From 1bd9180c67f5c665080781c1a77c0dd6bb73722f Mon Sep 17 00:00:00 2001 From: Reuben Turner Date: Wed, 17 Aug 2022 11:47:58 -0400 Subject: [PATCH] feat: add `backgroundColor` to `MacosSheet` (#291) --- CHANGELOG.md | 3 ++ example/lib/pages/dialogs_page.dart | 48 ++++++++++++----------------- example/pubspec.lock | 2 +- lib/src/sheets/macos_sheet.dart | 21 ++++++++++--- pubspec.lock | 2 +- pubspec.yaml | 4 +-- 6 files changed, 43 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33953df1..65821da3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.7.4] +* Added `backgroundColor` to `MacosSheet` + ## [1.7.3] * Fixed an issue where the `title` property of `TitleBar` did not apply a fitting `DefaultTextStyle` diff --git a/example/lib/pages/dialogs_page.dart b/example/lib/pages/dialogs_page.dart index 78da87d6..8e89d7e6 100644 --- a/example/lib/pages/dialogs_page.dart +++ b/example/lib/pages/dialogs_page.dart @@ -164,7 +164,8 @@ class _DialogsPageState extends State { onPressed: () { showMacosSheet( context: context, - builder: (_) => const MacosuiSheet(), + barrierDismissible: true, + builder: (_) => const DemoSheet(), ); }, ), @@ -206,8 +207,8 @@ class _DoNotNotifyRowState extends State { } } -class MacosuiSheet extends StatelessWidget { - const MacosuiSheet({super.key}); +class DemoSheet extends StatelessWidget { + const DemoSheet({super.key}); @override Widget build(BuildContext context) { @@ -227,34 +228,23 @@ class MacosuiSheet extends StatelessWidget { ), ), const SizedBox(height: 24), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - MacosListTile( - leading: MacosIcon(CupertinoIcons.lightbulb), - title: Text( - 'A robust library of Flutter components for macOS', - //style: MacosTheme.of(context).typography.headline, - ), - subtitle: Text( - 'Create native looking macOS applications using Flutter', - ), - ), - ], + const MacosListTile( + leading: MacosIcon(CupertinoIcons.lightbulb), + title: Text( + 'A robust library of Flutter components for macOS', + //style: MacosTheme.of(context).typography.headline, + ), + subtitle: Text( + 'Create native looking macOS applications using Flutter', + ), ), const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - MacosListTile( - leading: MacosIcon(CupertinoIcons.bolt), - title: Text( - 'Create beautiful macOS applications in minutes', - //style: MacosTheme.of(context).typography.headline, - ), - ), - SizedBox(width: 10), - ], + const MacosListTile( + leading: MacosIcon(CupertinoIcons.bolt), + title: Text( + 'Create beautiful macOS applications in minutes', + //style: MacosTheme.of(context).typography.headline, + ), ), const Spacer(), PushButton( diff --git a/example/pubspec.lock b/example/pubspec.lock index cb284195..64bfd46a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -87,7 +87,7 @@ packages: path: ".." relative: true source: path - version: "1.7.3" + version: "1.7.4" matcher: dependency: transitive description: diff --git a/lib/src/sheets/macos_sheet.dart b/lib/src/sheets/macos_sheet.dart index 9e19c691..0c152bf9 100644 --- a/lib/src/sheets/macos_sheet.dart +++ b/lib/src/sheets/macos_sheet.dart @@ -18,6 +18,7 @@ class MacosSheet extends StatelessWidget { this.insetPadding = _defaultInsetPadding, this.insetAnimationDuration = const Duration(milliseconds: 100), this.insetAnimationCurve = Curves.decelerate, + this.backgroundColor, }); /// The widget below this widget in the tree. @@ -36,6 +37,17 @@ class MacosSheet extends StatelessWidget { /// into the space that the dialog is placed in. final Curve insetAnimationCurve; + /// The background color for this widget. + /// + /// Defaults to + /// ```dart + /// brightness.resolve( + /// CupertinoColors.systemGrey6.color, + /// MacosColors.controlBackgroundColor.darkColor, + /// ) + /// ``` + final Color? backgroundColor; + @override Widget build(BuildContext context) { assert(debugCheckHasMacosTheme(context)); @@ -60,10 +72,11 @@ class MacosSheet extends StatelessWidget { curve: insetAnimationCurve, child: DecoratedBox( decoration: BoxDecoration( - color: brightness.resolve( - CupertinoColors.systemGrey6.color, - MacosColors.controlBackgroundColor.darkColor, - ), + color: backgroundColor ?? + brightness.resolve( + CupertinoColors.systemGrey6.color, + MacosColors.controlBackgroundColor.darkColor, + ), borderRadius: _kSheetBorderRadius, ), child: Container( diff --git a/pubspec.lock b/pubspec.lock index 75b81a34..1a21d943 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -112,7 +112,7 @@ packages: name: dart_code_metrics url: "https://pub.dartlang.org" source: hosted - version: "4.17.0" + version: "4.17.1" dart_style: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e5238f72..ca340113 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: macos_ui description: Flutter widgets and themes implementing the current macOS design language. -version: 1.7.3 +version: 1.7.4 homepage: "https://macosui.dev" repository: "https://github.com/GroovinChip/macos_ui" @@ -15,7 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - dart_code_metrics: ^4.17.0 + dart_code_metrics: ^4.17.1 flutter_lints: ^2.0.1 mocktail: ^0.3.0