Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use app theme colors in color property #246

Merged
merged 5 commits into from
Feb 6, 2024
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
2 changes: 1 addition & 1 deletion docs/docs/basics/parsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MiraiTextParser extends MiraiParser<MiraiText> {
maxLines: model.maxLines,
semanticsLabel: model.semanticsLabel,
textWidthBasis: model.textWidthBasis,
selectionColor: model.selectionColor.toColor,
selectionColor: model.selectionColor.toColor(context),
);
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/mirai_gallery/assets/json/app_bar_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"onPressed": {}
},
"backgroundColor": "primary",
"actions": [
{
"type": "iconButton",
Expand Down
2 changes: 1 addition & 1 deletion examples/mirai_gallery/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion examples/mirai_gallery/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions examples/mirai_gallery/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
6 changes: 3 additions & 3 deletions examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -579,7 +579,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -628,7 +628,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MiraiDialogActionParser extends MiraiActionParser<MiraiDialogAction> {
context: context,
builder: (_) => widget,
barrierDismissible: model.barrierDismissible,
barrierColor: model.barrierColor.toColor,
barrierColor: model.barrierColor.toColor(context),
barrierLabel: model.barrierLabel,
useSafeArea: model.useSafeArea,
traversalEdgeBehavior: model.traversalEdgeBehavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class MiraiModalBottomSheetActionParser
return showModalBottomSheet(
context: context,
builder: (context) => widget,
backgroundColor: model.backgroundColor.toColor,
backgroundColor: model.backgroundColor.toColor(context),
barrierLabel: model.barrierLabel,
elevation: model.elevation,
shape: model.shape?.parse,
shape: model.shape?.parse(context),
constraints: model.constraints?.parse,
barrierColor: model.barrierColor.toColor,
barrierColor: model.barrierColor.toColor(context),
isScrollControlled: model.isScrollControlled,
useRootNavigator: model.useRootNavigator,
isDismissible: model.isDismissible,
Expand Down
16 changes: 8 additions & 8 deletions packages/mirai/lib/src/framework/mirai_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ class MiraiApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (routerDelegate != null || routerConfig != null) {
return _materialRouterApp;
return _materialRouterApp(context);
}
return _materialApp;
return _materialApp(context);
}

Widget get _materialApp {
Widget _materialApp(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
scaffoldMessengerKey: scaffoldMessengerKey,
Expand All @@ -162,8 +162,8 @@ class MiraiApp extends StatelessWidget {
builder: builder,
title: title,
onGenerateTitle: onGenerateTitle,
theme: theme?.parse,
darkTheme: darkTheme?.parse,
theme: theme?.parse(context),
darkTheme: darkTheme?.parse(context),
highContrastTheme: highContrastTheme,
highContrastDarkTheme: highContrastDarkTheme,
themeMode: themeMode,
Expand All @@ -188,7 +188,7 @@ class MiraiApp extends StatelessWidget {
);
}

Widget get _materialRouterApp {
Widget _materialRouterApp(BuildContext context) {
return MaterialApp.router(
scaffoldMessengerKey: scaffoldMessengerKey,
routeInformationProvider: routeInformationProvider,
Expand All @@ -200,8 +200,8 @@ class MiraiApp extends StatelessWidget {
title: title,
onGenerateTitle: onGenerateTitle,
color: color,
theme: theme?.parse,
darkTheme: darkTheme?.parse,
theme: theme?.parse(context),
darkTheme: darkTheme?.parse(context),
highContrastTheme: highContrastTheme,
highContrastDarkTheme: highContrastDarkTheme,
themeMode: themeMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class MiraiAlertDialogParser extends MiraiParser<MiraiAlertDialog> {
return AlertDialog(
icon: Mirai.fromJson(model.icon, context),
iconPadding: model.iconPadding?.parse,
iconColor: model.iconColor?.toColor,
iconColor: model.iconColor?.toColor(context),
title: Mirai.fromJson(model.title, context),
titlePadding: model.titlePadding?.parse,
titleTextStyle: model.titleTextStyle?.parse,
titleTextStyle: model.titleTextStyle?.parse(context),
content: Mirai.fromJson(model.content, context),
contentPadding: model.contentPadding.parse,
contentTextStyle: model.contentTextStyle?.parse,
contentTextStyle: model.contentTextStyle?.parse(context),
actions: model.actions
?.map((action) => Mirai.fromJson(action, context) ?? const SizedBox())
.toList(),
Expand All @@ -38,7 +38,7 @@ class MiraiAlertDialogParser extends MiraiParser<MiraiAlertDialog> {
actionsOverflowDirection: model.actionsOverflowDirection,
actionsOverflowButtonSpacing: model.actionsOverflowButtonSpacing,
buttonPadding: model.buttonPadding.parse,
backgroundColor: model.backgroundColor.toColor,
backgroundColor: model.backgroundColor.toColor(context),
elevation: model.elevation,
semanticLabel: model.semanticLabel,
insetPadding: model.insetPadding.parse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class MiraiAppBarParser extends MiraiParser<MiraiAppBar> {
return AppBar(
leading: Mirai.fromJson(model.leading, context),
title: Mirai.fromJson(model.title, context),
titleTextStyle: model.titleTextStyle?.parse,
toolbarTextStyle: model.toolbarTextStyle?.parse,
shadowColor: model.shadowColor?.toColor,
backgroundColor: model.backgroundColor?.toColor,
foregroundColor: model.foregroundColor?.toColor,
surfaceTintColor: model.surfaceTintColor?.toColor,
titleTextStyle: model.titleTextStyle?.parse(context),
toolbarTextStyle: model.toolbarTextStyle?.parse(context),
shadowColor: model.shadowColor?.toColor(context),
backgroundColor: model.backgroundColor?.toColor(context),
foregroundColor: model.foregroundColor?.toColor(context),
surfaceTintColor: model.surfaceTintColor?.toColor(context),
actions: model.actions
.map((action) => Mirai.fromJson(action, context) ?? const SizedBox())
.toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ class MiraiAppBarTheme with _$MiraiAppBarTheme {
}

extension MiraiAppBarThemeParser on MiraiAppBarTheme {
AppBarTheme? get parse {
AppBarTheme? parse(BuildContext context) {
return AppBarTheme(
backgroundColor: backgroundColor.toColor,
foregroundColor: foregroundColor.toColor,
backgroundColor: backgroundColor.toColor(context),
foregroundColor: foregroundColor.toColor(context),
elevation: elevation,
scrolledUnderElevation: scrolledUnderElevation,
shadowColor: shadowColor.toColor,
surfaceTintColor: surfaceTintColor.toColor,
iconTheme: iconTheme?.parse,
actionsIconTheme: actionsIconTheme?.parse,
shadowColor: shadowColor.toColor(context),
surfaceTintColor: surfaceTintColor.toColor(context),
iconTheme: iconTheme?.parse(context),
actionsIconTheme: actionsIconTheme?.parse(context),
centerTitle: centerTitle,
titleSpacing: titleSpacing,
toolbarHeight: toolbarHeight,
toolbarTextStyle: toolbarTextStyle?.parse,
titleTextStyle: titleTextStyle?.parse,
systemOverlayStyle: systemOverlayStyle?.parse,
toolbarTextStyle: toolbarTextStyle?.parse(context),
titleTextStyle: titleTextStyle?.parse(context),
systemOverlayStyle: systemOverlayStyle?.parse(context),
);
}
}
4 changes: 2 additions & 2 deletions packages/mirai/lib/src/parsers/mirai_border/mirai_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class MiraiBorder with _$MiraiBorder {
}

extension MiraiBorderParser on MiraiBorder {
Border get parse {
Border parse(BuildContext context) {
return Border.all(
color: color.toColor ?? const Color(0xFF000000),
color: color.toColor(context) ?? const Color(0xFF000000),
width: width,
style: borderStyle,
strokeAlign: strokeAlign,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class MiraiBorderSide with _$MiraiBorderSide {
}

extension MiraiBorderSideParser on MiraiBorderSide? {
BorderSide get parse {
BorderSide parse(BuildContext context) {
return BorderSide(
color: this?.color.toColor ?? const Color(0xFF000000),
color: this?.color.toColor(context) ?? const Color(0xFF000000),
width: this?.width ?? 0.0,
style: this?.borderStyle ?? BorderStyle.solid,
strokeAlign: this?.strokeAlign ?? 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class MiraiBottomAppBarTheme with _$MiraiBottomAppBarTheme {
}

extension MiraiBottomAppBarThemeParser on MiraiBottomAppBarTheme {
BottomAppBarTheme? get parse {
BottomAppBarTheme? parse(BuildContext context) {
return BottomAppBarTheme(
color: color?.toColor,
color: color?.toColor(context),
elevation: elevation,
height: height,
surfaceTintColor: surfaceTintColor.toColor,
shadowColor: shadowColor.toColor,
surfaceTintColor: surfaceTintColor.toColor(context),
shadowColor: shadowColor.toColor(context),
padding: padding?.parse,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class MiraiBottomNavBarThemeData with _$MiraiBottomNavBarThemeData {
}

extension MiraiBottomNavBarThemeDataParser on MiraiBottomNavBarThemeData {
BottomNavigationBarThemeData? get parse {
BottomNavigationBarThemeData? parse(BuildContext context) {
return BottomNavigationBarThemeData(
backgroundColor: backgroundColor.toColor,
backgroundColor: backgroundColor.toColor(context),
elevation: elevation,
selectedIconTheme: selectedIconTheme?.parse,
unselectedIconTheme: unselectedIconTheme?.parse,
selectedItemColor: selectedItemColor.toColor,
unselectedItemColor: unselectedItemColor.toColor,
selectedLabelStyle: selectedLabelStyle?.parse,
unselectedLabelStyle: unselectedLabelStyle?.parse,
selectedIconTheme: selectedIconTheme?.parse(context),
unselectedIconTheme: unselectedIconTheme?.parse(context),
selectedItemColor: selectedItemColor.toColor(context),
unselectedItemColor: unselectedItemColor.toColor(context),
selectedLabelStyle: selectedLabelStyle?.parse(context),
unselectedLabelStyle: unselectedLabelStyle?.parse(context),
showSelectedLabels: showSelectedLabels,
showUnselectedLabels: showUnselectedLabels,
type: type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class MiraiBottomNavigationBarParser
currentIndex: model.currentIndex,
elevation: model.elevation,
type: model.navBarType,
fixedColor: model.fixedColor?.toColor,
backgroundColor: model.backgroundColor?.toColor,
fixedColor: model.fixedColor?.toColor(context),
backgroundColor: model.backgroundColor?.toColor(context),
iconSize: model.iconSize,
selectedItemColor: model.selectedItemColor?.toColor,
unselectedItemColor: model.unselectedItemColor?.toColor,
selectedItemColor: model.selectedItemColor?.toColor(context),
unselectedItemColor: model.unselectedItemColor?.toColor(context),
selectedFontSize: model.selectedFontSize,
unselectedFontSize: model.unselectedFontSize,
selectedLabelStyle: model.selectedLabelStyle?.parse,
unselectedLabelStyle: model.unselectedLabelStyle?.parse,
selectedLabelStyle: model.selectedLabelStyle?.parse(context),
unselectedLabelStyle: model.unselectedLabelStyle?.parse(context),
showSelectedLabels: model.showSelectedLabels,
showUnselectedLabels: model.showUnselectedLabels,
enableFeedback: model.enableFeedback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ class MiraiBottomSheetThemeData with _$MiraiBottomSheetThemeData {
}

extension MiraiBottomSheetThemeDataParser on MiraiBottomSheetThemeData {
BottomSheetThemeData get parse {
BottomSheetThemeData parse(BuildContext context) {
return BottomSheetThemeData(
backgroundColor: backgroundColor.toColor,
surfaceTintColor: surfaceTintColor.toColor,
backgroundColor: backgroundColor.toColor(context),
surfaceTintColor: surfaceTintColor.toColor(context),
elevation: elevation,
modalBackgroundColor: modalBackgroundColor.toColor,
modalBarrierColor: modalBarrierColor.toColor,
shadowColor: shadowColor.toColor,
modalBackgroundColor: modalBackgroundColor.toColor(context),
modalBarrierColor: modalBarrierColor.toColor(context),
shadowColor: shadowColor.toColor(context),
modalElevation: modalElevation,
shape: shape?.parse,
shape: shape?.parse(context),
showDragHandle: showDragHandle,
dragHandleColor: dragHandleColor.toColor,
dragHandleColor: dragHandleColor.toColor(context),
dragHandleSize: dragHandleSize.parse,
clipBehavior: clipBehavior,
constraints: constraints?.parse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ class MiraiBoxDecoration with _$MiraiBoxDecoration {
}

extension MiraiBoxDecorationParser on MiraiBoxDecoration? {
BoxDecoration? get parse {
BoxDecoration? parse(BuildContext context) {
return BoxDecoration(
color: this?.color.toColor,
color: this?.color.toColor(context),
backgroundBlendMode: this?.blendMode,
boxShadow: this?.boxShadow?.map((elem) => elem.parse).toList(),
boxShadow: this?.boxShadow?.map((elem) => elem.parse(context)).toList(),
shape: this?.shape ?? BoxShape.rectangle,
border: this?.border?.parse,
border: this?.border?.parse(context),
borderRadius: this?.borderRadius.parse,
image: this?.image.parse,
gradient: this?.gradient?.parse,
gradient: this?.gradient?.parse(context),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class MiraiBoxShadow with _$MiraiBoxShadow {
}

extension MiraiBoxShadowParser on MiraiBoxShadow? {
BoxShadow get parse {
BoxShadow parse(BuildContext context) {
return BoxShadow(
color: this?.color.toColor ?? const Color(0xFF000000),
color: this?.color.toColor(context) ?? const Color(0xFF000000),
blurRadius: this?.blurRadius ?? 0.0,
offset: this?.offset.parse ?? Offset.zero,
spreadRadius: this?.spreadRadius ?? 0.0,
Expand Down
Loading
Loading