2025-02-20 00:57:32 +05:30
|
|
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
2024-04-30 21:36:40 -05:00
|
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
2022-08-13 15:51:09 -05:00
|
|
|
|
2022-08-20 23:19:40 +02:00
|
|
|
enum AppSettingsEnum<T> {
|
2023-04-14 15:50:46 +02:00
|
|
|
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
|
2025-04-25 05:39:50 +05:30
|
|
|
manageLocalMediaAndroid<bool>(StoreKey.manageLocalMediaAndroid, null, false),
|
2024-04-15 07:50:47 +02:00
|
|
|
enableHapticFeedback<bool>(StoreKey.enableHapticFeedback, null, true),
|
2026-05-19 00:40:10 +05:30
|
|
|
readonlyModeEnabled<bool>(StoreKey.readonlyModeEnabled, "readonlyModeEnabled", false);
|
2022-08-20 23:19:40 +02:00
|
|
|
|
2023-03-23 02:36:44 +01:00
|
|
|
const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
|
2022-08-20 23:19:40 +02:00
|
|
|
|
2023-03-23 02:36:44 +01: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 15:51:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AppSettingsService {
|
2025-06-25 13:06:24 +05:30
|
|
|
const AppSettingsService();
|
2023-03-23 02:36:44 +01:00
|
|
|
T getSetting<T>(AppSettingsEnum<T> setting) {
|
|
|
|
|
return Store.get(setting.storeKey, setting.defaultValue);
|
2022-08-13 15:51:09 -05:00
|
|
|
}
|
|
|
|
|
|
2025-06-02 07:23:45 +05:30
|
|
|
Future<void> setSetting<T>(AppSettingsEnum<T> setting, T value) {
|
|
|
|
|
return Store.put(setting.storeKey, value);
|
2022-08-13 15:51:09 -05:00
|
|
|
}
|
|
|
|
|
}
|