|
|
@@ -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"),
|