2023-03-23 03:36:44 +02:00
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
2022-08-13 22:51:09 +02:00
|
|
|
|
2022-08-20 23:19:40 +02:00
|
|
|
enum AppSettingsEnum<T> {
|
2023-03-23 03:36:44 +02:00
|
|
|
loadPreview<bool>(StoreKey.loadPreview, "loadPreview", true),
|
|
|
|
loadOriginal<bool>(StoreKey.loadOriginal, "loadOriginal", false),
|
|
|
|
themeMode<String>(
|
|
|
|
StoreKey.themeMode,
|
|
|
|
"themeMode",
|
|
|
|
"system",
|
|
|
|
), // "light","dark","system"
|
|
|
|
tilesPerRow<int>(StoreKey.tilesPerRow, "tilesPerRow", 4),
|
|
|
|
dynamicLayout<bool>(StoreKey.dynamicLayout, "dynamicLayout", false),
|
|
|
|
groupAssetsBy<int>(StoreKey.groupAssetsBy, "groupBy", 0),
|
2022-08-21 18:29:24 +02:00
|
|
|
uploadErrorNotificationGracePeriod<int>(
|
2023-03-23 03:36:44 +02:00
|
|
|
StoreKey.uploadErrorNotificationGracePeriod,
|
2022-10-05 16:59:35 +02:00
|
|
|
"uploadErrorNotificationGracePeriod",
|
|
|
|
2,
|
|
|
|
),
|
2023-03-23 03:36:44 +02:00
|
|
|
backgroundBackupTotalProgress<bool>(
|
|
|
|
StoreKey.backgroundBackupTotalProgress,
|
|
|
|
"backgroundBackupTotalProgress",
|
|
|
|
true,
|
|
|
|
),
|
|
|
|
backgroundBackupSingleProgress<bool>(
|
|
|
|
StoreKey.backgroundBackupSingleProgress,
|
|
|
|
"backgroundBackupSingleProgress",
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
storageIndicator<bool>(StoreKey.storageIndicator, "storageIndicator", true),
|
|
|
|
thumbnailCacheSize<int>(
|
|
|
|
StoreKey.thumbnailCacheSize,
|
|
|
|
"thumbnailCacheSize",
|
|
|
|
10000,
|
|
|
|
),
|
|
|
|
imageCacheSize<int>(StoreKey.imageCacheSize, "imageCacheSize", 350),
|
|
|
|
albumThumbnailCacheSize<int>(
|
|
|
|
StoreKey.albumThumbnailCacheSize,
|
|
|
|
"albumThumbnailCacheSize",
|
|
|
|
200,
|
|
|
|
),
|
|
|
|
selectedAlbumSortOrder<int>(
|
|
|
|
StoreKey.selectedAlbumSortOrder,
|
|
|
|
"selectedAlbumSortOrder",
|
|
|
|
0,
|
|
|
|
),
|
|
|
|
;
|
2022-08-20 23:19:40 +02:00
|
|
|
|
2023-03-23 03:36:44 +02:00
|
|
|
const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
|
2022-08-20 23:19:40 +02:00
|
|
|
|
2023-03-23 03:36:44 +02:00
|
|
|
final StoreKey<T> storeKey;
|
2022-08-20 23:19:40 +02:00
|
|
|
final String hiveKey;
|
|
|
|
final T defaultValue;
|
2022-08-13 22:51:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class AppSettingsService {
|
2023-03-23 03:36:44 +02:00
|
|
|
T getSetting<T>(AppSettingsEnum<T> setting) {
|
|
|
|
return Store.get(setting.storeKey, setting.defaultValue);
|
2022-08-13 22:51:09 +02:00
|
|
|
}
|
|
|
|
|
2023-03-23 03:36:44 +02:00
|
|
|
void setSetting<T>(AppSettingsEnum<T> setting, T value) {
|
|
|
|
Store.put(setting.storeKey, value);
|
2022-08-13 22:51:09 +02:00
|
|
|
}
|
|
|
|
}
|