| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import SwiftUI
- import Swinject
- extension TargetBehavoir {
- struct RootView: BaseView {
- let resolver: Resolver
- @StateObject var state = StateModel()
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State var selectedVerboseHint: String?
- @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
- @Environment(AppState.self) var appState
- var body: some View {
- List {
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.highTemptargetRaisesSensitivity,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = NSLocalizedString(
- "High Temptarget Raises Sensitivity",
- comment: "High Temptarget Raises Sensitivity"
- )
- }
- ),
- units: state.units,
- type: .boolean,
- label: NSLocalizedString(
- "High Temptarget Raises Sensitivity",
- comment: "High Temptarget Raises Sensitivity"
- ),
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: NSLocalizedString(
- "Defaults to false. When set to true, raises sensitivity (lower sensitivity ratio) for temp targets set to >= 111. Synonym for exercise_mode. The higher your temp target above 110 will result in more sensitive (lower) ratios, e.g., temp target of 120 results in sensitivity ratio of 0.75, while 140 results in 0.6 (with default halfBasalTarget of 160).",
- comment: "High Temptarget Raises Sensitivity"
- ),
- headerText: "Algorithmic Target Settings"
- )
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.lowTemptargetLowersSensitivity,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = NSLocalizedString(
- "Low Temptarget Lowers Sensitivity",
- comment: "Low Temptarget Lowers Sensitivity"
- )
- }
- ),
- units: state.units,
- type: .boolean,
- label: NSLocalizedString(
- "Low Temptarget Lowers Sensitivity",
- comment: "Low Temptarget Lowers Sensitivity"
- ),
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: NSLocalizedString(
- "Defaults to false. When set to true, can lower sensitivity (higher sensitivity ratio) for temptargets <= 99. The lower your temp target below 100 will result in less sensitive (higher) ratios, e.g., temp target of 95 results in sensitivity ratio of 1.09, while 85 results in 1.33 (with default halfBasalTarget of 160).",
- comment: "Low Temptarget Lowers Sensitivity"
- )
- )
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.sensitivityRaisesTarget,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = NSLocalizedString("Sensitivity Raises Target", comment: "Sensitivity Raises Target")
- }
- ),
- units: state.units,
- type: .boolean,
- label: NSLocalizedString("Sensitivity Raises Target", comment: "Sensitivity Raises Target"),
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: NSLocalizedString(
- "When true, raises BG target when autosens detects sensitivity",
- comment: "Sensitivity Raises Target"
- )
- )
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.resistanceLowersTarget,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = NSLocalizedString("Resistance Lowers Target", comment: "Resistance Lowers Target")
- }
- ),
- units: state.units,
- type: .boolean,
- label: NSLocalizedString("Resistance Lowers Target", comment: "Resistance Lowers Target"),
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: NSLocalizedString(
- "Defaults to false. When true, will lower BG target when autosens detects resistance",
- comment: "Resistance Lowers Target"
- )
- )
- SettingInputSection(
- decimalValue: $state.halfBasalExerciseTarget,
- booleanValue: $booleanPlaceholder,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = NSLocalizedString("Half Basal Exercise Target", comment: "Half Basal Exercise Target")
- }
- ),
- units: state.units,
- type: .decimal("halfBasalExerciseTarget"),
- label: NSLocalizedString("Half Basal Exercise Target", comment: "Half Basal Exercise Target"),
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: NSLocalizedString(
- "Set to a number, e.g. 160, which means when temp target is 160 mg/dL, run 50% basal at this level (120 = 75%; 140 = 60%). This can be adjusted, to give you more control over your exercise modes.",
- comment: "Half Basal Exercise Target"
- )
- )
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: hintLabel ?? "",
- hintText: selectedVerboseHint ?? "",
- sheetTitle: "Help"
- )
- }
- .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
- .onAppear(perform: configureView)
- .navigationTitle("Target Behavior")
- .navigationBarTitleDisplayMode(.automatic)
- // .onDisappear {
- // state.saveIfChanged()
- // }
- }
- }
- }
|