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,
|
|
|
|
),
|
2023-04-14 15:50:46 +02:00
|
|
|
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
|
2023-07-01 03:47:44 +02:00
|
|
|
logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
|
|
|
|
preferRemoteImage<bool>(StoreKey.preferRemoteImage, null, false),
|
2023-08-27 07:07:35 +02:00
|
|
|
mapThemeMode<bool>(StoreKey.mapThemeMode, null, false),
|
|
|
|
mapShowFavoriteOnly<bool>(StoreKey.mapShowFavoriteOnly, null, false),
|
|
|
|
mapRelativeDate<int>(StoreKey.mapRelativeDate, null, 0),
|
2023-03-23 03:36:44 +02:00
|
|
|
;
|
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;
|
2023-04-14 15:50:46 +02:00
|
|
|
final String? hiveKey;
|
2022-08-20 23:19:40 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|