Procházet zdrojové kódy

Merge pull request #100 from MikePlante1/max_bolus

Utilize max bolus limit in Bolus module
bjornoleh před 2 roky
rodič
revize
cc4ccb2b78

+ 1 - 1
FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings

@@ -1052,7 +1052,7 @@ Enact a temp Basal or a temp target */
 "Bolus failed" = "Bolus failed";
 
 /* "Max Bolus Exceeded label" */
-"Max Bolus exceeded!" = "Max Bolus exceeded!";
+"Max Bolus exceeded!" = "¡Bolo máximo superado!";
 
 /* */
 "Bolus failed or inaccurate. Check pump history before repeating." = "Bolus failed or inaccurate. Check pump history before repeating.";

+ 2 - 2
FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings

@@ -16,8 +16,8 @@
 /* Continue after added carbs without bolus */
 "Continue without bolus" = "Fortsätt utan bolus";
 
-/* Alert when adding large amount without bolusing */
-"\nAmount is more than your Max Bolus setting! \nAre you sure you want to add " = "\nDetta är mer insulin än din maxdos-inställning!\nÄr du säker på att du vill lägga till ";
+/* Alert when adding large amount without bolusing. Don't remove the " " */
+"\nAmount is more than your Max Bolus setting! \nAre you sure you want to add " = "\nDetta är mer insulin än din maxdos-inställning! \nÄr du säker på att du vill lägga till ";
 
 /* Header */
 "Enact Bolus" = "Ge bolus";

+ 3 - 1
FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift

@@ -25,6 +25,7 @@ extension Bolus {
         @Published var expectedDelta: Decimal = 0
         @Published var minPredBG: Decimal = 0
         @Published var units: GlucoseUnits = .mmolL
+        @Published var maxBolus: Decimal = 0
 
         var waitForSuggestionInitial: Bool = false
 
@@ -34,6 +35,7 @@ extension Bolus {
             units = settingsManager.settings.units
             percentage = settingsManager.settings.insulinReqPercentage
             threshold = provider.suggestion?.threshold ?? 0
+            maxBolus = provider.pumpSettings().maxBolus
 
             if waitForSuggestionInitial {
                 apsManager.determineBasal()
@@ -55,7 +57,7 @@ extension Bolus {
                 return
             }
 
-            let maxAmount = Double(min(amount, provider.pumpSettings().maxBolus))
+            let maxAmount = Double(min(amount, maxBolus))
 
             unlockmanager.unlock()
                 .sink { _ in } receiveValue: { [weak self] _ in

+ 11 - 2
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -78,8 +78,17 @@ extension Bolus {
                     header: { Text("Bolus") }
                     Section {
                         Button { state.add() }
-                        label: { Text("Enact bolus") }
-                            .disabled(state.amount <= 0)
+                        label: {
+                            Text(
+                                state.amount < state.maxBolus ? NSLocalizedString("Enact bolus", comment: "") :
+                                    NSLocalizedString("Max Bolus exceeded!", comment: "")
+                                    + " (>"
+                                    + formatter.string(from: state.maxBolus as NSNumber)!
+                                    + ")"
+                            ) }
+                            .disabled(
+                                state.amount <= 0 || state.amount > state.maxBolus
+                            )
                     }
                     if waitForSuggestion {
                         Section {