Skip to content

Commit

Permalink
Merge pull request #100 from MikePlante1/max_bolus
Browse files Browse the repository at this point in the history
Utilize max bolus limit in Bolus module
  • Loading branch information
bjornoleh authored May 3, 2024
2 parents e4a71ef + 621afd4 commit cc4ccb2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 3 additions & 1 deletion FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cc4ccb2

Please sign in to comment.