Skip to content

Commit 52e54d0

Browse files
author
Rick Pasetto
authored
Move Delivery Limits to LoopKit (#157)
1 parent 11333ee commit 52e54d0

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

Loop/Views/DeliveryLimitsEditor.swift

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,6 @@ import HealthKit
1111
import LoopKit
1212
import LoopKitUI
1313

14-
15-
struct DeliveryLimits: Equatable {
16-
enum Setting: Equatable {
17-
case maximumBasalRate
18-
case maximumBolus
19-
}
20-
21-
var settings: [Setting: HKQuantity]
22-
23-
init(maximumBasalRate: HKQuantity?, maximumBolus: HKQuantity?) {
24-
settings = [:]
25-
settings[.maximumBasalRate] = maximumBasalRate
26-
settings[.maximumBolus] = maximumBolus
27-
}
28-
29-
var maximumBasalRate: HKQuantity? {
30-
get { settings[.maximumBasalRate] }
31-
set { settings[.maximumBasalRate] = newValue }
32-
}
33-
34-
var maximumBolus: HKQuantity? {
35-
get { settings[.maximumBolus] }
36-
set { settings[.maximumBolus] = newValue }
37-
}
38-
}
39-
40-
4114
struct DeliveryLimitsEditor: View {
4215
var initialValue: DeliveryLimits
4316
var supportedBasalRates: [Double]
@@ -77,7 +50,7 @@ struct DeliveryLimitsEditor: View {
7750

7851
var body: some View {
7952
ConfigurationPage(
80-
title: Text("Delivery Limits", comment: "Title for delivery limits page"),
53+
title: Text(TherapySetting.deliveryLimits.title),
8154
saveButtonState: saveButtonState,
8255
cards: {
8356
maximumBasalRateCard
@@ -125,7 +98,7 @@ struct DeliveryLimitsEditor: View {
12598

12699
var maximumBasalRateCard: Card {
127100
Card {
128-
SettingDescription(text: Text("Maximum basal rate is the highest temporary basal rate Tidepool Loop is allowed to set automatically.", comment: "Maximum bolus setting description"), informationalContent: {Text("To be implemented")}) // ANNA TODO: placeholder so this builds
101+
SettingDescription(text: Text(DeliveryLimits.Setting.maximumBasalRate.descriptiveText), informationalContent: {Text("To be implemented")}) // ANNA TODO: placeholder so this builds
129102
ExpandableSetting(
130103
isEditing: Binding(
131104
get: { self.settingBeingEdited == .maximumBasalRate },
@@ -136,7 +109,7 @@ struct DeliveryLimitsEditor: View {
136109
}
137110
),
138111
leadingValueContent: {
139-
Text("Maximum Basal Rate", comment: "Title text for maximum basal rate configuration")
112+
Text(DeliveryLimits.Setting.maximumBasalRate.title)
140113
},
141114
trailingValueContent: {
142115
GuardrailConstrainedQuantityView(
@@ -182,7 +155,7 @@ struct DeliveryLimitsEditor: View {
182155
var maximumBolusCard: Card {
183156
Card {
184157
SettingDescription(
185-
text: Text("Maximum bolus is the highest bolus amount you can deliver at one time.", comment: "Maximum basal rate setting description"), informationalContent: {Text("To be implemented")}) // ANNA TODO: placeholder so this builds
158+
text: Text(DeliveryLimits.Setting.maximumBolus.descriptiveText), informationalContent: {Text("To be implemented")}) // ANNA TODO: placeholder so this builds
186159
ExpandableSetting(
187160
isEditing: Binding(
188161
get: { self.settingBeingEdited == .maximumBolus },
@@ -193,7 +166,7 @@ struct DeliveryLimitsEditor: View {
193166
}
194167
),
195168
leadingValueContent: {
196-
Text("Maximum Bolus", comment: "Title text for maximum bolus configuration")
169+
Text(DeliveryLimits.Setting.maximumBolus.title)
197170
},
198171
trailingValueContent: {
199172
GuardrailConstrainedQuantityView(
@@ -321,7 +294,7 @@ struct DeliveryLimitsGuardrailWarning: View {
321294
return GuardrailWarning(title: title, threshold: threshold, caption: caption)
322295
case 2:
323296
return GuardrailWarning(
324-
title: Text("Delivery Limits"),
297+
title: Text(TherapySetting.deliveryLimits.title),
325298
thresholds: Array(crossedThresholds.values),
326299
caption: Text("The values you have entered are outside of what Tidepool generally recommends.", comment: "Caption text for warning where both delivery limits are outside the recommended range")
327300
)

0 commit comments

Comments
 (0)