Skip to content

Commit

Permalink
Merge pull request nightscout#1 from dnzxy/settings-update
Browse files Browse the repository at this point in the history
Extent SettingsInputSection and associated views
  • Loading branch information
tmhastings authored Oct 21, 2024
2 parents 65dc833 + 142a31d commit f2e374d
Show file tree
Hide file tree
Showing 29 changed files with 436 additions and 310 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension AutosensSettings {
@State var state = StateModel()
@State private var shouldDisplayHint: Bool = false
@State var hintDetent = PresentationDetent.large
@State var selectedVerboseHint: String?
@State var selectedVerboseHint: AnyView?
@State var hintLabel: String?
@State private var decimalPlaceholder: Decimal = 0.0
@State private var booleanPlaceholder: Bool = false
Expand Down Expand Up @@ -41,24 +41,22 @@ extension AutosensSettings {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = NSLocalizedString("Autosens Max", comment: "Autosens Max")
}
),
units: state.units,
type: .decimal("autosensMax"),
label: NSLocalizedString("Autosens Max", comment: "Autosens Max"),
miniHint: """
miniHint: """
The higher limit of the Autosens Ratio
Default: **120%**
""",
verboseHint: NSLocalizedString(
"""
Autosens Max sets the maximum Autosens Ratio used by Autosens, Dynamic ISF, Sigmoid Formula, and/or Autotune.
The Autosens Ratio is used to calculate the amount of adjustment needed to basals, ISF, and CR.
Increasing this value allows automatic adjustments of basal rates to be higher, ISF to be lower, and CR to be lower. This can result in more insulin given.
""",
comment: "Autosens Max"
verboseHint: Text(
NSLocalizedString(
"Autosens Max sets the maximum Autosens Ratio used by Autosens, Dynamic ISF, Sigmoid Formula, and/or Autotune. The Autosens Ratio is used to calculate the amount of adjustment needed to basals, ISF, and CR. Increasing this value allows automatic adjustments of basal rates to be higher, ISF to be lower, and CR to be lower. This can result in more insulin given.",
comment: "Autosens Max"
)
),
headerText: "Glucose Deviations Algorithm"
)
Expand All @@ -70,7 +68,7 @@ extension AutosensSettings {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = NSLocalizedString("Autosens Min", comment: "Autosens Min")
}
),
Expand All @@ -81,13 +79,13 @@ extension AutosensSettings {
The lower limit of the Autosens Ratio
Default: **80%**
""",
verboseHint: NSLocalizedString(
verboseHint: Text(NSLocalizedString(
"""
Autosens Min sets the minimum Autosens Ratio used by Autosens, Dynamic ISF, Sigmoid Formula, and/or Autotune.
The Autosens Ratio is used to calculate the amount of adjustment needed to basals, ISF, and CR.
Decreasing this value allows automatic adjustments of basal rates to be lower, ISF to be higher, and CR to be higher.
""",
comment: "Autosens Min"
comment: "Autosens Min")
)
)

Expand All @@ -98,17 +96,19 @@ extension AutosensSettings {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = NSLocalizedString("Rewind Resets Autosens", comment: "Rewind Resets Autosens")
}
),
units: state.units,
type: .boolean,
label: NSLocalizedString("Rewind Resets Autosens", comment: "Rewind Resets Autosens"),
miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
verboseHint: NSLocalizedString(
"This feature, enabled by default, resets the autosens ratio to neutral when you rewind your pump, on the assumption that this corresponds to a probable site change. Autosens will begin learning sensitivity anew from the time of the rewind, which may take up to 6 hours. If you usually rewind your pump independently of site changes, you may want to consider disabling this feature.",
comment: "Rewind Resets Autosens"
verboseHint: Text(
NSLocalizedString(
"This feature, enabled by default, resets the autosens ratio to neutral when you rewind your pump, on the assumption that this corresponds to a probable site change. Autosens will begin learning sensitivity anew from the time of the rewind, which may take up to 6 hours. If you usually rewind your pump independently of site changes, you may want to consider disabling this feature.",
comment: "Rewind Resets Autosens"
)
)
)
}
Expand All @@ -117,7 +117,7 @@ extension AutosensSettings {
hintDetent: $hintDetent,
shouldDisplayHint: $shouldDisplayHint,
hintLabel: hintLabel ?? "",
hintText: selectedVerboseHint ?? "",
hintText: selectedVerboseHint ?? AnyView(EmptyView()),
sheetTitle: "Help"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension AutotuneConfig {

@State private var shouldDisplayHint: Bool = false
@State var hintDetent = PresentationDetent.large
@State var selectedVerboseHint: String?
@State var selectedVerboseHint: AnyView?
@State var hintLabel: String?
@State private var decimalPlaceholder: Decimal = 0.0
@State private var booleanPlaceholder: Bool = false
Expand Down Expand Up @@ -63,15 +63,15 @@ extension AutotuneConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Use Autotune"
}
),
units: state.units,
type: .boolean,
label: "Use Autotune",
miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
verboseHint: "Autotune… bla bla bla",
verboseHint: Text("Autotune… bla bla bla"),
headerText: "Data-driven Adjustments"
)

Expand All @@ -83,15 +83,15 @@ extension AutotuneConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Only Autotune Basal Insulin"
}
),
units: state.units,
type: .boolean,
label: "Only Autotune Basal Insulin",
miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
verboseHint: "Only Autotune Basal Insulin… bla bla bla"
verboseHint: Text("Only Autotune Basal Insulin… bla bla bla")
)
}

