Skip to content

Commit 045e2d2

Browse files
authored
LOOP-2034: Add active insulin notice to simple bolus UI (#302)
* Add active insulin notice to simple bolus ui * Update from PR review
1 parent d6b4b75 commit 045e2d2

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

Loop/View Models/SimpleBolusViewModel.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class SimpleBolusViewModel: ObservableObject {
6363

6464
@Published var recommendedBolus: String = "0"
6565

66+
@Published var activeInsulin: String?
67+
6668
@Published var enteredCarbAmount: String = "" {
6769
didSet {
6870
if let enteredCarbs = Self.carbAmountFormatter.number(from: enteredCarbAmount)?.doubleValue, enteredCarbs > 0 {
@@ -127,6 +129,12 @@ class SimpleBolusViewModel: ObservableObject {
127129
} else {
128130
recommendation = nil
129131
}
132+
133+
if let decision = dosingDecision, let insulinOnBoard = decision.insulinOnBoard, insulinOnBoard.value > 0 {
134+
activeInsulin = Self.doseAmountFormatter.string(from: insulinOnBoard.value)
135+
} else {
136+
activeInsulin = nil
137+
}
130138
}
131139
}
132140

Loop/Views/SimpleBolusView.swift

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,37 @@ struct SimpleBolusView: View, HorizontalSizeClassOverride {
151151
}
152152

153153
private var recommendedBolusRow: some View {
154-
HStack {
155-
Text("Recommended Bolus", comment: "Label for recommended bolus row on simple bolus screen")
156-
Spacer()
157-
HStack(alignment: .firstTextBaseline) {
158-
Text(viewModel.recommendedBolus)
159-
.font(.title)
160-
.foregroundColor(Color(.label))
161-
.padding([.top, .bottom], 4)
162-
bolusUnitsLabel
154+
VStack(alignment: .leading) {
155+
HStack {
156+
Text("Recommended Bolus", comment: "Label for recommended bolus row on simple bolus screen")
157+
Spacer()
158+
HStack(alignment: .firstTextBaseline) {
159+
Text(viewModel.recommendedBolus)
160+
.font(.title)
161+
.foregroundColor(Color(.label))
162+
.padding([.top, .bottom], 4)
163+
bolusUnitsLabel
164+
}
165+
}
166+
.padding(.trailing, 8)
167+
if let activeInsulin = viewModel.activeInsulin {
168+
HStack(alignment: .center, spacing: 3) {
169+
Text("Adjusted for")
170+
.font(.footnote)
171+
.foregroundColor(.secondary)
172+
Text("Active Insulin")
173+
.font(.footnote)
174+
.bold()
175+
Text(activeInsulin)
176+
.font(.footnote)
177+
.bold()
178+
.foregroundColor(.secondary)
179+
bolusUnitsLabel
180+
.font(.footnote)
181+
.bold()
182+
}
163183
}
164184
}
165-
.padding(.trailing, 8)
166185
}
167186

168187
private var bolusEntryRow: some View {
@@ -197,7 +216,7 @@ struct SimpleBolusView: View, HorizontalSizeClassOverride {
197216
.foregroundColor(Color(.secondaryLabel))
198217
}
199218

200-
private var bolusUnitsLabel: some View {
219+
private var bolusUnitsLabel: Text {
201220
Text(QuantityFormatter().string(from: .internationalUnit()))
202221
.foregroundColor(Color(.secondaryLabel))
203222
}

0 commit comments

Comments
 (0)