Skip to content

Commit 29de17b

Browse files
committed
Use translucent color for window button actions
1 parent 7f85459 commit 29de17b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/main.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,20 +448,33 @@ class _MyHomePageState extends State<MyHomePage> {
448448

449449
class WindowButtons extends StatelessWidget {
450450
const WindowButtons({Key? key}) : super(key: key);
451+
static Color windowButtonAlphaColor(ThemeData style, Set<ButtonStates> states) {
452+
if (style.brightness == Brightness.light) {
453+
if (states.isPressing) return Colors.black.withOpacity(0.075);
454+
if (states.isHovering) return Colors.black.withOpacity(0.11);
455+
return Colors.transparent;
456+
} else {
457+
if (states.isPressing) return Colors.white.withOpacity(0.03);
458+
if (states.isHovering) return Colors.white.withOpacity(0.06);
459+
return Colors.transparent;
460+
}
461+
}
451462

452463
@override
453464
Widget build(BuildContext context) {
454465
assert(debugCheckHasFluentTheme(context));
455466
assert(debugCheckHasFluentLocalizations(context));
456467
final ThemeData theme = FluentTheme.of(context);
468+
final mica = GState.mica.of(context);
469+
457470
final buttonColors = WindowButtonColors(
458471
iconNormal: theme.inactiveColor,
459472
iconMouseDown: theme.inactiveColor,
460473
iconMouseOver: theme.inactiveColor,
461474
//Fixed button colors
462-
mouseOver: ButtonThemeData.buttonColor(
475+
mouseOver: mica.enabled ? windowButtonAlphaColor(theme, {ButtonStates.hovering}) : ButtonThemeData.buttonColor(
463476
theme.brightness, {ButtonStates.hovering}).lerpWith(Colors.black, 0.12),
464-
mouseDown: ButtonThemeData.buttonColor(
477+
mouseDown: mica.enabled ? windowButtonAlphaColor(theme, {ButtonStates.pressing}) : ButtonThemeData.buttonColor(
465478
theme.brightness, {ButtonStates.pressing}).lerpWith(theme.shadowColor, 0.12).withAlpha(150),
466479
);
467480
final closeButtonColors = WindowButtonColors(

0 commit comments

Comments
 (0)