diff --git a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json index b3e135569a..79beccd6c8 100644 --- a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json +++ b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json @@ -40,7 +40,7 @@ "yGridLines" : true, "oneDimensionalGraph" : false, "rulerMarks" : false, - "maxCarbs" : 1000, + "maxCarbs" : 200, "displayFatAndProteinOnWatch" : false, "confirmBolusFaster" : false, "onlyAutotuneBasals" : false, diff --git a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings index 6cf67657ff..c33128523d 100644 --- a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings @@ -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"; diff --git a/FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift b/FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift index bf418665a9..7cdff99272 100644 --- a/FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift +++ b/FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift @@ -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 diff --git a/FreeAPS/Sources/Modules/PreferencesEditor/View/PreferencesEditorRootView.swift b/FreeAPS/Sources/Modules/PreferencesEditor/View/PreferencesEditorRootView.swift index 0b25db6fad..b97005b2b3 100644 --- a/FreeAPS/Sources/Modules/PreferencesEditor/View/PreferencesEditorRootView.swift +++ b/FreeAPS/Sources/Modules/PreferencesEditor/View/PreferencesEditorRootView.swift @@ -71,6 +71,11 @@ extension PreferencesEditor { } } } + + // Exceptions. Below a FreeAPS setting added. + if field.displayName == NSLocalizedString("Max COB", comment: "Max COB") { + maxCarbs + } } } } @@ -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 + ) + } + } } } diff --git a/FreeAPS/Sources/Modules/PumpSettingsEditor/PumpSettingsEditorStateModel.swift b/FreeAPS/Sources/Modules/PumpSettingsEditor/PumpSettingsEditorStateModel.swift index 1fb2a84c87..ecd77e0f42 100644 --- a/FreeAPS/Sources/Modules/PumpSettingsEditor/PumpSettingsEditorStateModel.swift +++ b/FreeAPS/Sources/Modules/PumpSettingsEditor/PumpSettingsEditorStateModel.swift @@ -5,8 +5,6 @@ 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() { @@ -14,7 +12,6 @@ extension PumpSettingsEditor { maxBasal = settings.maxBasal maxBolus = settings.maxBolus dia = settings.insulinActionCurve - subscribeSetting(\.maxCarbs, on: $maxCarbs) { maxCarbs = $0 } } func save() { diff --git a/FreeAPS/Sources/Modules/PumpSettingsEditor/View/PumpSettingsEditorRootView.swift b/FreeAPS/Sources/Modules/PumpSettingsEditor/View/PumpSettingsEditorRootView.swift index 4611097c4c..5bf0884898 100644 --- a/FreeAPS/Sources/Modules/PumpSettingsEditor/View/PumpSettingsEditorRootView.swift +++ b/FreeAPS/Sources/Modules/PumpSettingsEditor/View/PumpSettingsEditorRootView.swift @@ -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")) {