Skip to content

Commit

Permalink
Update Bolus Alerts.
Browse files Browse the repository at this point in the history
Allow 3 X Max Bolus for non-pump insulin,
but add alert when over Max Bolus.
Localize (tested in Swedish)
  • Loading branch information
Jon-b-m committed Sep 28, 2023
1 parent 7aeade4 commit 7c7cafe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/* Continue after added carbs 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 */
"Enact Bolus" = "Enact Bolus";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/* Continue after added carbs without 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 */
"Enact Bolus" = "Ge bolus";

Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension Bolus {
showModal(for: nil)
return
}
amount = min(amount, maxBolus)
amount = min(amount, maxBolus * 3) // Allow for 3 * Max Bolus for non-pump insulin

pumpHistoryStorage.storeEvents(
[
Expand Down
36 changes: 27 additions & 9 deletions FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,36 @@ extension Bolus {
} else {
Button { isAddInsulinAlertPresented = true }
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(
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(
Text("Add"),
Expand Down

0 comments on commit 7c7cafe

Please sign in to comment.