Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.2.3]
### 🛠 Fixed 🛠
- Fixed sidebar background painting when wallpaper tinting is disabled: the macOS sidebar now stays transparent unless a decoration color is provided (previously showed a black strip). Addresses #587.

## [2.2.2]
### 🛠 Fixed 🛠
- Fixed setState called after dispose issue in MacosPulldownButton.
Expand Down
27 changes: 15 additions & 12 deletions lib/src/layout/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,15 @@ class _MacosWindowState extends State<MacosWindow> {
}
final MacosThemeData theme = MacosTheme.of(context);
late Color backgroundColor = widget.backgroundColor ?? theme.canvasColor;
late Color sidebarBackgroundColor;
late Color? sidebarBackgroundColor;
late Color endSidebarBackgroundColor;
Color dividerColor = theme.dividerColor;

final isMac = !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS;

// Respect the sidebar color override from parent if one is given
if (sidebar?.decoration?.color != null) {
sidebarBackgroundColor = sidebar!.decoration!.color!;
} else {
sidebarBackgroundColor = MacosColors.transparent;
}
sidebarBackgroundColor =
sidebar?.decoration?.color ?? (kIsWeb ? theme.canvasColor : null);
Comment on lines 204 to +206

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new sidebar background behavior across platforms (transparent on macOS unless Sidebar.decoration.color is set; theme.canvasColor on web). Since test/layout/window_test.dart already covers MacosWindow/Sidebar, it would be good to add a widget test asserting the expected background paint behavior for (1) no decoration color vs (2) a provided decoration color, to prevent regressions like the black strip issue.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests in de44e73


// Set the application window's brightness on macOS
MacOSBrightnessOverrideHandler.ensureMatchingBrightness(theme.brightness);
Expand Down Expand Up @@ -264,7 +261,11 @@ class _MacosWindowState extends State<MacosWindow> {
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
color: sidebarBackgroundColor,
// The sidebar background is painted exactly once by the inner
// ColoredBox (web) / DecoratedBox (macOS) below. Painting it
// here too would blend a semi-transparent
// Sidebar.decoration.color twice, making it darker than
// requested.
constraints: BoxConstraints(
minWidth: sidebar.minWidth,
maxWidth: sidebar.maxWidth!,
Expand All @@ -273,7 +274,7 @@ class _MacosWindowState extends State<MacosWindow> {
).normalize(),
child: kIsWeb
? ColoredBox(
color: theme.canvasColor,
color: sidebarBackgroundColor ?? theme.canvasColor,
child: Column(
children: [
// If an app is running on macOS, apply
Expand Down Expand Up @@ -326,10 +327,12 @@ class _MacosWindowState extends State<MacosWindow> {
: TransparentMacOSSidebar(
state: sidebarState,
child: DecoratedBox(
decoration: const BoxDecoration(
color: Color.fromRGBO(0, 0, 0, 1.0),
backgroundBlendMode: BlendMode.clear,
),
decoration:
(sidebar.decoration ?? const BoxDecoration())
.copyWith(
// Only paint if the caller set a color; null preserves native transparency.
color: sidebarBackgroundColor,
),
Comment on lines +331 to +335

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the non-web branch, AnimatedContainer already paints sidebarBackgroundColor via its color:. The new DecoratedBox also applies sidebarBackgroundColor as the BoxDecoration.color, which will effectively paint the color twice when the caller provides a semi-transparent Sidebar.decoration.color (making it appear darker than requested). Consider having only a single widget paint the background color (e.g., move the sidebar.decoration/color onto AnimatedContainer.decoration and drop the inner color paint) so opacity is applied exactly once.

Suggested change
(sidebar.decoration ?? const BoxDecoration())
.copyWith(
// Only paint if the caller set a color; null preserves native transparency.
color: sidebarBackgroundColor,
),
sidebar.decoration ?? const BoxDecoration(),

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dfae50f: dropped the redundant paint so the color is applied once.

child: Column(
children: [
// If an app is running on macOS, apply
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 2.2.2
version: 2.2.3
homepage: "https://macosui.dev"
repository: "https://github.com/GroovinChip/macos_ui"

Expand Down
47 changes: 47 additions & 0 deletions test/layout/window_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_window_utils/widgets/transparent_macos_sidebar.dart';

void main() {
group('MacosWindow', () {
Expand All @@ -15,6 +16,7 @@ void main() {
bool dragClosed = true,
double? dragClosedBuffer,
double? snapToStartBuffer,
BoxDecoration? decoration,
}) {
return Sidebar(
builder: (context, scrollController) => const Text('Hello there'),
Expand All @@ -24,6 +26,7 @@ void main() {
dragClosed: dragClosed,
dragClosedBuffer: dragClosedBuffer,
snapToStartBuffer: snapToStartBuffer,
decoration: decoration,
);
}

Expand Down Expand Up @@ -54,6 +57,50 @@ void main() {
expect(tester.widget<AnimatedPositioned>(backgroundFinder).left, 0);
}

// The sidebar background is painted by the DecoratedBox inside the
// TransparentMacOSSidebar. Grabbing its decoration lets us assert what
// color (if any) is painted for the sidebar.
BoxDecoration sidebarDecoration(WidgetTester tester) {
final decoratedBox = tester.widget<DecoratedBox>(
find
.descendant(
of: find.byType(TransparentMacOSSidebar),
matching: find.byType(DecoratedBox),
)
.first,
);
return decoratedBox.decoration as BoxDecoration;
}

group('background', () {
testWidgets(
'stays transparent when no decoration color is provided, so the '
'native sidebar material shows through',
(tester) async {
await tester.pumpWidget(viewBuilder(sidebarBuilder()));

expect(sidebarDecoration(tester).color, isNull);

await tester.pump(Duration.zero);
},
);

testWidgets('is painted with the provided Sidebar.decoration color', (
tester,
) async {
const color = MacosColors.systemBlueColor;
await tester.pumpWidget(
viewBuilder(
sidebarBuilder(decoration: const BoxDecoration(color: color)),
),
);

expect(sidebarDecoration(tester).color, color);

await tester.pump(Duration.zero);
});
});

testWidgets('initial width equals startWidth', (tester) async {
final sidebar = sidebarBuilder();
final view = viewBuilder(sidebar);
Expand Down