FastDropAlarmEditor.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // LoopFollow
  2. // FastDropAlarmEditor.swift
  3. // Created by Jonas Björkert on 2025-05-11.
  4. import SwiftUI
  5. struct FastDropAlarmEditor: View {
  6. @Binding var alarm: Alarm
  7. @State private var useLimit: Bool = false
  8. var body: some View {
  9. Form {
  10. InfoBanner(
  11. text: "Alerts when glucose readings drop rapidly. For example, three straight readings each falling by at least the amount you set. Optionally limit alerts to only fire below a certain BG level."
  12. )
  13. AlarmGeneralSection(alarm: $alarm)
  14. AlarmBGSection(
  15. header: "Rate of Fall",
  16. footer: "This is how much the glucose must drop to be considered a fast drop.",
  17. title: "Falls by",
  18. range: 3 ... 54,
  19. value: Binding(
  20. get: { alarm.delta ?? 18 }, // This value is not used, the default value is set on the alarm
  21. set: { alarm.delta = $0 }
  22. )
  23. )
  24. AlarmStepperSection(
  25. header: "Consecutive Drops",
  26. footer: "Number of drops—each meeting the rate above—required before an alert fires.",
  27. title: "Number of Drops",
  28. range: 1 ... 3,
  29. step: 1,
  30. value: $alarm.monitoringWindow
  31. )
  32. AlarmBGLimitSection(
  33. header: "BG Limit",
  34. footer: "When enabled, this alert only fires if the glucose is below the limit you set.",
  35. toggleText: "Use BG Limit",
  36. pickerTitle: "Dropping below",
  37. range: 40 ... 300,
  38. defaultOnValue: 120,
  39. value: $alarm.belowBG
  40. )
  41. AlarmActiveSection(alarm: $alarm)
  42. AlarmAudioSection(alarm: $alarm)
  43. AlarmSnoozeSection(alarm: $alarm)
  44. }
  45. .navigationTitle(alarm.type.rawValue)
  46. }
  47. }