| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- import SwiftUI
- import Swinject
- extension AutosensSettings {
- struct RootView: BaseView {
- let resolver: Resolver
- @State var state = StateModel()
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State var selectedVerboseHint: AnyView?
- @State var hintLabel: String?
- @State private var decimalPlaceholder: Decimal = 0.0
- @State private var booleanPlaceholder: Bool = false
- @Environment(\.colorScheme) var colorScheme
- @EnvironmentObject var appIcons: Icons
- private var color: LinearGradient {
- colorScheme == .dark ? LinearGradient(
- gradient: Gradient(colors: [
- Color.bgDarkBlue,
- Color.bgDarkerDarkBlue
- ]),
- startPoint: .top,
- endPoint: .bottom
- )
- :
- LinearGradient(
- gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
- startPoint: .top,
- endPoint: .bottom
- )
- }
- var body: some View {
- List {
- SettingInputSection(
- decimalValue: $state.autosensMax,
- booleanValue: $booleanPlaceholder,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- 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: """
- The higher limit of the Autosens Ratio
- Default: 120%
- """,
- verboseHint: VStack {
- Text("Default: 120%").bold()
- Text(
- """
- 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.
- """
- )
- Text(
- "Increasing this value allows automatic adjustments of basal rates to be higher, ISF to be lower, and CR to be lower."
- )
- .italic()
- },
- headerText: "Glucose Deviations Algorithm"
- )
- SettingInputSection(
- decimalValue: $state.autosensMin,
- booleanValue: $booleanPlaceholder,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0.map { AnyView($0) }
- hintLabel = NSLocalizedString("Autosens Min", comment: "Autosens Min")
- }
- ),
- units: state.units,
- type: .decimal("autosensMin"),
- label: NSLocalizedString("Autosens Min", comment: "Autosens Min"),
- miniHint: """
- The lower limit of the Autosens Ratio
- Default: 80%
- """,
- verboseHint: VStack {
- Text("Default: 80%").bold()
- Text(
- """
- 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.
- """
- )
- Text(
- "Decreasing this value allows automatic adjustments of basal rates to be lower, ISF to be higher, and CR to be higher."
- )
- .italic()
- }
- )
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.rewindResetsAutosens,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- 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: """
- Pump rewind initiates a reset in Autosens Ratio
- Default: ON
- """,
- verboseHint: VStack {
- Text("Default: ON").bold()
- Text("Medtronic Users Only").bold().italic()
- Text("This feature resets the Autosens Ratio to neutral when you rewind your pump on the assumption that this corresponds to a site change.")
- Text("Autosens will begin learning sensitivity anew from the time of the rewind, which may take up to 6 hours.")
- Text("If you usually rewind your pump independently of site changes, you may want to consider disabling this feature.").italic()
- }
- )
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: hintLabel ?? "",
- hintText: selectedVerboseHint ?? AnyView(EmptyView()),
- sheetTitle: "Help"
- )
- }
- .scrollContentBackground(.hidden).background(color)
- .onAppear(perform: configureView)
- .navigationTitle("Autosens")
- .navigationBarTitleDisplayMode(.automatic)
- .onDisappear {
- state.saveIfChanged()
- }
- }
- }
- }
|