Przeglądaj źródła

Use fresh suggestion for both bolus calculators. Fresh as in updated every relevant oref variable, like COB, IOB etc.

Jon Mårtensson 2 lat temu
rodzic
commit
5dec48dadb

+ 0 - 4
FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift

@@ -235,10 +235,6 @@ extension Bolus {
                     .roundBolus(amount: max(self.insulinRecommended, 0))
 
                 self.getDeltaBG()
-
-                if self.useCalc {
-                    self.apsManager.determineBasalSync()
-                }
             }
         }
     }

+ 34 - 26
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -100,36 +100,44 @@ extension Bolus {
                 header: { Text("Values") }
 
                 Section {
-                    HStack {
-                        Text("Recommended Bolus")
-                        Spacer()
-
-                        Text(
-                            formatter
-                                .string(from: Double(insulinCalculated) as NSNumber)!
-                        )
-                        let unit = NSLocalizedString(
-                            " U",
-                            comment: "Unit in number of units delivered (keep the space character!)"
-                        )
-                        Text(unit).foregroundColor(.secondary)
-                    }.contentShape(Rectangle())
-                        .onTapGesture {
-                            state.amount = insulinCalculated
+                    if state.waitForSuggestion {
+                        HStack {
+                            Text("Wait please").foregroundColor(.secondary)
+                            Spacer()
+                            ActivityIndicator(isAnimating: .constant(true), style: .medium) // fix iOS 15 bug
                         }
-
-                    if !state.waitForSuggestion {
+                    } else {
                         HStack {
-                            Text("Bolus")
+                            Text("Recommended Bolus")
                             Spacer()
-                            DecimalTextField(
-                                "0",
-                                value: $state.amount,
-                                formatter: formatter,
-                                autofocus: false,
-                                cleanInput: true
+
+                            Text(
+                                formatter
+                                    .string(from: Double(insulinCalculated) as NSNumber)!
+                            )
+                            let unit = NSLocalizedString(
+                                " U",
+                                comment: "Unit in number of units delivered (keep the space character!)"
                             )
-                            Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
+                            Text(unit).foregroundColor(.secondary)
+                        }.contentShape(Rectangle())
+                            .onTapGesture {
+                                state.amount = insulinCalculated
+                            }
+
+                        if !state.waitForSuggestion {
+                            HStack {
+                                Text("Bolus")
+                                Spacer()
+                                DecimalTextField(
+                                    "0",
+                                    value: $state.amount,
+                                    formatter: formatter,
+                                    autofocus: false,
+                                    cleanInput: true
+                                )
+                                Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
+                            }
                         }
                     }
                 }

+ 4 - 1
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -511,7 +511,10 @@ extension Home {
                     .foregroundColor(.loopGreen)
                     .buttonStyle(.borderless)
                     Spacer()
-                    Button { state.showModal(for: .bolus(waitForSuggestion: false)) }
+                    Button {
+                        state.showModal(for: .bolus(waitForSuggestion: true))
+                        state.apsManager.determineBasalSync()
+                    }
                     label: {
                         Image("bolus")
                             .renderingMode(.template)