Commit 8312250
Changed files (1)
app
lib
model
storage
app/lib/model/storage/settings_store.dart
@@ -44,6 +44,7 @@ class Settings extends ChangeNotifier {
bool? bottomAppBars,
List<Medicine>? medications,
int? highestMedIndex,
+ PressureUnit? preferredPressureUnit,
}) {
if (accentColor != null) _accentColor = accentColor;
if (sysColor != null) _sysColor = sysColor;
@@ -68,6 +69,7 @@ class Settings extends ChangeNotifier {
if (bottomAppBars != null) _bottomAppBars = bottomAppBars;
if (medications != null) _medications.addAll(medications);
if (highestMedIndex != null) _highestMedIndex = highestMedIndex;
+ if (preferredPressureUnit != null) _preferredPressureUnit = preferredPressureUnit;
_language = language; // No check here, as null is the default as well.
}
@@ -100,6 +102,7 @@ class Settings extends ChangeNotifier {
medications: ConvertUtil.parseList<String>(map['medications'])?.map((e) =>
Medicine.fromJson(jsonDecode(e)),).toList(),
highestMedIndex: ConvertUtil.parseInt(map['highestMedIndex']),
+ preferredPressureUnit: PressureUnit.decode(ConvertUtil.parseInt(map['preferredPressureUnit'])),
);
// update
@@ -144,6 +147,7 @@ class Settings extends ChangeNotifier {
'bottomAppBars': bottomAppBars,
'medications': medications.map(jsonEncode).toList(),
'highestMedIndex': highestMedIndex,
+ 'preferredPressureUnit': preferredPressureUnit,
};
/// Serialize the object to a restoreable string.
@@ -340,6 +344,14 @@ class Settings extends ChangeNotifier {
_bottomAppBars = value;
notifyListeners();
}
+
+ PressureUnit _preferredPressureUnit = PressureUnit.mmHg;
+ /// Preferred unit to display and enter measurements in.
+ PressureUnit get preferredPressureUnit => _preferredPressureUnit;
+ set preferredPressureUnit(PressureUnit value) {
+ _preferredPressureUnit = value;
+ notifyListeners();
+ }
final List<Medicine> _medications = [];
/// All medications ever added.