Skip to content

Commit

Permalink
Fix dynamic color issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chen08209 committed Oct 27, 2024
1 parent c7a9159 commit 51e888e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/models/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const defaultThemeProps = ThemeProps();
@freezed
class ThemeProps with _$ThemeProps {
const factory ThemeProps({
@Default(0xFF795548) int? primaryColor,
int? primaryColor,
@Default(ThemeMode.system) ThemeMode themeMode,
@Default(false) bool prueBlack,
@Default(FontFamily.system) FontFamily fontFamily,
Expand All @@ -158,14 +158,20 @@ class ThemeProps with _$ThemeProps {
factory ThemeProps.realFromJson(Map<String, Object?>? json) {
if (json == null) {
return Platform.isWindows
? defaultThemeProps.copyWith(fontFamily: FontFamily.miSans)
? defaultThemeProps.copyWith(
fontFamily: FontFamily.miSans,
primaryColor: defaultPrimaryColor.value,
)
: defaultThemeProps;
}
try {
return ThemeProps.fromJson(json);
} catch (_) {
return Platform.isWindows
? defaultThemeProps.copyWith(fontFamily: FontFamily.miSans)
? defaultThemeProps.copyWith(
fontFamily: FontFamily.miSans,
primaryColor: defaultPrimaryColor.value,
)
: defaultThemeProps;
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/models/generated/config.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ class __$$ThemePropsImplCopyWithImpl<$Res>
@JsonSerializable()
class _$ThemePropsImpl implements _ThemeProps {
const _$ThemePropsImpl(
{this.primaryColor = 0xFF795548,
{this.primaryColor,
this.themeMode = ThemeMode.system,
this.prueBlack = false,
this.fontFamily = FontFamily.system});
Expand All @@ -1676,7 +1676,6 @@ class _$ThemePropsImpl implements _ThemeProps {
_$$ThemePropsImplFromJson(json);

@override
@JsonKey()
final int? primaryColor;
@override
@JsonKey()
Expand Down
2 changes: 1 addition & 1 deletion lib/models/generated/config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51e888e

Please sign in to comment.