OnboardingView+AlgorithmUtil.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. //
  2. // OnboardingView+AlgorithmUtil.swift
  3. // Trio
  4. //
  5. // Created by Cengiz Deniz on 15.04.25.
  6. //
  7. import SwiftUI
  8. protocol AlgorithmSubstepProtocol: Identifiable, RawRepresentable {
  9. var title: String { get }
  10. func hint(units: GlucoseUnits) -> String
  11. func description(units: GlucoseUnits) -> any View
  12. }
  13. extension AlgorithmSubstepProtocol {
  14. var title: String {
  15. AlgorithmSettingMeta(rawValue: String(describing: self))?.title ?? ""
  16. }
  17. func hint(units: GlucoseUnits) -> String {
  18. AlgorithmSettingMeta(rawValue: String(describing: self))?.hint(units: units) ?? ""
  19. }
  20. func description(units: GlucoseUnits) -> any View {
  21. AlgorithmSettingMeta(rawValue: String(describing: self))?.description(units: units) ?? AnyView(EmptyView())
  22. }
  23. }
  24. extension AlgorithmSubstepProtocol where Self: RawRepresentable, Self.RawValue == Int {
  25. func toAlgorithmSubstep() -> AlgorithmSettingsSubstep? {
  26. switch self {
  27. case let step as AutosensSettingsSubstep:
  28. return [
  29. .autosensMin,
  30. .autosensMax,
  31. .rewindResetsAutosens
  32. ][step.rawValue]
  33. case let step as SMBSettingsSubstep:
  34. return [
  35. .enableSMBAlways,
  36. .enableSMBWithCOB,
  37. .enableSMBWithTempTarget,
  38. .enableSMBAfterCarbs,
  39. .enableSMBWithHighGlucoseTarget,
  40. .allowSMBWithHighTempTarget,
  41. .enableUAM,
  42. .maxSMBMinutes,
  43. .maxUAMMinutes,
  44. .maxDeltaGlucoseThreshold
  45. ][step.rawValue]
  46. case let step as TargetBehaviorSubstep:
  47. return [
  48. .highTempTargetRaisesSensitivity,
  49. .lowTempTargetLowersSensitivity,
  50. .sensitivityRaisesTarget,
  51. .resistanceLowersTarget,
  52. .halfBasalTarget
  53. ][step.rawValue]
  54. default:
  55. return nil
  56. }
  57. }
  58. }
  59. extension View {
  60. func eraseToAnyView() -> AnyView {
  61. AnyView(self)
  62. }
  63. }
  64. enum AlgorithmSettingsOverviewSubstep: Int, CaseIterable, Identifiable {
  65. case contents
  66. case importantNotes
  67. var id: Int { rawValue }
  68. }
  69. enum AlgorithmSettingsSubstep: Int, CaseIterable, Identifiable {
  70. case autosensMin
  71. case autosensMax
  72. case rewindResetsAutosens
  73. case enableSMBAlways
  74. case enableSMBWithCOB
  75. case enableSMBWithTempTarget
  76. case enableSMBAfterCarbs
  77. case enableSMBWithHighGlucoseTarget
  78. case allowSMBWithHighTempTarget
  79. case enableUAM
  80. case maxSMBMinutes
  81. case maxUAMMinutes
  82. case maxDeltaGlucoseThreshold
  83. case highTempTargetRaisesSensitivity
  84. case lowTempTargetLowersSensitivity
  85. case sensitivityRaisesTarget
  86. case resistanceLowersTarget
  87. case halfBasalTarget
  88. var id: Int { rawValue }
  89. var title: String {
  90. switch self {
  91. case .autosensMin: return String(localized: "Autosens Minimum", comment: "Autosens Min")
  92. case .autosensMax: return String(localized: "Autosens Maximum", comment: "Autosens Max")
  93. case .rewindResetsAutosens: return String(localized: "Rewind Resets Autosens", comment: "Rewind Resets Autosens")
  94. case .enableSMBAlways: return String(localized: "Enable SMB Always", comment: "Enable SMB Always")
  95. case .enableSMBWithCOB: return String(localized: "Enable SMB With COB", comment: "Enable SMB With COB")
  96. case .enableSMBWithTempTarget: return String(
  97. localized: "Enable SMB With Temptarget",
  98. comment: "Enable SMB With Temptarget"
  99. )
  100. case .enableSMBAfterCarbs: return String(localized: "Enable SMB After Carbs", comment: "Enable SMB After Carbs")
  101. case .enableSMBWithHighGlucoseTarget: return String(
  102. localized: "Enable SMB With High Glucose",
  103. comment: "Enable SMB With High Glucose"
  104. )
  105. case .allowSMBWithHighTempTarget: return String(
  106. localized: "Allow SMB With High Temptarget",
  107. comment: "Allow SMB With High Temptarget"
  108. )
  109. case .enableUAM: return String(localized: "Enable UAM (Unannounced Meals)", comment: "Enable UAM")
  110. case .maxSMBMinutes: return String(localized: "Max SMB Basal Minutes", comment: "Max SMB Basal Minutes")
  111. case .maxUAMMinutes: return String(localized: "Max UAM Basal Minutes", comment: "Max UAM Basal Minutes")
  112. case .maxDeltaGlucoseThreshold: return String(
  113. localized: "Max. Allowed Glucose Rise for SMB",
  114. comment: "Max. Allowed Glucose Rise for SMB, formerly Max Delta-BG Threshold"
  115. )
  116. case .highTempTargetRaisesSensitivity: return String(
  117. localized: "High Temp Target Raises Sensitivity",
  118. comment: "High Temp Target Raises Sensitivity"
  119. )
  120. case .lowTempTargetLowersSensitivity: return String(
  121. localized:
  122. "Low Temp Target Lowers Sensitivity",
  123. comment: "Low Temp Target Lowers Sensitivity"
  124. )
  125. case .sensitivityRaisesTarget: return String(localized: "Sensitivity Raises Target", comment: "Sensitivity Raises Target")
  126. case .resistanceLowersTarget: return String(localized: "Resistance Lowers Target", comment: "Resistance Lowers Target")
  127. case .halfBasalTarget: return String(localized: "Half Basal Exercise Target", comment: "Half Basal Exercise Target")
  128. }
  129. }
  130. func hint(units: GlucoseUnits) -> String {
  131. switch self {
  132. case .autosensMin: return String(localized: "Lower limit of the Autosens Ratio.")
  133. case .autosensMax: return String(localized: "Upper limit of the Autosens Ratio.")
  134. case .rewindResetsAutosens: return String(localized: "Pump rewind initiates a reset in Autosens Ratio.")
  135. case .enableSMBAlways: return String(localized: "Allow SMBs at all times except when a high Temp Target is set.")
  136. case .enableSMBWithCOB: return String(localized: "Allow SMB when carbs are on board.")
  137. case .enableSMBWithTempTarget: return String(
  138. localized: "Allow SMB when a manual Temporary Target is set under \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue)."
  139. )
  140. case .enableSMBAfterCarbs: return String(localized: "Allow SMB for 6 hrs after a carb entry.")
  141. case .enableSMBWithHighGlucoseTarget: return String(localized: "Allow SMB when glucose is above the High Glucose Target value.")
  142. case .allowSMBWithHighTempTarget: return String(
  143. localized: "Allow SMB when a manual Temporary Target is set greater than \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue)."
  144. )
  145. case .enableUAM: return String(localized: "Enable Unannounced Meals SMB.")
  146. case .maxSMBMinutes: return String(localized: "Limits the size of a single Super Micro Bolus (SMB) dose.")
  147. case .maxUAMMinutes: return String(localized: "Limits the size of a single Unannounced Meal (UAM) SMB dose.")
  148. case .maxDeltaGlucoseThreshold: return String(localized: "Disables SMBs if last two glucose values differ by more than this percent.")
  149. case .highTempTargetRaisesSensitivity: return String(
  150. localized: "Increase sensitivity when glucose is above target if a manual Temp Target > \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) is set."
  151. )
  152. case .lowTempTargetLowersSensitivity: return String(
  153. localized: "Decrease sensitivity when glucose is below target if a manual Temp Target < \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) is set."
  154. )
  155. case .sensitivityRaisesTarget: return String(localized: "Raise target glucose when Autosens Ratio is less than 1.")
  156. case .resistanceLowersTarget: return String(localized: "Lower target glucose when Autosens Ratio is greater than 1.")
  157. case .halfBasalTarget: return String(localized: "Scales down your basal rate to 50% at this value.")
  158. }
  159. }
  160. func description(units: GlucoseUnits) -> any View {
  161. switch self {
  162. case .autosensMin:
  163. return VStack(alignment: .leading, spacing: 8) {
  164. Text("Default: 70%").bold().foregroundStyle(Color.primary)
  165. Text(
  166. "Autosens Min sets the minimum Autosens Ratio used by Autosens, Dynamic ISF, and Sigmoid Formula."
  167. )
  168. Text(
  169. "The Autosens Ratio is used to calculate the amount of adjustment needed to basal rates, ISF, and CR."
  170. )
  171. Text(
  172. "Tip: Decreasing this value allows automatic adjustments of basal rates to be lower, ISF to be higher, and CR to be higher."
  173. )
  174. }
  175. case .autosensMax:
  176. return VStack(alignment: .leading, spacing: 8) {
  177. Text("Default: 120%").bold().foregroundStyle(Color.primary)
  178. Text(
  179. "Autosens Max sets the maximum Autosens Ratio used by Autosens, Dynamic ISF, and Sigmoid Formula."
  180. )
  181. Text(
  182. "The Autosens Ratio is used to calculate the amount of adjustment needed to basal rates, ISF, and CR."
  183. )
  184. Text(
  185. "Tip: Increasing this value allows automatic adjustments of basal rates to be higher, ISF to be lower, and CR to be lower."
  186. )
  187. }
  188. case .rewindResetsAutosens:
  189. return VStack(alignment: .leading, spacing: 5) {
  190. Text("Default: ON").bold().foregroundStyle(Color.primary)
  191. Text("Medtronic and Dana Users Only").bold()
  192. VStack(alignment: .leading, spacing: 8) {
  193. Text(
  194. "This feature resets the Autosens Ratio to neutral when you rewind your pump on the assumption that this corresponds to a site change."
  195. )
  196. Text(
  197. "Autosens will begin learning sensitivity anew from the time of the rewind, which may take up to 6 hours."
  198. )
  199. Text(
  200. "Tip: If you usually rewind your pump independently of site changes, you may want to consider disabling this feature."
  201. )
  202. }
  203. }
  204. case .enableSMBAlways:
  205. return VStack(alignment: .leading, spacing: 8) {
  206. Text(
  207. "Enabling SMB Always will disable some of the subsequent \"Enable SMB\" options during Onboarding. These redundant options will be skipped."
  208. )
  209. .padding(.bottom)
  210. .foregroundStyle(Color.orange)
  211. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  212. Text(
  213. "When enabled, Super Micro Boluses (SMBs) will always be allowed if dosing calculations determine insulin is needed via the SMB delivery method, except when a high Temp Target is set."
  214. )
  215. Text(
  216. "Note: If you would like to allow SMBs when a high Temp Target is set, enable the \"Allow SMBs with High Temptarget\" setting."
  217. )
  218. }
  219. case .enableSMBWithCOB:
  220. return VStack(alignment: .leading, spacing: 8) {
  221. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  222. Text(
  223. "When the carb on board (COB) forecast line is active, enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required."
  224. )
  225. Text(
  226. "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
  227. )
  228. }
  229. case .enableSMBWithTempTarget:
  230. return VStack(alignment: .leading, spacing: 8) {
  231. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  232. Text(
  233. "Enabling this feature allows Trio to deliver insulin required using Super Micro Boluses (SMB) at times when a manual Temporary Target under \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) is set."
  234. )
  235. Text(
  236. "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
  237. )
  238. }
  239. case .enableSMBAfterCarbs:
  240. return VStack(alignment: .leading, spacing: 8) {
  241. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  242. Text(
  243. "Enabling this feature allows Trio to deliver insulin required using Super Micro Boluses (SMB) for 6 hours after a carb entry, regardless of whether there are active carbs on board (COB)."
  244. )
  245. Text(
  246. "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
  247. )
  248. }
  249. case .enableSMBWithHighGlucoseTarget:
  250. return VStack(alignment: .leading, spacing: 8) {
  251. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  252. Text(
  253. "Enabling this feature allows Trio to deliver insulin required using Super Micro Boluses (SMB) when glucose reading is above the value set as High Glucose Target."
  254. )
  255. Text(
  256. "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
  257. )
  258. }
  259. case .allowSMBWithHighTempTarget:
  260. return VStack(alignment: .leading, spacing: 8) {
  261. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  262. Text(
  263. "Enabling this feature allows Trio to deliver insulin required using Super Micro Boluses (SMB) when a manual Temporary Target above \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) is set."
  264. )
  265. Text(
  266. "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
  267. )
  268. Text(
  269. "Warning: High Temp Targets are often set when recovering from lows. If you use High Temp Targets for that purpose, this feature should remain disabled."
  270. ).bold()
  271. }
  272. case .enableUAM:
  273. return VStack(alignment: .leading, spacing: 8) {
  274. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  275. Text(
  276. "Enabling the UAM (Unannounced Meals) feature allows the system to detect and respond to unexpected rises in glucose readings caused by unannounced or miscalculated carbs, meals high in fat or protein, or other factors like adrenaline."
  277. )
  278. Text(
  279. "It uses the SMB (Super Micro Bolus) algorithm to deliver insulin in small amounts to correct glucose spikes. UAM also works in reverse, reducing or stopping SMBs if glucose levels drop unexpectedly."
  280. )
  281. Text(
  282. "This feature ensures more accurate insulin adjustments when carb entries are missing or incorrect."
  283. )
  284. }
  285. case .maxSMBMinutes:
  286. return VStack(spacing: 8) {
  287. VStack(alignment: .leading, spacing: 8) {
  288. Text("Default: 30 minutes").bold().foregroundStyle(Color.primary)
  289. Text("(50% current basal rate)")
  290. VStack(alignment: .leading, spacing: 8) {
  291. Text(
  292. "This is a limit on the size of a single SMB. One SMB can only be as large as this many minutes of your current profile basal rate."
  293. )
  294. Text(
  295. "To calculate the maximum SMB allowed based on this setting, use the following formula:"
  296. )
  297. }
  298. }
  299. VStack(alignment: .center, spacing: 5) {
  300. Text(
  301. "𝒳 = Max SMB Basal Minutes"
  302. )
  303. Text("(𝒳 / 60) × current basal rate")
  304. }
  305. VStack(alignment: .leading, spacing: 8) {
  306. Text(
  307. "Warning: Increasing this value above 90 minutes may impact Trio's ability to effectively zero temp and prevent lows."
  308. ).bold()
  309. Text("Note: SMBs must be enabled to use this limit.")
  310. }
  311. }
  312. case .maxUAMMinutes:
  313. return VStack(spacing: 8) {
  314. VStack(alignment: .leading, spacing: 8) {
  315. Text("Default: 30 minutes").bold().foregroundStyle(Color.primary)
  316. Text("(50% current basal rate)")
  317. VStack(alignment: .leading, spacing: 8) {
  318. Text(
  319. "This is a limit on the size of a single UAM SMB. One UAM SMB can only be as large as this many minutes of your current profile basal rate."
  320. )
  321. Text(
  322. "To calculate the maximum UAM SMB allowed based on this setting, use the following formula:"
  323. )
  324. }
  325. }
  326. VStack(alignment: .center, spacing: 5) {
  327. Text(
  328. "𝒳 = Max UAM SMB Basal Minutes"
  329. )
  330. Text("(𝒳 / 60) × current basal rate")
  331. }
  332. VStack(alignment: .leading, spacing: 8) {
  333. Text(
  334. "Warning: Increasing this value above 60 minutes may impact Trio's ability to effectively zero temp and prevent lows."
  335. ).bold()
  336. Text("Note: UAM SMBs must be enabled to use this limit.")
  337. }
  338. }
  339. case .maxDeltaGlucoseThreshold:
  340. return VStack(alignment: .leading, spacing: 8) {
  341. Text("Default: 20% increase").bold().foregroundStyle(Color.primary)
  342. Text(
  343. "Maximum allowed positive percent change in glucose level to permit SMBs. If the difference in glucose is greater than this, Trio will disable SMBs."
  344. )
  345. Text(
  346. "This is a safety limitation to avoid high SMB doses when glucose is rising abnormally fast, such as after a meal or with a very jumpy CGM sensor."
  347. )
  348. Text("Note: This setting has a hard-coded cap of 40%")
  349. }
  350. case .highTempTargetRaisesSensitivity:
  351. return VStack(alignment: .leading, spacing: 8) {
  352. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  353. Text(
  354. "When this feature is enabled, manually setting a temporary target above \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) will decrease the Autosens Ratio used for ISF and basal adjustments, resulting in less insulin delivered overall. This scales with the temporary target set; the higher the temp target, the lower the Autosens Ratio used."
  355. )
  356. Text(
  357. "If Half Basal Exercise Target is set to \(units == .mgdL ? "160" : 160.formattedAsMmolL) \(units.rawValue), a temp target of \(units == .mgdL ? "120" : 120.formattedAsMmolL) \(units.rawValue) uses an Autosens Ratio of 0.75. A temp target of \(units == .mgdL ? "140" : 140.formattedAsMmolL) \(units.rawValue) uses an Autosens Ratio of 0.6."
  358. )
  359. Text("Note: The effect of this can be adjusted with the Half Basal Exercise Target")
  360. }
  361. case .lowTempTargetLowersSensitivity:
  362. return VStack(alignment: .leading, spacing: 8) {
  363. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  364. Text(
  365. "When this feature is enabled, setting a temporary target below \(units == .mgdL ? "100" : 100.formattedAsMmolL) \(units.rawValue) will increase the Autosens Ratio used for ISF and basal adjustments, resulting in more insulin delivered overall. This scales with the temporary target set; the lower the Temp Target, the higher the Autosens Ratio used. It requires Algorithm Settings > Autosens > Autosens Max to be set to > 100% to work."
  366. )
  367. Text(
  368. "If Half Basal Exercise Target is \(units == .mgdL ? "160" : 160.formattedAsMmolL) \(units.rawValue), a Temp Target of \(units == .mgdL ? "95" : 95.formattedAsMmolL) \(units.rawValue) uses an Autosens Ratio of 1.09. A Temp Target of \(units == .mgdL ? "85" : 85.formattedAsMmolL) \(units.rawValue) uses an Autosens Ratio of 1.33."
  369. )
  370. Text("Note: The effect of this can be adjusted with the Half Basal Exercise Target")
  371. }
  372. case .sensitivityRaisesTarget:
  373. return VStack(alignment: .leading, spacing: 8) {
  374. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  375. Text(
  376. "Enabling this feature causes Trio to automatically raise the targeted glucose if it detects an increase in insulin sensitivity from your baseline."
  377. )
  378. }
  379. case .resistanceLowersTarget:
  380. return VStack(alignment: .leading, spacing: 8) {
  381. Text("Default: OFF").bold().foregroundStyle(Color.primary)
  382. Text(
  383. "Enabling this feature causes Trio to automatically reduce the targeted glucose if it detects a decrease in sensitivity (resistance) from your baseline."
  384. )
  385. }
  386. case .halfBasalTarget:
  387. return VStack(alignment: .leading, spacing: 8) {
  388. Text(
  389. "Default: \(units == .mgdL ? "160" : 160.formattedAsMmolL) \(units.rawValue)"
  390. )
  391. .bold().foregroundStyle(Color.primary)
  392. Text(
  393. "The Half Basal Exercise Target allows you to scale down your basal insulin during exercise or scale up your basal insulin when eating soon when a temporary glucose target is set."
  394. )
  395. Text(
  396. "For example, at a temp target of \(units == .mgdL ? "160" : 160.formattedAsMmolL) \(units.rawValue), your basal is reduced to 50%, but this scales depending on the target (e.g., 75% at \(units == .mgdL ? "120" : 120.formattedAsMmolL) \(units.rawValue), 60% at \(units == .mgdL ? "140" : 140.formattedAsMmolL) \(units.rawValue))."
  397. )
  398. Text(
  399. "Note: This setting is only utilized if the settings \"Low Temp Target Lowers Sensitivity\" OR \"High Temp Target Raises Sensitivity\" are enabled."
  400. )
  401. }
  402. }
  403. }
  404. init?(rawValue: String) {
  405. self.init(rawValue: AlgorithmSettingsSubstep.allCases.first { rawValue == "\($0)" }?.rawValue ?? -1)
  406. }
  407. }
  408. // MARK: - Algorithm Settings Substep Groups
  409. enum AutosensSettingsSubstep: Int, CaseIterable, Identifiable {
  410. case autosensMin
  411. case autosensMax
  412. case rewindResetsAutosens
  413. var id: Int { rawValue }
  414. }
  415. enum SMBSettingsSubstep: Int, CaseIterable, Identifiable {
  416. case enableSMBAlways
  417. case enableSMBWithCOB
  418. case enableSMBWithTempTarget
  419. case enableSMBAfterCarbs
  420. case enableSMBWithHighGlucoseTarget
  421. case allowSMBWithHighTempTarget
  422. case enableUAM
  423. case maxSMBMinutes
  424. case maxUAMMinutes
  425. case maxDeltaGlucoseThreshold
  426. var id: Int { rawValue }
  427. }
  428. enum TargetBehaviorSubstep: Int, CaseIterable, Identifiable {
  429. case highTempTargetRaisesSensitivity
  430. case lowTempTargetLowersSensitivity
  431. case sensitivityRaisesTarget
  432. case resistanceLowersTarget
  433. case halfBasalTarget
  434. var id: Int { rawValue }
  435. }
  436. extension AutosensSettingsSubstep: AlgorithmSubstepProtocol {}
  437. extension SMBSettingsSubstep: AlgorithmSubstepProtocol {}
  438. extension TargetBehaviorSubstep: AlgorithmSubstepProtocol {}
  439. // MARK: - Shared Metadata Helper
  440. enum AlgorithmSettingMeta: String {
  441. case autosensMin
  442. case autosensMax
  443. case rewindResetsAutosens
  444. case enableSMBAlways
  445. case enableSMBWithCOB
  446. case enableSMBWithTempTarget
  447. case enableSMBAfterCarbs
  448. case enableSMBWithHighGlucoseTarget
  449. case allowSMBWithHighTempTarget
  450. case enableUAM
  451. case maxSMBMinutes
  452. case maxUAMMinutes
  453. case maxDeltaGlucoseThreshold
  454. case highTempTargetRaisesSensitivity
  455. case lowTempTargetLowersSensitivity
  456. case sensitivityRaisesTarget
  457. case resistanceLowersTarget
  458. case halfBasalTarget
  459. var title: String {
  460. AlgorithmSettingsSubstep(rawValue: rawValue)?.title ?? ""
  461. }
  462. func hint(units: GlucoseUnits) -> String {
  463. AlgorithmSettingsSubstep(rawValue: rawValue)?.hint(units: units) ?? ""
  464. }
  465. func description(units: GlucoseUnits) -> any View {
  466. AlgorithmSettingsSubstep(rawValue: rawValue)?.description(units: units) ?? AnyView(EmptyView())
  467. }
  468. }