Skip to content

Commit

Permalink
Move max carbs (Artificial-Pancreas#811)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0713f01)
  • Loading branch information
Jon-b-m committed Aug 12, 2024
1 parent 3cbf3d2 commit f8e20d4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"units": "mmol/L",
"timeCap": 8,
"useCalc": true,
"maxCarbs": 350,
"maxCarbs": 200,
"birthDate": "0001-01-01T23:00:00.000Z",
"displayHR": true,
"closedLoop": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ Enact a temp Basal or a temp target */
/* Max setting */
"Max Carbs" = "Max Carbs";

/* Max carbs description */
"Maximum amount of carbs (g) you can add each entry" = "Maximum amount of carbs (g) you can add each entry";

/* */
"Pump Settings" = "Pump Settings";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ extension PreferencesEditor {
@Published var sections: [FieldSection] = []
@Published var useAlternativeBolusCalc: Bool = false
@Published var units: GlucoseUnits = .mmolL
@Published var maxCarbs: Decimal = 200

override func subscribe() {
preferences = provider.preferences
units = settingsManager.settings.units

subscribeSetting(\.maxCarbs, on: $maxCarbs) { maxCarbs = $0 }
subscribeSetting(\.units, on: $unitsIndex.map { $0 == 0 ? GlucoseUnits.mgdL : .mmolL }) {
unitsIndex = $0 == .mgdL ? 0 : 1
} didSet: { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ extension PreferencesEditor {
}
}
}

// Exceptions. Below a FreeAPS setting added.
if field.displayName == NSLocalizedString("Max COB", comment: "Max COB") {
maxCarbs
}
}
}
}
Expand Down Expand Up @@ -112,5 +117,27 @@ extension PreferencesEditor {
)
}
}

var maxCarbs: some View {
HStack {
ZStack {
Button("", action: {
infoButtonPressed = InfoText(
description: NSLocalizedString(
"Maximum amount of carbs (g) you can add each entry",
comment: "Max carbs description"
),
oref0Variable: NSLocalizedString("Max Carbs", comment: "Max setting")
)
})
Text("Max Carbs")
}
DecimalTextField(
"0",
value: self.$state.maxCarbs,
formatter: formatter
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ extension PumpSettingsEditor {
@Published var maxBasal: Decimal = 0.0
@Published var maxBolus: Decimal = 0.0
@Published var dia: Decimal = 0.0
@Published var maxCarbs: Decimal = 1000

@Published var syncInProgress = false

override func subscribe() {
let settings = provider.settings()
maxBasal = settings.maxBasal
maxBolus = settings.maxBolus
dia = settings.insulinActionCurve
maxCarbs = settingsManager.settings.maxCarbs
subscribeSetting(\.maxCarbs, on: $maxCarbs) { maxCarbs = $0 }
}

func save() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ extension PumpSettingsEditor {
Text("Max Bolus")
DecimalTextField("U", value: $state.maxBolus, formatter: formatter)
}
HStack {
Text("Max Carbs")
DecimalTextField("g", value: $state.maxCarbs, formatter: formatter)
}
}

Section(header: Text("Duration of Insulin Action")) {
Expand Down

0 comments on commit f8e20d4

Please sign in to comment.