Explorar o código

Merge pull request #418 from nightscout/max-iob-warning

Display MaxIOB 0 warning in home view
marv-out hai 1 ano
pai
achega
d00a058a24

+ 3 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -116026,6 +116026,9 @@
         }
         }
       }
       }
     },
     },
+    "MaxIOB: 0 U" : {
+
+    },
     "Meal" : {
     "Meal" : {
       "comment" : "Debug option view Meal",
       "comment" : "Debug option view Meal",
       "extractionState" : "manual",
       "extractionState" : "manual",

+ 1 - 2
Trio/Sources/Modules/CGMSettings/View/CGMRootView.swift

@@ -106,8 +106,7 @@ extension CGMSettings {
                         type: .boolean,
                         type: .boolean,
                         label: String(localized: "Smooth Glucose Value"),
                         label: String(localized: "Smooth Glucose Value"),
                         miniHint: String(localized: "Smooth CGM readings using Savitzky-Golay filtering."),
                         miniHint: String(localized: "Smooth CGM readings using Savitzky-Golay filtering."),
-                        verboseHint:
-                        VStack(alignment: .leading, spacing: 10) {
+                        verboseHint: VStack(alignment: .leading, spacing: 10) {
                             Text("Default: OFF").bold()
                             Text("Default: OFF").bold()
                             Text(
                             Text(
                                 "This filter looks at small groups of nearby readings and fits them to a simple mathematical curve. This process doesn't change the overall pattern of your glucose data but helps smooth out the \"noise\" or irregular fluctuations that could lead to false highs or lows."
                                 "This filter looks at small groups of nearby readings and fits them to a simple mathematical curve. This process doesn't change the overall pattern of your glucose data but helps smooth out the \"noise\" or irregular fluctuations that could lead to false highs or lows."

+ 3 - 0
Trio/Sources/Modules/Home/HomeStateModel.swift

@@ -63,6 +63,7 @@ extension Home {
         var alarm: GlucoseAlarm?
         var alarm: GlucoseAlarm?
         var manualTempBasal = false
         var manualTempBasal = false
         var isSmoothingEnabled = false
         var isSmoothingEnabled = false
+        var maxIOB: Decimal = 0.0
         var autosensMax: Decimal = 1.2
         var autosensMax: Decimal = 1.2
         var lowGlucose: Decimal = 70
         var lowGlucose: Decimal = 70
         var highGlucose: Decimal = 180
         var highGlucose: Decimal = 180
@@ -395,6 +396,7 @@ extension Home {
             highTTraisesSens = settingsManager.preferences.highTemptargetRaisesSensitivity
             highTTraisesSens = settingsManager.preferences.highTemptargetRaisesSensitivity
             lowTTlowersSens = settingsManager.preferences.lowTemptargetLowersSensitivity
             lowTTlowersSens = settingsManager.preferences.lowTemptargetLowersSensitivity
             settingHalfBasalTarget = settingsManager.preferences.halfBasalExerciseTarget
             settingHalfBasalTarget = settingsManager.preferences.halfBasalExerciseTarget
+            maxIOB = settingsManager.preferences.maxIOB
         }
         }
 
 
         @MainActor private func setupCGMSettings() async {
         @MainActor private func setupCGMSettings() async {
@@ -670,6 +672,7 @@ extension Home.StateModel:
         highTTraisesSens = settingsManager.preferences.highTemptargetRaisesSensitivity
         highTTraisesSens = settingsManager.preferences.highTemptargetRaisesSensitivity
         isExerciseModeActive = settingsManager.preferences.exerciseMode
         isExerciseModeActive = settingsManager.preferences.exerciseMode
         lowTTlowersSens = settingsManager.preferences.lowTemptargetLowersSensitivity
         lowTTlowersSens = settingsManager.preferences.lowTemptargetLowersSensitivity
+        maxIOB = settingsManager.preferences.maxIOB
     }
     }
 
 
     func pumpSettingsDidChange(_: PumpSettings) {
     func pumpSettingsDidChange(_: PumpSettings) {

+ 32 - 23
Trio/Sources/Modules/Home/View/HomeRootView.swift

@@ -460,32 +460,41 @@ extension Home {
 
 
                 Spacer()
                 Spacer()
 
 
-                HStack {
-                    if state.pumpSuspended {
-                        Text("Pump suspended")
-                            .font(.callout).fontWeight(.bold).fontDesign(.rounded)
-                            .foregroundColor(.loopGray)
-                    } else if let tempBasalString = tempBasalString {
-                        Image(systemName: "drop.circle")
-                            .font(.callout)
-                            .foregroundColor(.insulinTintColor)
-                        if tempBasalString.count > 5 {
-                            Text(tempBasalString)
+                if state.maxIOB == 0.0 {
+                    HStack {
+                        Image(systemName: "exclamationmark.circle.fill")
+                        Text("MaxIOB: 0 U")
+                    }.bold()
+                        .foregroundStyle(Color.red)
+                        .font(.callout)
+                } else {
+                    HStack {
+                        if state.pumpSuspended {
+                            Text("Pump suspended")
                                 .font(.callout).fontWeight(.bold).fontDesign(.rounded)
                                 .font(.callout).fontWeight(.bold).fontDesign(.rounded)
-                                .lineLimit(1)
-                                .minimumScaleFactor(0.85)
-                                .truncationMode(.tail)
-                                .allowsTightening(true)
+                                .foregroundColor(.loopGray)
+                        } else if let tempBasalString = tempBasalString {
+                            Image(systemName: "drop.circle")
+                                .font(.callout)
+                                .foregroundColor(.insulinTintColor)
+                            if tempBasalString.count > 5 {
+                                Text(tempBasalString)
+                                    .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                                    .lineLimit(1)
+                                    .minimumScaleFactor(0.85)
+                                    .truncationMode(.tail)
+                                    .allowsTightening(true)
+                            } else {
+                                // Short strings can just display normally
+                                Text(tempBasalString).font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                            }
                         } else {
                         } else {
-                            // Short strings can just display normally
-                            Text(tempBasalString).font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                            Image(systemName: "drop.circle")
+                                .font(.callout)
+                                .foregroundColor(.insulinTintColor)
+                            Text("No Data")
+                                .font(.callout).fontWeight(.bold).fontDesign(.rounded)
                         }
                         }
-                    } else {
-                        Image(systemName: "drop.circle")
-                            .font(.callout)
-                            .foregroundColor(.insulinTintColor)
-                        Text("No Data")
-                            .font(.callout).fontWeight(.bold).fontDesign(.rounded)
                     }
                     }
                 }
                 }
             }.padding(.horizontal)
             }.padding(.horizontal)