2022-12-16 08:08:12 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
2022-12-18 09:03:41 +00:00
|
|
|
import 'models/photography_values/iso_value.dart';
|
|
|
|
import 'models/photography_values/nd_value.dart';
|
|
|
|
import 'models/theme_type.dart';
|
2022-12-16 08:08:12 +00:00
|
|
|
|
|
|
|
class UserPreferencesService {
|
2023-01-21 10:37:49 +00:00
|
|
|
static const _isoKey = "iso";
|
|
|
|
static const _ndFilterKey = "nd";
|
2022-12-16 08:08:12 +00:00
|
|
|
|
2023-01-25 18:58:29 +00:00
|
|
|
static const _cameraEvCalibrationKey = "cameraEvCalibration";
|
|
|
|
|
2023-01-21 10:37:49 +00:00
|
|
|
static const _hapticsKey = "haptics";
|
|
|
|
static const _themeTypeKey = "themeType";
|
2023-01-25 10:08:11 +00:00
|
|
|
static const _dynamicColorKey = "dynamicColor";
|
2022-12-16 20:07:05 +00:00
|
|
|
|
2022-12-16 08:08:12 +00:00
|
|
|
final SharedPreferences _sharedPreferences;
|
|
|
|
|
|
|
|
UserPreferencesService(this._sharedPreferences);
|
|
|
|
|
|
|
|
IsoValue get iso => isoValues.firstWhere((v) => v.value == (_sharedPreferences.getInt(_isoKey) ?? 100));
|
|
|
|
set iso(IsoValue value) => _sharedPreferences.setInt(_isoKey, value.value);
|
|
|
|
|
|
|
|
NdValue get ndFilter => ndValues.firstWhere((v) => v.value == (_sharedPreferences.getInt(_ndFilterKey) ?? 0));
|
|
|
|
set ndFilter(NdValue value) => _sharedPreferences.setInt(_ndFilterKey, value.value);
|
2022-12-16 20:07:05 +00:00
|
|
|
|
2023-01-21 10:37:49 +00:00
|
|
|
bool get haptics => _sharedPreferences.getBool(_hapticsKey) ?? false;
|
|
|
|
set haptics(bool value) => _sharedPreferences.setBool(_hapticsKey, value);
|
|
|
|
|
2023-01-25 18:58:29 +00:00
|
|
|
double get cameraEvCalibration => _sharedPreferences.getDouble(_cameraEvCalibrationKey) ?? 0.0;
|
|
|
|
set cameraEvCalibration(double value) => _sharedPreferences.setDouble(_cameraEvCalibrationKey, value);
|
|
|
|
|
2022-12-16 20:07:05 +00:00
|
|
|
ThemeType get themeType => ThemeType.values[_sharedPreferences.getInt(_themeTypeKey) ?? 0];
|
|
|
|
set themeType(ThemeType value) => _sharedPreferences.setInt(_themeTypeKey, value.index);
|
2023-01-22 19:30:29 +00:00
|
|
|
|
2023-01-25 10:08:11 +00:00
|
|
|
bool get dynamicColor => _sharedPreferences.getBool(_dynamicColorKey) ?? false;
|
|
|
|
set dynamicColor(bool value) => _sharedPreferences.setBool(_dynamicColorKey, value);
|
2022-12-16 08:08:12 +00:00
|
|
|
}
|