migrate dynamic theme

This commit is contained in:
shenlong-tanwen
2026-05-03 21:34:42 +07:00
parent 68a718fab4
commit ca95fbb47d
8 changed files with 38 additions and 26 deletions
@@ -4,19 +4,27 @@ import 'package:immich_mobile/constants/colors.dart';
class ThemeConfig {
final ThemeMode mode;
final ImmichColorPreset primaryColor;
final bool dynamicTheme;
const ThemeConfig({this.mode = .system, this.primaryColor = .indigo});
const ThemeConfig({this.mode = .system, this.primaryColor = .indigo, this.dynamicTheme = false});
ThemeConfig copyWith({ThemeMode? mode, ImmichColorPreset? primaryColor}) =>
.new(mode: mode ?? this.mode, primaryColor: primaryColor ?? this.primaryColor);
ThemeConfig copyWith({ThemeMode? mode, ImmichColorPreset? primaryColor, bool? dynamicTheme}) => .new(
mode: mode ?? this.mode,
primaryColor: primaryColor ?? this.primaryColor,
dynamicTheme: dynamicTheme ?? this.dynamicTheme,
);
@override
bool operator ==(Object other) =>
identical(this, other) || (other is ThemeConfig && other.mode == mode && other.primaryColor == primaryColor);
identical(this, other) ||
(other is ThemeConfig &&
other.mode == mode &&
other.primaryColor == primaryColor &&
other.dynamicTheme == dynamicTheme);
@override
int get hashCode => Object.hash(mode, primaryColor);
int get hashCode => Object.hash(mode, primaryColor, dynamicTheme);
@override
String toString() => 'ThemeConfig(mode: $mode, primaryColor: $primaryColor)';
String toString() => 'ThemeConfig(mode: $mode, primaryColor: $primaryColor, dynamicTheme: $dynamicTheme)';
}
@@ -17,6 +17,7 @@ enum MetadataKey<T extends Object> {
// Theme
primaryColor<ImmichColorPreset>(.appConfig, 'theme.primaryColor', .indigo, _EnumCodec(ImmichColorPreset.values)),
themeMode<ThemeMode>(.appConfig, 'theme.mode', .system, _EnumCodec(ThemeMode.values)),
dynamicTheme<bool>(.appConfig, 'dynamicTheme', false),
// Log
logLevel<LogLevel>(.systemConfig, 'log.level', .info, _EnumCodec(LogLevel.values));
+1 -1
View File
@@ -49,7 +49,6 @@ enum StoreKey<T> {
customHeaders<String>._(127),
// theme settings
dynamicTheme<bool>._(129),
colorfulInterface<bool>._(130),
syncAlbums<bool>._(131),
@@ -95,6 +94,7 @@ enum StoreKey<T> {
// Legacy keys that have been migrated to the new metadata store
legacyPrimaryColor<String>._(128),
legacyDynamicTheme<bool>._(129),
legacyThemeMode<String>._(102),
legacyLogLevel<int>._(115);