Skip to content

Commit

Permalink
feat: add backgroundColor to MacosSheet (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
GroovinChip authored Aug 17, 2022
1 parent 53c1d24 commit 1bd9180
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
48 changes: 19 additions & 29 deletions example/lib/pages/dialogs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class _DialogsPageState extends State<DialogsPage> {
onPressed: () {
showMacosSheet(
context: context,
builder: (_) => const MacosuiSheet(),
barrierDismissible: true,
builder: (_) => const DemoSheet(),
);
},
),
Expand Down Expand Up @@ -206,8 +207,8 @@ class _DoNotNotifyRowState extends State<DoNotNotifyRow> {
}
}

class MacosuiSheet extends StatelessWidget {
const MacosuiSheet({super.key});
class DemoSheet extends StatelessWidget {
const DemoSheet({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.7.3"
version: "1.7.4"
matcher:
dependency: transitive
description:
Expand Down
21 changes: 17 additions & 4 deletions lib/src/sheets/macos_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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));
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions 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: 1.7.3
version: 1.7.4
homepage: "https://macosui.dev"
repository: "https://github.com/GroovinChip/macos_ui"

Expand All @@ -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

Expand Down

0 comments on commit 1bd9180

Please sign in to comment.