ReviewInsulinActionView.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Foundation
  2. import SwiftUI
  3. import Swinject
  4. struct ReviewInsulinActionView: BaseView {
  5. var resolver: any Swinject.Resolver
  6. @ObservedObject var state: NightscoutConfig.StateModel
  7. @State private var shouldDisplayHint: Bool = false
  8. @State private var hintDetent = PresentationDetent.large
  9. @State private var selectedVerboseHint: String?
  10. @State private var hintLabel: String?
  11. @State private var decimalPlaceholder: Decimal = 0.0
  12. @State private var booleanPlaceholder: Bool = false
  13. @Environment(\.colorScheme) var colorScheme
  14. @Environment(AppState.self) var appState
  15. var body: some View {
  16. List {
  17. SettingInputSection(
  18. decimalValue: $state.importedInsulinActionCurve,
  19. booleanValue: $booleanPlaceholder,
  20. shouldDisplayHint: $shouldDisplayHint,
  21. selectedVerboseHint: Binding(
  22. get: { selectedVerboseHint },
  23. set: {
  24. selectedVerboseHint = $0
  25. hintLabel = "Duration of Insulin Action"
  26. }
  27. ),
  28. units: state.units,
  29. type: .decimal("dia"),
  30. label: "Duration of Insulin Action",
  31. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  32. verboseHint: "Duration of Insulin Action… bla bla bla",
  33. headerText: "Review imported DIA"
  34. )
  35. }
  36. .sheet(isPresented: $shouldDisplayHint) {
  37. SettingInputHintView(
  38. hintDetent: $hintDetent,
  39. shouldDisplayHint: $shouldDisplayHint,
  40. hintLabel: hintLabel ?? "",
  41. hintText: selectedVerboseHint ?? "",
  42. sheetTitle: "Help"
  43. )
  44. }
  45. .scrollContentBackground(.hidden)
  46. .background(appState.trioBackgroundColor(for: colorScheme))
  47. .onAppear(perform: configureView)
  48. .navigationTitle("Duration of Insulin Action")
  49. .navigationBarTitleDisplayMode(.automatic)
  50. .onDisappear {
  51. state.saveReviewedInsulinAction()
  52. }
  53. }
  54. }