mirror of
https://github.com/immich-app/immich.git
synced 2025-11-17 00:32:37 +09:00
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker / pre-job (push) Waiting to run
Docker / Re-Tag ML () (push) Blocked by required conditions
Docker / Re-Tag ML (-armnn) (push) Blocked by required conditions
Docker / Re-Tag ML (-cuda) (push) Blocked by required conditions
Docker / Re-Tag ML (-openvino) (push) Blocked by required conditions
Docker / Re-Tag Server () (push) Blocked by required conditions
Docker / Build and Push ML (armnn, linux/arm64, -armnn) (push) Blocked by required conditions
Docker / Build and Push ML (cpu, linux/amd64,linux/arm64) (push) Blocked by required conditions
Docker / Build and Push ML (cuda, linux/amd64, -cuda) (push) Blocked by required conditions
Docker / Build and Push ML (openvino, linux/amd64, -openvino) (push) Blocked by required conditions
Docker / Build and Push Server (cpu, linux/amd64,linux/arm64) (push) Blocked by required conditions
Docker / Docker Build & Push Server Success (push) Blocked by required conditions
Docker / Docker Build & Push ML Success (push) Blocked by required conditions
Docs build / pre-job (push) Waiting to run
Docs build / Docs Build (push) Blocked by required conditions
Static Code Analysis / pre-job (push) Waiting to run
Static Code Analysis / Run Dart Code Analysis (push) Blocked by required conditions
Test / pre-job (push) Waiting to run
Test / Test & Lint Server (push) Blocked by required conditions
Test / Unit Test CLI (push) Blocked by required conditions
Test / Unit Test CLI (Windows) (push) Blocked by required conditions
Test / Test & Lint Web (push) Blocked by required conditions
Test / End-to-End Lint (push) Blocked by required conditions
Test / Medium Tests (Server) (push) Blocked by required conditions
Test / End-to-End Tests (Server & CLI) (push) Blocked by required conditions
Test / End-to-End Tests (Web) (push) Blocked by required conditions
Test / Unit Test Mobile (push) Blocked by required conditions
Test / Unit Test ML (push) Blocked by required conditions
Test / ShellCheck (push) Waiting to run
Test / OpenAPI Clients (push) Waiting to run
Test / TypeORM Checks (push) Waiting to run
refactor to use context helpers for consistency Co-authored-by: dvbthien <dvbthien@gmail.com>
107 lines
4.1 KiB
Dart
107 lines
4.1 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
|
import 'package:immich_mobile/widgets/settings/preference_settings/primary_color_setting.dart';
|
|
import 'package:immich_mobile/widgets/settings/settings_sub_title.dart';
|
|
import 'package:immich_mobile/widgets/settings/settings_switch_list_tile.dart';
|
|
import 'package:immich_mobile/utils/hooks/app_settings_update_hook.dart';
|
|
import 'package:immich_mobile/utils/immich_app_theme.dart';
|
|
|
|
class ThemeSetting extends HookConsumerWidget {
|
|
const ThemeSetting({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final currentThemeString = useAppSettingsState(AppSettingsEnum.themeMode);
|
|
final currentTheme = useValueNotifier(ref.read(immichThemeModeProvider));
|
|
final isDarkTheme = useValueNotifier(currentTheme.value == ThemeMode.dark);
|
|
final isSystemTheme =
|
|
useValueNotifier(currentTheme.value == ThemeMode.system);
|
|
|
|
final applyThemeToBackgroundSetting =
|
|
useAppSettingsState(AppSettingsEnum.colorfulInterface);
|
|
final applyThemeToBackgroundProvider =
|
|
useValueNotifier(ref.read(colorfulInterfaceSettingProvider));
|
|
|
|
useValueChanged(
|
|
currentThemeString.value,
|
|
(_, __) => currentTheme.value = switch (currentThemeString.value) {
|
|
"light" => ThemeMode.light,
|
|
"dark" => ThemeMode.dark,
|
|
_ => ThemeMode.system,
|
|
},
|
|
);
|
|
|
|
useValueChanged(
|
|
applyThemeToBackgroundSetting.value,
|
|
(_, __) => applyThemeToBackgroundProvider.value =
|
|
applyThemeToBackgroundSetting.value,
|
|
);
|
|
|
|
void onThemeChange(bool isDark) {
|
|
if (isDark) {
|
|
ref.watch(immichThemeModeProvider.notifier).state = ThemeMode.dark;
|
|
currentThemeString.value = "dark";
|
|
} else {
|
|
ref.watch(immichThemeModeProvider.notifier).state = ThemeMode.light;
|
|
currentThemeString.value = "light";
|
|
}
|
|
}
|
|
|
|
void onSystemThemeChange(bool isSystem) {
|
|
if (isSystem) {
|
|
currentThemeString.value = "system";
|
|
isSystemTheme.value = true;
|
|
ref.watch(immichThemeModeProvider.notifier).state = ThemeMode.system;
|
|
} else {
|
|
final currentSystemBrightness = context.platformBrightness;
|
|
isSystemTheme.value = false;
|
|
isDarkTheme.value = currentSystemBrightness == Brightness.dark;
|
|
if (currentSystemBrightness == Brightness.light) {
|
|
currentThemeString.value = "light";
|
|
ref.watch(immichThemeModeProvider.notifier).state = ThemeMode.light;
|
|
} else if (currentSystemBrightness == Brightness.dark) {
|
|
currentThemeString.value = "dark";
|
|
ref.watch(immichThemeModeProvider.notifier).state = ThemeMode.dark;
|
|
}
|
|
}
|
|
}
|
|
|
|
void onSurfaceColorSettingChange(bool useColorfulInterface) {
|
|
applyThemeToBackgroundSetting.value = useColorfulInterface;
|
|
ref.watch(colorfulInterfaceSettingProvider.notifier).state =
|
|
useColorfulInterface;
|
|
}
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SettingsSubTitle(title: "theme_setting_theme_title".tr()),
|
|
SettingsSwitchListTile(
|
|
valueNotifier: isSystemTheme,
|
|
title: 'theme_setting_system_theme_switch'.tr(),
|
|
onChanged: onSystemThemeChange,
|
|
),
|
|
if (currentTheme.value != ThemeMode.system)
|
|
SettingsSwitchListTile(
|
|
valueNotifier: isDarkTheme,
|
|
title: 'theme_setting_dark_mode_switch'.tr(),
|
|
onChanged: onThemeChange,
|
|
),
|
|
const PrimaryColorSetting(),
|
|
SettingsSwitchListTile(
|
|
valueNotifier: applyThemeToBackgroundProvider,
|
|
title: "theme_setting_colorful_interface_title".tr(),
|
|
subtitle: 'theme_setting_colorful_interface_subtitle'.tr(),
|
|
onChanged: onSurfaceColorSettingChange,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|