NightscoutImportResultView.swift 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. @Environment(AppState.self) var appState
  18. private var allViewsVisited: Bool {
  19. hasVisitedBasalProfileEditor &&
  20. hasVisitedISFEditor &&
  21. hasVisitedCREditor &&
  22. hasVisitedPumpSettingsEditor
  23. }
  24. var body: some View {
  25. NavigationStack {
  26. Form {
  27. Section(
  28. header: Text("Imported Nightscout Data"),
  29. content: {
  30. Text(
  31. "Trio has successfully imported your default Nightscout profile and stored it as therapy settings. "
  32. ) +
  33. Text("This has replaced your previous therapy settings.").bold().foregroundColor(.accentColor)
  34. Text("Please review the following settings:").bold()
  35. }
  36. ).listRowBackground(Color.chart)
  37. Section {
  38. NavigationLink(
  39. destination: BasalProfileEditor.RootView(resolver: resolver)
  40. .onDisappear { hasVisitedBasalProfileEditor = true }
  41. ) {
  42. HStack {
  43. Text("Basal Rates")
  44. if hasVisitedBasalProfileEditor {
  45. Image(systemName: "checkmark.circle.fill")
  46. .imageScale(.large)
  47. .fontWeight(.bold)
  48. .foregroundStyle(Color.green)
  49. }
  50. }.foregroundColor(hasVisitedBasalProfileEditor ? .secondary : .primary)
  51. }
  52. NavigationLink(
  53. destination: ISFEditor.RootView(resolver: resolver)
  54. .onDisappear { hasVisitedISFEditor = true }
  55. ) {
  56. HStack {
  57. Text("Insulin Sensitivities")
  58. if hasVisitedISFEditor {
  59. Image(systemName: "checkmark.circle.fill")
  60. .imageScale(.large)
  61. .fontWeight(.bold)
  62. .foregroundStyle(Color.green)
  63. }
  64. }.foregroundColor(hasVisitedISFEditor ? .secondary : .primary)
  65. }
  66. NavigationLink(
  67. destination: CarbRatioEditor.RootView(resolver: resolver)
  68. .onDisappear { hasVisitedCREditor = true }
  69. ) {
  70. HStack {
  71. Text("Carb Ratios")
  72. if hasVisitedCREditor {
  73. Image(systemName: "checkmark.circle.fill")
  74. .imageScale(.large)
  75. .fontWeight(.bold)
  76. .foregroundStyle(Color.green)
  77. }
  78. }.foregroundColor(hasVisitedCREditor ? .secondary : .primary)
  79. }
  80. NavigationLink(
  81. destination: ReviewInsulinActionView(resolver: resolver, state: state)
  82. .onDisappear { hasVisitedPumpSettingsEditor = true }
  83. ) {
  84. HStack {
  85. Text("Duration of Insulin Action (DIA)")
  86. if hasVisitedPumpSettingsEditor {
  87. Image(systemName: "checkmark.circle.fill")
  88. .imageScale(.large)
  89. .fontWeight(.bold)
  90. .foregroundStyle(Color.green)
  91. }
  92. }.foregroundColor(hasVisitedPumpSettingsEditor ? .secondary : .primary)
  93. }
  94. }.listRowBackground(Color.chart)
  95. Section {
  96. HStack {
  97. Button {
  98. state.isImportResultReviewPresented = false
  99. } label: {
  100. Text("Finish").font(.title3)
  101. }
  102. .disabled(!allViewsVisited)
  103. .frame(maxWidth: .infinity, alignment: .center)
  104. .tint(.white)
  105. }
  106. }.listRowBackground(allViewsVisited ? Color(.systemBlue) : Color(.systemGray4))
  107. }
  108. .navigationTitle("Review Import")
  109. .navigationBarTitleDisplayMode(.large)
  110. .scrollContentBackground(.hidden)
  111. .background(appState.trioBackgroundColor(for: colorScheme))
  112. .interactiveDismissDisabled(true)
  113. .screenNavigation(self)
  114. }
  115. }
  116. }