Skip to content

Commit

Permalink
Use fresh suggestion for both bolus calculators. Fresh as in updated …
Browse files Browse the repository at this point in the history
…every relevant oref variable, like COB, IOB etc.
  • Loading branch information
Jon-b-m committed Oct 29, 2023
1 parent 692a57e commit 5dec48d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
4 changes: 0 additions & 4 deletions FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ extension Bolus {
.roundBolus(amount: max(self.insulinRecommended, 0))

self.getDeltaBG()

if self.useCalc {
self.apsManager.determineBasalSync()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,36 +100,44 @@ extension Bolus {
header: { Text("Values") }

Section {
HStack {
Text("Recommended Bolus")
Spacer()

Text(
formatter
.string(from: Double(insulinCalculated) as NSNumber)!
)
let unit = NSLocalizedString(
" U",
comment: "Unit in number of units delivered (keep the space character!)"
)
Text(unit).foregroundColor(.secondary)
}.contentShape(Rectangle())
.onTapGesture {
state.amount = insulinCalculated
if state.waitForSuggestion {
HStack {
Text("Wait please").foregroundColor(.secondary)
Spacer()
ActivityIndicator(isAnimating: .constant(true), style: .medium) // fix iOS 15 bug
}

if !state.waitForSuggestion {
} else {
HStack {
Text("Bolus")
Text("Recommended Bolus")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: false,
cleanInput: true

Text(
formatter
.string(from: Double(insulinCalculated) as NSNumber)!
)
let unit = NSLocalizedString(
" U",
comment: "Unit in number of units delivered (keep the space character!)"
)
Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
Text(unit).foregroundColor(.secondary)
}.contentShape(Rectangle())
.onTapGesture {
state.amount = insulinCalculated
}

if !state.waitForSuggestion {
HStack {
Text("Bolus")
Spacer()
DecimalTextField(
"0",
value: $state.amount,
formatter: formatter,
autofocus: false,
cleanInput: true
)
Text(!(state.amount > state.maxBolus) ? "U" : "😵").foregroundColor(.secondary)
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion FreeAPS/Sources/Modules/Home/View/HomeRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,10 @@ extension Home {
.foregroundColor(.loopGreen)
.buttonStyle(.borderless)
Spacer()
Button { state.showModal(for: .bolus(waitForSuggestion: false)) }
Button {
state.showModal(for: .bolus(waitForSuggestion: true))
state.apsManager.determineBasalSync()
}
label: {
Image("bolus")
.renderingMode(.template)
Expand Down

0 comments on commit 5dec48d

Please sign in to comment.