mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Merge upstream
This commit is contained in:
@@ -6,7 +6,11 @@ enum AppSettingsEnum<T> {
|
||||
themeMode<String>("themeMode", "system"), // "light","dark","system"
|
||||
tilesPerRow<int>("tilesPerRow", 4),
|
||||
uploadErrorNotificationGracePeriod<int>(
|
||||
"uploadErrorNotificationGracePeriod", 2),
|
||||
"uploadErrorNotificationGracePeriod",
|
||||
2,
|
||||
),
|
||||
backgroundBackupTotalProgress<bool>("backgroundBackupTotalProgress", true),
|
||||
backgroundBackupSingleProgress<bool>("backgroundBackupSingleProgress", false),
|
||||
storageIndicator<bool>("storageIndicator", true),
|
||||
thumbnailCacheSize<int>("thumbnailCacheSize", 10000),
|
||||
imageCacheSize<int>("imageCacheSize", 350),
|
||||
|
||||
@@ -15,12 +15,20 @@ class NotificationSetting extends HookConsumerWidget {
|
||||
final appSettingService = ref.watch(appSettingsServiceProvider);
|
||||
|
||||
final sliderValue = useState(0.0);
|
||||
final totalProgressValue =
|
||||
useState(AppSettingsEnum.backgroundBackupTotalProgress.defaultValue);
|
||||
final singleProgressValue =
|
||||
useState(AppSettingsEnum.backgroundBackupSingleProgress.defaultValue);
|
||||
|
||||
useEffect(
|
||||
() {
|
||||
sliderValue.value = appSettingService
|
||||
.getSetting<int>(AppSettingsEnum.uploadErrorNotificationGracePeriod)
|
||||
.toDouble();
|
||||
totalProgressValue.value = appSettingService
|
||||
.getSetting<bool>(AppSettingsEnum.backgroundBackupTotalProgress);
|
||||
singleProgressValue.value = appSettingService
|
||||
.getSetting<bool>(AppSettingsEnum.backgroundBackupSingleProgress);
|
||||
return null;
|
||||
},
|
||||
[],
|
||||
@@ -42,6 +50,22 @@ class NotificationSetting extends HookConsumerWidget {
|
||||
),
|
||||
).tr(),
|
||||
children: [
|
||||
_buildSwitchListTile(
|
||||
context,
|
||||
appSettingService,
|
||||
totalProgressValue,
|
||||
AppSettingsEnum.backgroundBackupTotalProgress,
|
||||
title: 'setting_notifications_total_progress_title'.tr(),
|
||||
subtitle: 'setting_notifications_total_progress_subtitle'.tr(),
|
||||
),
|
||||
_buildSwitchListTile(
|
||||
context,
|
||||
appSettingService,
|
||||
singleProgressValue,
|
||||
AppSettingsEnum.backgroundBackupSingleProgress,
|
||||
title: 'setting_notifications_single_progress_title'.tr(),
|
||||
subtitle: 'setting_notifications_single_progress_subtitle'.tr(),
|
||||
),
|
||||
ListTile(
|
||||
isThreeLine: false,
|
||||
dense: true,
|
||||
@@ -53,7 +77,9 @@ class NotificationSetting extends HookConsumerWidget {
|
||||
value: sliderValue.value,
|
||||
onChanged: (double v) => sliderValue.value = v,
|
||||
onChangeEnd: (double v) => appSettingService.setSetting(
|
||||
AppSettingsEnum.uploadErrorNotificationGracePeriod, v.toInt()),
|
||||
AppSettingsEnum.uploadErrorNotificationGracePeriod,
|
||||
v.toInt(),
|
||||
),
|
||||
max: 5.0,
|
||||
divisions: 5,
|
||||
label: formattedValue,
|
||||
@@ -65,6 +91,28 @@ class NotificationSetting extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
SwitchListTile _buildSwitchListTile(
|
||||
BuildContext context,
|
||||
AppSettingsService appSettingService,
|
||||
ValueNotifier<bool> valueNotifier,
|
||||
AppSettingsEnum settingsEnum, {
|
||||
required String title,
|
||||
String? subtitle,
|
||||
}) {
|
||||
return SwitchListTile(
|
||||
key: Key(settingsEnum.name),
|
||||
value: valueNotifier.value,
|
||||
onChanged: (value) {
|
||||
valueNotifier.value = value;
|
||||
appSettingService.setSetting(settingsEnum, value);
|
||||
},
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
dense: true,
|
||||
title: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: subtitle != null ? Text(subtitle) : null,
|
||||
);
|
||||
}
|
||||
|
||||
String _formatSliderValue(double v) {
|
||||
if (v == 0.0) {
|
||||
return 'setting_notifications_notify_immediately'.tr();
|
||||
|
||||
Reference in New Issue
Block a user