Переглянути джерело

Update Bolus Alerts.
Allow 3 X Max Bolus for non-pump insulin,
but add alert when over Max Bolus.
Localize (tested in Swedish)

Jon Mårtensson 2 роки тому
батько
коміт
7c7cafecf2

+ 3 - 0
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -16,6 +16,9 @@
 /* Continue after added carbs without bolus */
 /* Continue after added carbs without bolus */
 "Continue without bolus" = "Continue without bolus";
 "Continue without bolus" = "Continue without bolus";
 
 
+/* Alert when adding large amount without bolusing */
+"\nAmount is more than your Max Bolus setting! \nAre you sure you want to add " = "\nAmount is more than your Max Bolus setting! \nAre you sure you want to add ";
+
 /* Header */
 /* Header */
 "Enact Bolus" = "Enact Bolus";
 "Enact Bolus" = "Enact Bolus";
 
 

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

@@ -16,6 +16,9 @@
 /* Continue after added carbs without bolus */
 /* Continue after added carbs without bolus */
 "Continue without bolus" = "Fortsätt utan bolus";
 "Continue without bolus" = "Fortsätt utan bolus";
 
 
+/* 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 */
 /* Header */
 "Enact Bolus" = "Ge bolus";
 "Enact Bolus" = "Ge bolus";
 
 

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

@@ -73,7 +73,7 @@ extension Bolus {
                 showModal(for: nil)
                 showModal(for: nil)
                 return
                 return
             }
             }
-            amount = min(amount, maxBolus)
+            amount = min(amount, maxBolus * 3) // Allow for 3 * Max Bolus for non-pump insulin
 
 
             pumpHistoryStorage.storeEvents(
             pumpHistoryStorage.storeEvents(
                 [
                 [

+ 27 - 9
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -90,18 +90,36 @@ extension Bolus {
                         } else {
                         } else {
                             Button { isAddInsulinAlertPresented = true }
                             Button { isAddInsulinAlertPresented = true }
                             label: { Text("Add insulin without actually bolusing") }
                             label: { Text("Add insulin without actually bolusing") }
-                                .disabled(
-                                    state.amount <= 0 || state.amount > state.maxBolus
-                                )
+                                .disabled(state.amount <= 0 || state.amount > state.maxBolus * 3)
                         }
                         }
                     }
                     }
                     .alert(isPresented: $isAddInsulinAlertPresented) {
                     .alert(isPresented: $isAddInsulinAlertPresented) {
-                        Alert(
-                            title: Text("Are you sure?"),
-                            message: Text(
-                                NSLocalizedString("Add", comment: "Add insulin without bolusing alert") + " " + formatter
-                                    .string(from: state.amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") +
-                                    NSLocalizedString(" without bolusing", comment: "Add insulin without bolusing alert")
+                        let isOverMax = state.amount > state.maxBolus ? true : false
+                        let secondParagrap1 = "Add"
+                        let secondParagraph2 = " U"
+                        let secondParagraph3 = " without bolusing"
+                        let insulinAmount = formatter.string(from: state.amount as NSNumber)!
+
+                        // Actual alert
+                        return Alert(
+                            title: Text(
+                                isOverMax ? "Warning" : "Are you sure?"
+                            ),
+                            message:
+                            Text(
+                                isOverMax ? (
+                                    NSLocalizedString(
+                                        "\nAmount is more than your Max Bolus setting! \nAre you sure you want to add ",
+                                        comment: "Alert"
+                                    ) + insulinAmount +
+                                        NSLocalizedString(secondParagraph2, comment: "Insulin unit") +
+                                        NSLocalizedString(secondParagraph3, comment: "Add insulin without bolusing alert") + "?"
+                                ) :
+                                    NSLocalizedString(secondParagrap1, comment: "Add insulin without bolusing alert") +
+                                    " " +
+                                    insulinAmount +
+                                    NSLocalizedString(secondParagraph2, comment: "Insulin unit") +
+                                    NSLocalizedString(secondParagraph3, comment: "Add insulin without bolusing alert")
                             ),
                             ),
                             primaryButton: .destructive(
                             primaryButton: .destructive(
                                 Text("Add"),
                                 Text("Add"),