Commit 861b9a2

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2023-11-08 13:58:38
add needlePinBarWidth setting
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent 1f19cc8
Changed files (3)
lib/components/measurement_graph.dart
@@ -159,7 +159,7 @@ class _LineChartState extends State<_LineChart> {
           FlSpot(r.creationTime.millisecondsSinceEpoch.toDouble(), max + 5)
         ],
         barWidth: 20,
-        dotData: FlDotData(show: false),
+        dotData: const FlDotData(show: false),
         color: r.needlePin!.color.withAlpha(100),
       ));
     }
lib/model/storage/settings_store.dart
@@ -22,6 +22,7 @@ class Settings extends ChangeNotifier {
     List<HorizontalGraphLine>? horizontalGraphLines,
     String? dateFormatString,
     double? graphLineThickness,
+    double? needlePinBarWidth,
     int? animationSpeed,
     int? sysWarn,
     int? diaWarn,
@@ -46,6 +47,7 @@ class Settings extends ChangeNotifier {
     if (sysWarn != null) _sysWarn = sysWarn;
     if (diaWarn != null) _diaWarn = diaWarn;
     if (graphLineThickness != null) _graphLineThickness = graphLineThickness;
+    if (needlePinBarWidth != null) _needlePinBarWidth = needlePinBarWidth;
     if (validateInputs != null) _validateInputs = validateInputs;
     if (allowMissingValues != null) _allowMissingValues = allowMissingValues;
     if (drawRegressionLines != null) _drawRegressionLines = drawRegressionLines;
@@ -77,6 +79,7 @@ class Settings extends ChangeNotifier {
       language: ConvertUtil.parseLocale(map['language']),
       horizontalGraphLines: ConvertUtil.parseList<String>(map['horizontalGraphLines'])?.map((e) =>
           HorizontalGraphLine.fromJson(jsonDecode(e))).toList(),
+      needlePinBarWidth: ConvertUtil.parseDouble(map['needlePinBarWidth'])
     );
 
     // update
@@ -113,7 +116,8 @@ class Settings extends ChangeNotifier {
       'startWithAddMeasurementPage': startWithAddMeasurementPage,
       'useLegacyList': useLegacyList,
       'language': ConvertUtil.serializeLocale(language),
-      'horizontalGraphLines': horizontalGraphLines.map((e) => jsonEncode(e)).toList()
+      'horizontalGraphLines': horizontalGraphLines.map((e) => jsonEncode(e)).toList(),
+      'needlePinBarWidth': _needlePinBarWidth
     };
 
   String toJson() => jsonEncode(toMap());
@@ -254,6 +258,13 @@ class Settings extends ChangeNotifier {
     _useLegacyList = value;
     notifyListeners();
   }
+
+  double _needlePinBarWidth = 5;
+  double get needlePinBarWidth => _needlePinBarWidth;
+  set needlePinBarWidth(double value) {
+    _needlePinBarWidth = value;
+    notifyListeners();
+  }
   
 // When adding fields notice the checklist at the top.
 }
test/model/json_serialization_test.dart
@@ -74,6 +74,7 @@ void main() {
         sysColor: Colors.deepOrange,
         diaColor: Colors.deepOrange,
         pulColor: Colors.deepOrange,
+        needlePinBarWidth: 123.456789,
         dateFormatString: 'Lorem Ipsum',
         graphLineThickness: 134.23123,
         animationSpeed: 78,
@@ -112,6 +113,7 @@ void main() {
       expect(initial.horizontalGraphLines.length, fromJson.horizontalGraphLines.length);
       expect(initial.horizontalGraphLines.first.color.value, fromJson.horizontalGraphLines.first.color.value);
       expect(initial.horizontalGraphLines.first.height, fromJson.horizontalGraphLines.first.height);
+      expect(initial.needlePinBarWidth, fromJson.needlePinBarWidth);
 
       expect(initial.toJson(), fromJson.toJson());
     });