Parcourir la source

Display Eventual BG

Jon Mårtensson il y a 2 ans
Parent
commit
7c19bd9c26

+ 10 - 10
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -57,15 +57,15 @@ extension Bolus {
 
         var body: some View {
             Form {
-                if state.displayPredictions {
-                    Section {
-                        if state.waitForSuggestion {
-                            Text("Please wait")
-                        } else {
-                            predictionChart
-                        }
-                    } header: { Text("Predictions") }
-                }
+                
+                Section {
+                    if state.waitForSuggestion {
+                        Text("Please wait")
+                    } else {
+                        predictionChart
+                    }
+                } header: { Text("Predictions") }
+                
 
                 Section {}
                 if fetch {
@@ -203,7 +203,7 @@ extension Bolus {
         var predictionChart: some View {
             ZStack {
                 PredictionView(
-                    predictions: $state.predictions, units: $state.units, eventualBG: $state.evBG, target: $state.target
+                    predictions: $state.predictions, units: $state.units, eventualBG: $state.evBG, target: $state.target, displayPredictions: $state.displayPredictions
                 )
             }
         }

+ 9 - 10
FreeAPS/Sources/Modules/Bolus/View/DefaultBolusCalcRootView.swift

@@ -37,15 +37,13 @@ extension Bolus {
 
         var body: some View {
             Form {
-                if state.displayPredictions {
-                    Section {
-                        if state.waitForSuggestion {
-                            Text("Please wait")
-                        } else {
-                            predictionChart
-                        }
-                    } header: { Text("Predictions") }
-                }
+                Section {
+                    if state.waitForSuggestion {
+                        Text("Please wait")
+                    } else {
+                        predictionChart
+                    }
+                } header: { Text("Predictions") }
 
                 if fetch {
                     Section {
@@ -178,7 +176,8 @@ extension Bolus {
         var predictionChart: some View {
             ZStack {
                 PredictionView(
-                    predictions: $state.predictions, units: $state.units, eventualBG: $state.evBG, target: $state.target
+                    predictions: $state.predictions, units: $state.units, eventualBG: $state.evBG, target: $state.target,
+                    displayPredictions: $state.displayPredictions
                 )
             }
         }

+ 4 - 1
FreeAPS/Sources/Modules/Bolus/View/Predictions.swift

@@ -8,6 +8,7 @@ struct PredictionView: View {
     @Binding var units: GlucoseUnits
     @Binding var eventualBG: Int
     @Binding var target: Decimal
+    @Binding var displayPredictions: Bool
 
     private enum Config {
         static let height: CGFloat = 160
@@ -16,7 +17,9 @@ struct PredictionView: View {
 
     var body: some View {
         VStack {
-            chart()
+            if displayPredictions {
+                chart()
+            }
             HStack {
                 let conversion = units == .mmolL ? 0.0555 : 1
                 Text("Eventual Glucose")