FastRiseAlarmEditor.swift 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // FastRiseAlarmEditor.swift
  3. // LoopFollow
  4. //
  5. // Created by Jonas Björkert on 2025-05-15.
  6. // Copyright © 2025 Jon Fawcett. All rights reserved.
  7. //
  8. import SwiftUI
  9. struct FastRiseAlarmEditor: View {
  10. @Binding var alarm: Alarm
  11. var body: some View {
  12. Form {
  13. InfoBanner(
  14. text: "Alerts when glucose readings rise rapidly. For example, "
  15. + "three straight readings each climbing by at least the amount "
  16. + "you set. Optionally limit alerts to only fire above a certain BG.",
  17. alarmType: alarm.type
  18. )
  19. AlarmGeneralSection(alarm: $alarm)
  20. AlarmBGSection(
  21. header: "Rate of Rise",
  22. footer: "How much the BG must rise to count as a “fast” rise.",
  23. title: "Rise per reading",
  24. range: 3 ... 20,
  25. value: Binding(
  26. get: { alarm.delta ?? 3 },
  27. set: { alarm.delta = $0 }
  28. )
  29. )
  30. AlarmStepperSection(
  31. header: "Consecutive Rises",
  32. footer: "Number of rises—each meeting the rate above—"
  33. + "required before an alert fires.",
  34. title: "Rises in a row",
  35. range: 1 ... 3,
  36. step: 1,
  37. value: Binding(
  38. get: { Double(alarm.monitoringWindow ?? 2) },
  39. set: { alarm.monitoringWindow = Int($0) }
  40. )
  41. )
  42. AlarmBGLimitSection(
  43. header: "BG Limit",
  44. footer: "When enabled, this alert only fires if the glucose is "
  45. + "above the limit you set.",
  46. toggleText: "Use BG Limit",
  47. pickerTitle: "Rising above",
  48. range: 40 ... 300,
  49. value: $alarm.aboveBG
  50. )
  51. AlarmActiveSection(alarm: $alarm)
  52. AlarmAudioSection(alarm: $alarm)
  53. AlarmSnoozeSection(alarm: $alarm, range: 5 ... 60, step: 5)
  54. }
  55. .navigationTitle(alarm.type.rawValue)
  56. }
  57. }