NightscoutImportResultView.swift 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import SwiftUI
  2. import Swinject
  3. struct NightscoutImportResultView: BaseView {
  4. var resolver: any Swinject.Resolver
  5. @ObservedObject var state: NightscoutConfig.StateModel
  6. @State private var shouldDisplayHint: Bool = false
  7. @State private var hintDetent = PresentationDetent.large
  8. @State private var selectedVerboseHint: String?
  9. @State private var hintLabel: String?
  10. @State private var decimalPlaceholder: Decimal = 0.0
  11. @State private var booleanPlaceholder: Bool = false
  12. @State private var hasVisitedBasalProfileEditor = false
  13. @State private var hasVisitedISFEditor = false
  14. @State private var hasVisitedCREditor = false
  15. @State private var hasVisitedPumpSettingsEditor = false
  16. @Environment(\.colorScheme) var colorScheme
  17. var color: LinearGradient {
  18. colorScheme == .dark ? LinearGradient(
  19. gradient: Gradient(colors: [
  20. Color.bgDarkBlue,
  21. Color.bgDarkerDarkBlue
  22. ]),
  23. startPoint: .top,
  24. endPoint: .bottom
  25. )
  26. :
  27. LinearGradient(
  28. gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
  29. startPoint: .top,
  30. endPoint: .bottom
  31. )
  32. }
  33. private var allViewsVisited: Bool {
  34. hasVisitedBasalProfileEditor &&
  35. hasVisitedISFEditor &&
  36. hasVisitedCREditor &&
  37. hasVisitedPumpSettingsEditor
  38. }
  39. var body: some View {
  40. NavigationStack {
  41. Form {
  42. Section(
  43. header: Text("Imported Nightscout Data"),
  44. content: {
  45. Text(
  46. "Trio has successfully imported your default Nightscout profile and stored it as therapy settings. "
  47. ) +
  48. Text("This has replaced your previous therapy settings.").bold().foregroundColor(.accentColor)
  49. Text("Please review the following settings:").bold()
  50. }
  51. ).listRowBackground(Color.chart)
  52. Section {
  53. NavigationLink(
  54. destination: BasalProfileEditor.RootView(resolver: resolver)
  55. .onDisappear { hasVisitedBasalProfileEditor = true }
  56. ) {
  57. HStack {
  58. Text("Basal Rates")
  59. if hasVisitedBasalProfileEditor {
  60. Image(systemName: "checkmark.circle.fill")
  61. .imageScale(.large)
  62. .fontWeight(.bold)
  63. .foregroundStyle(Color.green)
  64. }
  65. }.foregroundColor(hasVisitedBasalProfileEditor ? .secondary : .primary)
  66. }
  67. NavigationLink(
  68. destination: ISFEditor.RootView(resolver: resolver)
  69. .onDisappear { hasVisitedISFEditor = true }
  70. ) {
  71. HStack {
  72. Text("Insulin Sensitivities")
  73. if hasVisitedISFEditor {
  74. Image(systemName: "checkmark.circle.fill")
  75. .imageScale(.large)
  76. .fontWeight(.bold)
  77. .foregroundStyle(Color.green)
  78. }
  79. }.foregroundColor(hasVisitedISFEditor ? .secondary : .primary)
  80. }
  81. NavigationLink(
  82. destination: CarbRatioEditor.RootView(resolver: resolver)
  83. .onDisappear { hasVisitedCREditor = true }
  84. ) {
  85. HStack {
  86. Text("Carb Ratios")
  87. if hasVisitedCREditor {
  88. Image(systemName: "checkmark.circle.fill")
  89. .imageScale(.large)
  90. .fontWeight(.bold)
  91. .foregroundStyle(Color.green)
  92. }
  93. }.foregroundColor(hasVisitedCREditor ? .secondary : .primary)
  94. }
  95. NavigationLink(
  96. destination: ReviewInsulinActionView(resolver: resolver, state: state)
  97. .onDisappear { hasVisitedPumpSettingsEditor = true }
  98. ) {
  99. HStack {
  100. Text("Duration of Insulin Action (DIA)")
  101. if hasVisitedPumpSettingsEditor {
  102. Image(systemName: "checkmark.circle.fill")
  103. .imageScale(.large)
  104. .fontWeight(.bold)
  105. .foregroundStyle(Color.green)
  106. }
  107. }.foregroundColor(hasVisitedPumpSettingsEditor ? .secondary : .primary)
  108. }
  109. }.listRowBackground(Color.chart)
  110. Section {
  111. HStack {
  112. Button {
  113. state.isImportResultReviewPresented = false
  114. } label: {
  115. Text("Finish").font(.title3)
  116. }
  117. .disabled(!allViewsVisited)
  118. .frame(maxWidth: .infinity, alignment: .center)
  119. .tint(.white)
  120. }
  121. }.listRowBackground(allViewsVisited ? Color(.systemBlue) : Color(.systemGray4))
  122. }
  123. .navigationTitle("Review Import")
  124. .navigationBarTitleDisplayMode(.large)
  125. .scrollContentBackground(.hidden).background(color)
  126. .interactiveDismissDisabled(true)
  127. .screenNavigation(self)
  128. }
  129. }
  130. }