LoopStatusHelpView.swift 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import SwiftUI
  2. struct LoopStatusHelpView: View {
  3. @Environment(AppState.self) var appState
  4. @Environment(\.colorScheme) var colorScheme
  5. var state: Home.StateModel
  6. var helpSheetDetent: Binding<PresentationDetent>
  7. var isHelpSheetPresented: Binding<Bool>
  8. var body: some View {
  9. NavigationStack {
  10. VStack(alignment: .leading) {
  11. Text(
  12. "The oref algorithm provides recommendations, showing key variables, decisions on temporary basal rates or super-micro-boluses, and a 'reason' field explaining its actions. Find all key terms of this 'reason' explained below:"
  13. )
  14. .font(.subheadline)
  15. .foregroundColor(.secondary)
  16. .padding(.top, 50)
  17. List {
  18. DefinitionRow(
  19. term: String(localized: "Autosens Ratio"),
  20. definition: Text(
  21. "The ratio of how sensitive or resistant to insulin you are in the current loop cycle. Baseline = 1.0, Sensitive < 1.0, Resistant > 1.0"
  22. ),
  23. color: .insulin
  24. ).listRowBackground(Color.gray.opacity(0.1))
  25. DefinitionRow(
  26. term: String(localized: "ISF"),
  27. definition: Text(
  28. "The first value is your profile Insulin Sensitivity Factor (ISF). The second value, after the arrow, is your adjusted ISF used for the most recent automated dosing calculation."
  29. ),
  30. color: .insulin
  31. ).listRowBackground(Color.gray.opacity(0.1))
  32. DefinitionRow(
  33. term: String(localized: "COB"),
  34. definition: Text(
  35. "Amount of Carbs on Board (COB) used in the most recent automated dosing calculation."
  36. ),
  37. color: .insulin
  38. ).listRowBackground(Color.gray.opacity(0.1))
  39. DefinitionRow(
  40. term: String(localized: "Dev"),
  41. definition: Text(
  42. "Abbreviation for 'Deviation'. How much the actual glucose change deviated from the BGI."
  43. ),
  44. color: .insulin
  45. ).listRowBackground(Color.gray.opacity(0.1))
  46. DefinitionRow(
  47. term: String(localized: "BGI"),
  48. definition: Text(
  49. "The degree to which your glucose should be rising or falling based solely on insulin activity."
  50. ),
  51. color: .insulin
  52. ).listRowBackground(Color.gray.opacity(0.1))
  53. DefinitionRow(
  54. term: String(localized: "CR"),
  55. definition: Text(
  56. "The first value is your profile Carb Ratio (CR). The second value, after the arrow, is your adjusted CR used for the most recent automated dosing calculation."
  57. ),
  58. color: .insulin
  59. ).listRowBackground(Color.gray.opacity(0.1))
  60. DefinitionRow(
  61. term: String(localized: "Target"),
  62. definition: Text(
  63. "The first value is your target glucose from your settings. The second value, after the arrow, is your adjusted target glucose used for the most recent automated dosing calculation. A second value is shown if you have a temp target, override, or one of the Target Behavior options enabled."
  64. ),
  65. color: .insulin
  66. ).listRowBackground(Color.gray.opacity(0.1))
  67. DefinitionRow(
  68. term: String(localized: "minPredBG"),
  69. definition: Text(
  70. "The lowest forecasted value that Trio has estimated for your future glucose."
  71. ),
  72. color: .insulin
  73. ).listRowBackground(Color.gray.opacity(0.1))
  74. DefinitionRow(
  75. term: String(localized: "minGuardBG"),
  76. definition: Text(
  77. "The lowest forecasted glucose during the remaining duration of insulin action (DIA)."
  78. ),
  79. color: .insulin
  80. ).listRowBackground(Color.gray.opacity(0.1))
  81. DefinitionRow(
  82. term: String(localized: "IOBpredBG"),
  83. definition: Text(
  84. "The forecasted glucose value in 4 hours calculated based on IOB only."
  85. ),
  86. color: .insulin
  87. ).listRowBackground(Color.gray.opacity(0.1))
  88. DefinitionRow(
  89. term: String(localized: "COBpredBG"),
  90. definition: Text(
  91. "The forecasted glucose value in 4 hours calculated based on current IOB and COB."
  92. ),
  93. color: .insulin
  94. ).listRowBackground(Color.gray.opacity(0.1))
  95. DefinitionRow(
  96. term: String(localized: "UAMpredBG"),
  97. definition: Text(
  98. "The forecasted glucose value in 4 hours based on current deviations ramping down to zero at the same rate they have been recently."
  99. ),
  100. color: .insulin
  101. ).listRowBackground(Color.gray.opacity(0.1))
  102. DefinitionRow(
  103. term: String(localized: "TDD"),
  104. definition: Text(
  105. "Abbreviation for 'Total Daily Dose'. Last 24 hours of total insulin administered, both basal and bolus."
  106. ),
  107. color: .zt
  108. ).listRowBackground(Color.gray.opacity(0.1))
  109. DefinitionRow(
  110. term: String(localized: "Bolus/Basal %"),
  111. definition: Text(
  112. "Of the total insulin delivered in the past 24 hours, this indicates what percentage was administered through basals and what was given through bolus."
  113. ),
  114. color: .green
  115. ).listRowBackground(Color.gray.opacity(0.1))
  116. DefinitionRow(
  117. term: String(localized: "Dynamic ISF/CR"),
  118. definition: Text(
  119. "A display of On/On indicates both Dynamic ISF and CR are enabled. On/Off indicates only Dynamic ISF is enabled. Dynamic CR cannot be enabled when Dynamic ISF is disabled."
  120. ),
  121. color: .zt
  122. ).listRowBackground(Color.gray.opacity(0.1))
  123. DefinitionRow(
  124. term: String(localized: "Sigmoid function"),
  125. definition: Text("If shown, Sigmoid Dynamic ISF is enabled."),
  126. color: .zt
  127. ).listRowBackground(Color.gray.opacity(0.1))
  128. DefinitionRow(
  129. term: String(localized: "Logarithmic formula"),
  130. definition: Text("If shown, Logarithmic Dynamic ISF is enabled."),
  131. color: .zt
  132. ).listRowBackground(Color.gray.opacity(0.1))
  133. DefinitionRow(
  134. term: String(localized: "AF"),
  135. definition: Text(
  136. "Displays the Adjustment Factor (AF) for either Logathmic or Sigmoid Dynamic ISF in use."
  137. ),
  138. color: .zt
  139. ).listRowBackground(Color.gray.opacity(0.1))
  140. DefinitionRow(
  141. term: String(localized: "SMB Ratio"),
  142. definition: Text(
  143. "SMB Delivery Ratio of calculated insulin required that is given as SMB."
  144. ),
  145. color: .zt
  146. ).listRowBackground(Color.gray.opacity(0.1))
  147. DefinitionRow(
  148. term: String(localized: "Smoothing"),
  149. definition: Text("Indicates glucose smoothing is enabled."),
  150. color: .gray
  151. ).listRowBackground(Color.gray.opacity(0.1))
  152. }
  153. .scrollContentBackground(.hidden)
  154. .navigationBarTitle("Glossary", displayMode: .inline)
  155. .padding(.bottom, 15)
  156. Button {
  157. isHelpSheetPresented.wrappedValue.toggle()
  158. } label: {
  159. Text("Got it!").bold().frame(maxWidth: .infinity, minHeight: 30, alignment: .center)
  160. }
  161. .buttonStyle(.bordered)
  162. .padding(.top)
  163. }
  164. .padding([.horizontal, .bottom])
  165. .listSectionSpacing(10)
  166. .ignoresSafeArea(edges: .top)
  167. .presentationDetents(
  168. [.fraction(0.9), .large],
  169. selection: helpSheetDetent
  170. )
  171. }
  172. }
  173. var legendLinesView: some View {
  174. Group {
  175. DefinitionRow(
  176. term: String(localized: "IOB (Insulin on Board)"),
  177. definition: Text(
  178. "Forecasts future glucose readings based on the amount of insulin still active in the body."
  179. ),
  180. color: .insulin
  181. )
  182. DefinitionRow(
  183. term: String(localized: "ZT (Zero-Temp)"),
  184. definition: Text(
  185. "Forecasts the worst-case future glucose reading scenario if no carbs are absorbed and insulin delivery is stopped until glucose starts rising."
  186. ),
  187. color: .zt
  188. )
  189. DefinitionRow(
  190. term: String(localized: "COB (Carbs on Board)"),
  191. definition: Text(
  192. "Forecasts future glucose reading changes by considering the amount of carbohydrates still being absorbed in the body."
  193. ),
  194. color: .loopYellow
  195. )
  196. DefinitionRow(
  197. term: String(localized: "UAM (Unannounced Meal)"),
  198. definition: Text(
  199. "Forecasts future glucose levels and insulin dosing needs for unexpected meals or other causes of glucose reading increases without prior notice."
  200. ),
  201. color: .uam
  202. )
  203. }
  204. }
  205. var legendConeOfUncertaintyView: some View {
  206. DefinitionRow(
  207. term: String(localized: "Cone of Uncertainty"),
  208. definition: VStack(alignment: .leading, spacing: 10) {
  209. Text(
  210. "For simplicity reasons, oref's various forecast curves are displayed as a \"Cone of Uncertainty\" that depicts a possible, forecasted range of future glucose fluctuation based on the current data and the algothim's result."
  211. )
  212. Text(
  213. "To modify how the forecast is displayed, go to Settings > Features > User Interface > Forecast Display Type."
  214. )
  215. },
  216. color: Color.blue.opacity(0.5)
  217. )
  218. }
  219. }