2024-12-11 16:30:56 +00:00
|
|
|
import 'package:immich_mobile/constants/colors.dart';
|
2024-05-01 02:36:40 +00:00
|
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
2022-08-13 20:51:09 +00:00
|
|
|
|
2022-08-20 21:19:40 +00:00
|
|
|
enum AppSettingsEnum<T> {
|
2023-03-23 01:36:44 +00:00
|
|
|
loadPreview<bool>(StoreKey.loadPreview, "loadPreview", true),
|
|
|
|
loadOriginal<bool>(StoreKey.loadOriginal, "loadOriginal", false),
|
|
|
|
themeMode<String>(
|
|
|
|
StoreKey.themeMode,
|
|
|
|
"themeMode",
|
|
|
|
"system",
|
|
|
|
), // "light","dark","system"
|
2024-08-06 14:20:27 +00:00
|
|
|
primaryColor<String>(
|
|
|
|
StoreKey.primaryColor,
|
|
|
|
"primaryColor",
|
|
|
|
defaultColorPresetName,
|
|
|
|
),
|
|
|
|
dynamicTheme<bool>(
|
|
|
|
StoreKey.dynamicTheme,
|
|
|
|
"dynamicTheme",
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
colorfulInterface<bool>(
|
|
|
|
StoreKey.colorfulInterface,
|
|
|
|
"colorfulInterface",
|
|
|
|
true,
|
|
|
|
),
|
2023-03-23 01:36:44 +00:00
|
|
|
tilesPerRow<int>(StoreKey.tilesPerRow, "tilesPerRow", 4),
|
|
|
|
dynamicLayout<bool>(StoreKey.dynamicLayout, "dynamicLayout", false),
|
|
|
|
groupAssetsBy<int>(StoreKey.groupAssetsBy, "groupBy", 0),
|
2022-08-21 16:29:24 +00:00
|
|
|
uploadErrorNotificationGracePeriod<int>(
|
2023-03-23 01:36:44 +00:00
|
|
|
StoreKey.uploadErrorNotificationGracePeriod,
|
2022-10-05 14:59:35 +00:00
|
|
|
"uploadErrorNotificationGracePeriod",
|
|
|
|
2,
|
|
|
|
),
|
2023-03-23 01:36:44 +00: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 13:50:46 +00:00
|
|
|
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
|
2023-07-01 01:47:44 +00:00
|
|
|
logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
|
|
|
|
preferRemoteImage<bool>(StoreKey.preferRemoteImage, null, false),
|
2024-05-14 19:31:47 +00:00
|
|
|
loopVideo<bool>(StoreKey.loopVideo, "loopVideo", true),
|
2024-01-15 15:26:13 +00:00
|
|
|
mapThemeMode<int>(StoreKey.mapThemeMode, null, 0),
|
2023-08-27 05:07:35 +00:00
|
|
|
mapShowFavoriteOnly<bool>(StoreKey.mapShowFavoriteOnly, null, false),
|
2023-10-04 13:51:07 +00:00
|
|
|
mapIncludeArchived<bool>(StoreKey.mapIncludeArchived, null, false),
|
2024-04-06 14:04:40 +00:00
|
|
|
mapwithPartners<bool>(StoreKey.mapwithPartners, null, false),
|
2023-08-27 05:07:35 +00:00
|
|
|
mapRelativeDate<int>(StoreKey.mapRelativeDate, null, 0),
|
2023-09-12 14:51:43 +00:00
|
|
|
allowSelfSignedSSLCert<bool>(StoreKey.selfSignedCert, null, false),
|
2023-12-07 15:53:15 +00:00
|
|
|
ignoreIcloudAssets<bool>(StoreKey.ignoreIcloudAssets, null, false),
|
2023-12-07 18:14:09 +00:00
|
|
|
selectedAlbumSortReverse<bool>(
|
|
|
|
StoreKey.selectedAlbumSortReverse,
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
),
|
2024-04-15 05:50:47 +00:00
|
|
|
enableHapticFeedback<bool>(StoreKey.enableHapticFeedback, null, true),
|
2024-08-26 18:21:19 +00:00
|
|
|
syncAlbums<bool>(StoreKey.syncAlbums, null, false),
|
2024-12-05 15:11:48 +00:00
|
|
|
autoEndpointSwitching<bool>(StoreKey.autoEndpointSwitching, null, false),
|
2023-03-23 01:36:44 +00:00
|
|
|
;
|
2022-08-20 21:19:40 +00:00
|
|
|
|
2023-03-23 01:36:44 +00:00
|
|
|
const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
|
2022-08-20 21:19:40 +00:00
|
|
|
|
2023-03-23 01:36:44 +00:00
|
|
|
final StoreKey<T> storeKey;
|
2023-04-14 13:50:46 +00:00
|
|
|
final String? hiveKey;
|
2022-08-20 21:19:40 +00:00
|
|
|
final T defaultValue;
|
2022-08-13 20:51:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class AppSettingsService {
|
2023-03-23 01:36:44 +00:00
|
|
|
T getSetting<T>(AppSettingsEnum<T> setting) {
|
|
|
|
return Store.get(setting.storeKey, setting.defaultValue);
|
2022-08-13 20:51:09 +00:00
|
|
|
}
|
|
|
|
|
2023-03-23 01:36:44 +00:00
|
|
|
void setSetting<T>(AppSettingsEnum<T> setting, T value) {
|
|
|
|
Store.put(setting.storeKey, value);
|
2022-08-13 20:51:09 +00:00
|
|
|
}
|
|
|
|
}
|