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
@@ -7,10 +7,8 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/extensions/theme_extensions.dart';
import 'package:immich_mobile/providers/infrastructure/metadata.provider.dart';
import 'package:immich_mobile/providers/theme.provider.dart';
import 'package:immich_mobile/services/app_settings.service.dart';
import 'package:immich_mobile/theme/color_scheme.dart';
import 'package:immich_mobile/theme/dynamic_theme.dart';
import 'package:immich_mobile/utils/hooks/app_settings_update_hook.dart';
class PrimaryColorSetting extends HookConsumerWidget {
const PrimaryColorSetting({super.key});
@@ -18,9 +16,7 @@ class PrimaryColorSetting extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final themeProvider = ref.read(immichThemeProvider);
final currentPreset = ref.watch(appConfigProvider.select((config) => config.theme.primaryColor));
final systemPrimaryColorSetting = useAppSettingsState(AppSettingsEnum.dynamicTheme);
final themeConfig = ref.watch(appConfigProvider.select((config) => config.theme));
const tileSize = 55.0;
@@ -31,9 +27,7 @@ class PrimaryColorSetting extends HookConsumerWidget {
}
onUseSystemColorChange(bool newValue) {
systemPrimaryColorSetting.value = newValue;
ref.watch(dynamicThemeSettingProvider.notifier).state = newValue;
ref.invalidate(immichThemeProvider);
ref.read(metadataProvider).write(MetadataKey.dynamicTheme, newValue);
popBottomSheet();
}
@@ -41,11 +35,10 @@ class PrimaryColorSetting extends HookConsumerWidget {
ref.read(metadataProvider).write(MetadataKey.primaryColor, colorPreset);
//turn off system color setting
if (systemPrimaryColorSetting.value) {
onUseSystemColorChange(false);
} else {
popBottomSheet();
if (themeConfig.dynamicTheme) {
ref.read(metadataProvider).write(MetadataKey.dynamicTheme, false);
}
popBottomSheet();
}
buildPrimaryColorTile({
@@ -115,7 +108,7 @@ class PrimaryColorSetting extends HookConsumerWidget {
'theme_setting_system_primary_color_title'.tr(),
style: context.textTheme.bodyLarge?.copyWith(fontWeight: FontWeight.w500, height: 1.5),
),
value: systemPrimaryColorSetting.value,
value: themeConfig.dynamicTheme,
onChanged: onUseSystemColorChange,
),
),
@@ -133,7 +126,7 @@ class PrimaryColorSetting extends HookConsumerWidget {
topColor: theme.light.primary,
bottomColor: theme.dark.primary,
tileSize: tileSize,
showSelector: currentPreset == preset && !systemPrimaryColorSetting.value,
showSelector: themeConfig.primaryColor == preset && !themeConfig.dynamicTheme,
),
);
}).toList(),