Expand Down Expand Up @@ -188,7 +188,7 @@ extension AutotuneConfig {
hintDetent: $hintDetent,
shouldDisplayHint: $shouldDisplayHint,
hintLabel: hintLabel ?? "",
hintText: selectedVerboseHint ?? "",
hintText: selectedVerboseHint ?? AnyView(EmptyView()),
sheetTitle: "Help"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension BolusCalculatorConfig {

@State private var shouldDisplayHint: Bool = false
@State var hintDetent = PresentationDetent.large
@State var selectedVerboseHint: String?
@State var selectedVerboseHint: AnyView?
@State var hintLabel: String?
@State private var decimalPlaceholder: Decimal = 0.0
@State private var booleanPlaceholder: Bool = false
Expand Down Expand Up @@ -55,15 +55,15 @@ extension BolusCalculatorConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Display Meal Presets"
}
),
units: state.units,
type: .boolean,
label: "Display Meal Presets",
miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
verboseHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
verboseHint: Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr.")
)

SettingInputSection(
Expand All @@ -73,15 +73,15 @@ extension BolusCalculatorConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Recommended Bolus Percentage"
}
),
units: state.units,
type: .decimal("overrideFactor"),
label: "Recommended Bolus Percentage",
miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
verboseHint: "Recommended Bolus Percentage… bla bla bla",
verboseHint: Text("Recommended Bolus Percentage… bla bla bla"),
headerText: "Calculator Configuration"
)

Expand All @@ -92,7 +92,7 @@ extension BolusCalculatorConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Fatty Meal Factor"
}
),
Expand All @@ -101,7 +101,9 @@ extension BolusCalculatorConfig {
label: "Enable Fatty Meal Factor",
conditionalLabel: "Fatty Meal Factor",
miniHint: "Lower your bolus recommendation by factor x for fatty meals.",
verboseHint: "You can add the option in your bolus calculator to apply another (!) customizable factor at the end of the calculation which could be useful for fatty meals, e.g Pizza (default 0.7)."
verboseHint: Text(
"You can add the option in your bolus calculator to apply another (!) customizable factor at the end of the calculation which could be useful for fatty meals, e.g Pizza (default 0.7)."
)
)

SettingInputSection(
Expand All @@ -111,7 +113,7 @@ extension BolusCalculatorConfig {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Super Bolus & Sweet Meal Factor"
}
),
Expand All @@ -120,15 +122,17 @@ extension BolusCalculatorConfig {
label: "Enable Super Bolus",
conditionalLabel: "Super Bolus Factor",
miniHint: "Add x times current scheduled basal rate to your bolus recommendation.",
verboseHint: "You can enable the super bolus functionality which could be useful when eating sweets/cake etc. Therefore your current basal rate will be added x-times to your bolus recommendation. You can adjust the factor X here, the default is 2 times your current scheduled basal rate."
verboseHint: Text(
"You can enable the super bolus functionality which could be useful when eating sweets/cake etc. Therefore your current basal rate will be added x-times to your bolus recommendation. You can adjust the factor X here, the default is 2 times your current scheduled basal rate."
)
)
}
.sheet(isPresented: $shouldDisplayHint) {
SettingInputHintView(
hintDetent: $hintDetent,
shouldDisplayHint: $shouldDisplayHint,
hintLabel: hintLabel ?? "",
hintText: selectedVerboseHint ?? "",
hintText: selectedVerboseHint ?? AnyView(EmptyView()),
sheetTitle: "Help"
)
}
Expand Down
17 changes: 11 additions & 6 deletions FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension CGM {

@State private var shouldDisplayHint: Bool = false
@State var hintDetent = PresentationDetent.large
@State var selectedVerboseHint: String?
@State var selectedVerboseHint: AnyView?
@State var hintLabel: String?
@State private var decimalPlaceholder: Decimal = 0.0
@State private var booleanPlaceholder: Bool = false
Expand Down Expand Up @@ -62,7 +62,11 @@ extension CGM {
action: {
hintLabel = "Available CGM Types for Trio"
selectedVerboseHint =
"CGM Types… bla bla \n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr."
AnyView(
Text(
"CGM Types… bla bla \n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr."
)
)
shouldDisplayHint.toggle()
},
label: {
Expand Down Expand Up @@ -172,7 +176,8 @@ extension CGM {
Button(
action: {
hintLabel = "CGM Heartbeat"
selectedVerboseHint = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
selectedVerboseHint =
AnyView(Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr."))
shouldDisplayHint.toggle()
},
label: {
Expand All @@ -199,15 +204,15 @@ extension CGM {
selectedVerboseHint: Binding(
get: { selectedVerboseHint },
set: {
selectedVerboseHint = $0
selectedVerboseHint = $0.map { AnyView($0) }
hintLabel = "Smooth Glucose Value"
}
),
units: state.units,
type: .boolean,
label: "Smooth Glucose Value",
miniHint: "Smooth CGM readings using Savitzky–Golay filtering.",
verboseHint: "Smooth Glucose Value… bla bla bla"
verboseHint: Text("Smooth Glucose Value… bla bla bla")
)
}
.scrollContentBackground(.hidden).background(color)
Expand All @@ -219,7 +224,7 @@ extension CGM {
hintDetent: $hintDetent,
shouldDisplayHint: $shouldDisplayHint,
hintLabel: hintLabel ?? "",
hintText: selectedVerboseHint ?? "",
hintText: selectedVerboseHint ?? AnyView(EmptyView()),
sheetTitle: "Help"
)
}
Expand Down
Loading

0 comments on commit f2e374d

Please sign in to comment.