mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
save stop type to sharedPrefs
This commit is contained in:
parent
0c58134733
commit
80fe288bd0
2 changed files with 17 additions and 7 deletions
|
@ -14,6 +14,7 @@ class UserPreferencesService {
|
||||||
static const ndFilterKey = "ndFilter";
|
static const ndFilterKey = "ndFilter";
|
||||||
|
|
||||||
static const evSourceTypeKey = "evSourceType";
|
static const evSourceTypeKey = "evSourceType";
|
||||||
|
static const stopTypeKey = "stopType";
|
||||||
static const cameraEvCalibrationKey = "cameraEvCalibration";
|
static const cameraEvCalibrationKey = "cameraEvCalibration";
|
||||||
static const lightSensorEvCalibrationKey = "lightSensorEvCalibration";
|
static const lightSensorEvCalibrationKey = "lightSensorEvCalibration";
|
||||||
static const meteringScreenLayoutKey = "meteringScreenLayout";
|
static const meteringScreenLayoutKey = "meteringScreenLayout";
|
||||||
|
@ -84,6 +85,9 @@ class UserPreferencesService {
|
||||||
bool get caffeine => _sharedPreferences.getBool(caffeineKey) ?? false;
|
bool get caffeine => _sharedPreferences.getBool(caffeineKey) ?? false;
|
||||||
set caffeine(bool value) => _sharedPreferences.setBool(caffeineKey, value);
|
set caffeine(bool value) => _sharedPreferences.setBool(caffeineKey, value);
|
||||||
|
|
||||||
|
StopType get stopType => StopType.values[_sharedPreferences.getInt(stopTypeKey) ?? 2];
|
||||||
|
set stopType(StopType value) => _sharedPreferences.setInt(stopTypeKey, value.index);
|
||||||
|
|
||||||
MeteringScreenLayoutConfig get meteringScreenLayout {
|
MeteringScreenLayoutConfig get meteringScreenLayout {
|
||||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
|
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
|
||||||
if (configJson != null) {
|
if (configJson != null) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||||
import 'package:lightmeter/utils/inherited_generics.dart';
|
import 'package:lightmeter/utils/inherited_generics.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
@ -16,14 +17,12 @@ class StopTypeProvider extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class StopTypeProviderState extends State<StopTypeProvider> {
|
class StopTypeProviderState extends State<StopTypeProvider> {
|
||||||
StopType _stopType = StopType.third;
|
late StopType _stopType;
|
||||||
|
|
||||||
StopType get stopType => _stopType;
|
@override
|
||||||
|
void initState() {
|
||||||
void set(StopType type) {
|
super.initState();
|
||||||
setState(() {
|
_stopType = context.get<UserPreferencesService>().stopType;
|
||||||
_stopType = type;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -33,4 +32,11 @@ class StopTypeProviderState extends State<StopTypeProvider> {
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set(StopType type) {
|
||||||
|
setState(() {
|
||||||
|
_stopType = type;
|
||||||
|
});
|
||||||
|
context.get<UserPreferencesService>().stopType = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue