Skip to content
Merged
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
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class MyApp extends StatelessWidget {
title: 'macos_ui example',
style: Style(
brightness: Brightness.light,
accentColor: CupertinoColors.systemIndigo,
primaryColor: CupertinoColors.systemIndigo,
),
darkStyle: Style(
brightness: Brightness.dark,
accentColor: CupertinoColors.systemIndigo,
primaryColor: CupertinoColors.systemIndigo,
),
themeMode: appTheme.mode,
debugShowCheckedModeBanner: false, //yay!
Expand All @@ -43,7 +43,7 @@ class Demo extends StatelessWidget {
child: Container(
height: 50.0,
width: 50.0,
color: context.theme.accentColor,
color: context.style.primaryColor,
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/layout/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Scaffold extends StatelessWidget {
Widget build(BuildContext context) {
debugCheckHasMacosTheme(context);

final style = context.theme;
final style = context.style;
late Color bodyColor;
late Color sidebarColor;
late Color gripColor;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/macos_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MacosApp extends StatefulWidget {
this.builder,
this.title = '',
this.onGenerateTitle,
this.primaryColor,
this.color,
this.locale,
this.localizationsDelegates,
this.localeListResolutionCallback,
Expand Down Expand Up @@ -85,7 +85,7 @@ class MacosApp extends StatefulWidget {
this.builder,
this.title = '',
this.onGenerateTitle,
this.primaryColor,
this.color,
this.locale,
this.localizationsDelegates,
this.localeListResolutionCallback,
Expand Down Expand Up @@ -170,7 +170,7 @@ class MacosApp extends StatefulWidget {
final GenerateAppTitle? onGenerateTitle;

/// {@macro flutter.widgets.widgetsApp.color}
final Color? primaryColor;
final Color? color;

/// {@macro flutter.widgets.widgetsApp.locale}
final Locale? locale;
Expand Down Expand Up @@ -329,7 +329,7 @@ class _MacosAppState extends State<MacosApp> {
}

Widget _buildApp(BuildContext context) {
final defaultColor = widget.primaryColor ?? CupertinoColors.systemBlue;
final defaultColor = widget.color ?? CupertinoColors.systemBlue;
if (_usesRouter) {
return c.CupertinoApp.router(
key: GlobalObjectKey(this),
Expand Down
12 changes: 10 additions & 2 deletions lib/src/styles/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class MacosTheme extends InheritedWidget {
}

extension themeContext on BuildContext {
Style get theme => MacosTheme.of(this);
Style? get maybeTheme => MacosTheme.maybeOf(this);
Style get style => MacosTheme.of(this);
Style? get maybeStyle => MacosTheme.maybeOf(this);
}

extension brightnessExtension on Brightness {
Expand All @@ -48,11 +48,14 @@ class Style with Diagnosticable {
const Style({
this.typography,
this.brightness,
this.primaryColor,
this.accentColor,
this.animationCurve,
this.mediumAnimationDuration,
});

final CupertinoDynamicColor? primaryColor;

final CupertinoDynamicColor? accentColor;

final Curve? animationCurve;
Expand All @@ -69,6 +72,7 @@ class Style with Diagnosticable {
brightness: brightness,
typography: Typography.defaultTypography(brightness: brightness)
.copyWith(typography),
primaryColor: primaryColor ?? CupertinoColors.systemBlue,
accentColor: accentColor ?? CupertinoColors.systemBlue,
mediumAnimationDuration: Duration(milliseconds: 300),
animationCurve: Curves.easeInOut,
Expand All @@ -90,12 +94,16 @@ class Style with Diagnosticable {
animationCurve: other.animationCurve ?? animationCurve,
mediumAnimationDuration:
other.mediumAnimationDuration ?? mediumAnimationDuration,
primaryColor: other.primaryColor ?? primaryColor,
accentColor: other.accentColor ?? accentColor,
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(EnumProperty('brightness', brightness));
properties.add(EnumProperty('primaryColor', primaryColor));
properties.add(EnumProperty('accentColor', accentColor));
}
}
2 changes: 1 addition & 1 deletion lib/src/util.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:macos_ui/macos_ui.dart';

bool debugCheckHasMacosTheme(BuildContext context, [bool check = true]) {
final has = context.maybeTheme != null;
final has = context.maybeStyle != null;
if (check)
assert(
has,
Expand Down