ReviewInsulinActionView.swift 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. var color: LinearGradient {
  15. colorScheme == .dark ? LinearGradient(
  16. gradient: Gradient(colors: [
  17. Color.bgDarkBlue,
  18. Color.bgDarkerDarkBlue
  19. ]),
  20. startPoint: .top,
  21. endPoint: .bottom
  22. )
  23. :
  24. LinearGradient(
  25. gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
  26. startPoint: .top,
  27. endPoint: .bottom
  28. )
  29. }
  30. var body: some View {
  31. List {
  32. SettingInputSection(
  33. decimalValue: $state.importedInsulinActionCurve,
  34. booleanValue: $booleanPlaceholder,
  35. shouldDisplayHint: $shouldDisplayHint,
  36. selectedVerboseHint: Binding(
  37. get: { selectedVerboseHint },
  38. set: {
  39. selectedVerboseHint = $0
  40. hintLabel = "Duration of Insulin Action"
  41. }
  42. ),
  43. units: state.units,
  44. type: .decimal("dia"),
  45. label: "Duration of Insulin Action",
  46. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  47. verboseHint: "Duration of Insulin Action… bla bla bla",
  48. headerText: "Review imported DIA"
  49. )
  50. }
  51. .sheet(isPresented: $shouldDisplayHint) {
  52. SettingInputHintView(
  53. hintDetent: $hintDetent,
  54. shouldDisplayHint: $shouldDisplayHint,
  55. hintLabel: hintLabel ?? "",
  56. hintText: selectedVerboseHint ?? "",
  57. sheetTitle: "Help"
  58. )
  59. }
  60. .scrollContentBackground(.hidden).background(color)
  61. .onAppear(perform: configureView)
  62. .navigationTitle("Duration of Insulin Action")
  63. .navigationBarTitleDisplayMode(.automatic)
  64. .onDisappear {
  65. state.saveReviewedInsulinAction()
  66. }
  67. }
  68. }