NightscoutImportResultView.swift 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 applied it as therapy settings. This has replaced your previous therapy settings."
  47. )
  48. Text("Please review the following settings:").bold()
  49. }
  50. ).listRowBackground(Color.chart)
  51. Section {
  52. NavigationLink(
  53. destination: BasalProfileEditor.RootView(resolver: resolver)
  54. .onDisappear { hasVisitedBasalProfileEditor = true }
  55. ) {
  56. HStack {
  57. Text("Basal Rates")
  58. if hasVisitedBasalProfileEditor {
  59. Image(systemName: "checkmark.circle.fill")
  60. .imageScale(.large)
  61. .fontWeight(.bold)
  62. .foregroundStyle(Color.green)
  63. }
  64. }.foregroundColor(hasVisitedBasalProfileEditor ? .secondary : .primary)
  65. }
  66. NavigationLink(
  67. destination: ISFEditor.RootView(resolver: resolver)
  68. .onDisappear { hasVisitedISFEditor = true }
  69. ) {
  70. HStack {
  71. Text("Insulin Sensitivities")
  72. if hasVisitedISFEditor {
  73. Image(systemName: "checkmark.circle.fill")
  74. .imageScale(.large)
  75. .fontWeight(.bold)
  76. .foregroundStyle(Color.green)
  77. }
  78. }.foregroundColor(hasVisitedISFEditor ? .secondary : .primary)
  79. }
  80. NavigationLink(
  81. destination: CarbRatioEditor.RootView(resolver: resolver)
  82. .onDisappear { hasVisitedCREditor = true }
  83. ) {
  84. HStack {
  85. Text("Carb Ratios")
  86. if hasVisitedCREditor {
  87. Image(systemName: "checkmark.circle.fill")
  88. .imageScale(.large)
  89. .fontWeight(.bold)
  90. .foregroundStyle(Color.green)
  91. }
  92. }.foregroundColor(hasVisitedCREditor ? .secondary : .primary)
  93. }
  94. NavigationLink(
  95. destination: ReviewInsulinActionView(resolver: resolver, state: state)
  96. .onDisappear { hasVisitedPumpSettingsEditor = true }
  97. ) {
  98. HStack {
  99. Text("Duration of Insulin Action (DIA)")
  100. if hasVisitedPumpSettingsEditor {
  101. Image(systemName: "checkmark.circle.fill")
  102. .imageScale(.large)
  103. .fontWeight(.bold)
  104. .foregroundStyle(Color.green)
  105. }
  106. }.foregroundColor(hasVisitedPumpSettingsEditor ? .secondary : .primary)
  107. }
  108. }.listRowBackground(Color.chart)
  109. Section {
  110. HStack {
  111. Button {
  112. state.isImportResultReviewPresented = false
  113. } label: {
  114. Text("Finish").font(.title3)
  115. }
  116. .disabled(!allViewsVisited)
  117. .frame(maxWidth: .infinity, alignment: .center)
  118. .tint(.white)
  119. }
  120. }.listRowBackground(allViewsVisited ? Color(.systemBlue) : Color(.systemGray4))
  121. }
  122. // .toolbar(content: {
  123. // ToolbarItem(placement: .topBarLeading) {
  124. // Button(action: { state.isImportResultReviewPresented = false }, label: {
  125. // Text("Cancel")
  126. // })
  127. // }
  128. // })
  129. .navigationTitle("Review Import")
  130. .navigationBarTitleDisplayMode(.large)
  131. .scrollContentBackground(.hidden).background(color)
  132. .interactiveDismissDisabled(true)
  133. .screenNavigation(self)
  134. }
  135. }
  136. }