Skip to content

Commit

Permalink
fix: windows window control and titlebar color (#889)
Browse files Browse the repository at this point in the history
* fix: windows window control and titlebar color

On Windows the titlebar color was not correct in the light mode when overwriting the foreground color via YaruWindowTitleBar the color was not correctly forwarded to the close button

* Update lib/src/widgets/yaru_window_control.dart

Co-authored-by: Lukas Klingsbo <[email protected]>

---------

Co-authored-by: Lukas Klingsbo <[email protected]>
  • Loading branch information
Feichtmeier and spydon authored Apr 16, 2024
1 parent ef61073 commit 7b485d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
4 changes: 1 addition & 3 deletions lib/src/widgets/yaru_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ class YaruTitleBar extends StatelessWidget implements PreferredSizeWidget {

final closeButton = YaruWindowControl(
platform: windowControlPlatform,
iconColor: windowControlPlatform == YaruWindowControlPlatform.windows
? null
: MaterialStatePropertyAll(foregroundColor),
iconColor: MaterialStatePropertyAll(foregroundColor),
type: YaruWindowControlType.close,
onTap: onClose != null ? () => onClose!(context) : null,
);
Expand Down
35 changes: 16 additions & 19 deletions lib/src/widgets/yaru_window_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,24 @@ class _YaruWindowControlState extends State<YaruWindowControl>
}

Color _getIconColor(ColorScheme colorScheme) {
final iconColor = widget.iconColor?.resolve(_states);
if (iconColor != null) return iconColor;
final color = switch (style) {
YaruWindowControlPlatform.yaru => _getYaruIconColor(colorScheme),
YaruWindowControlPlatform.windows => _getWindowsIconColor(colorScheme)
};

switch (style) {
case YaruWindowControlPlatform.yaru:
return _getYaruIconColor(colorScheme);
case YaruWindowControlPlatform.windows:
return _getWindowsIconColor(colorScheme);
return color.withOpacity(interactive ? 1.0 : 0.5);
}

Color _getYaruIconColor(ColorScheme colorScheme) {
return widget.iconColor?.resolve(_states) ?? colorScheme.onSurface;
}

Color _getWindowsIconColor(ColorScheme colorScheme) {
final color = widget.iconColor?.resolve(_states) ?? colorScheme.onSurface;
if (interactive && _hovered && widget.type == YaruWindowControlType.close) {
return Colors.white;
}
return color;
}

double get _iconSize {
Expand All @@ -264,18 +273,6 @@ class _YaruWindowControlState extends State<YaruWindowControl>
}
}

Color _getYaruIconColor(ColorScheme colorScheme) {
return colorScheme.onSurface.withOpacity(interactive ? 1.0 : 0.5);
}

Color _getWindowsIconColor(ColorScheme colorScheme) {
if (_hovered && interactive && widget.type == YaruWindowControlType.close) {
return widget.iconColor?.resolve(_states) ?? Colors.white;
}

return colorScheme.onSurface.withOpacity(interactive ? 1.0 : 0.5);
}

Widget _buildBoxDecoration({
required Widget child,
required ColorScheme colorScheme,
Expand Down

0 comments on commit 7b485d5

Please sign in to comment.