SensorAgeAlarmEditor.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // LoopFollow
  2. // SensorAgeAlarmEditor.swift
  3. import SwiftUI
  4. struct SensorAgeAlarmEditor: View {
  5. @Binding var alarm: Alarm
  6. private var lifetimeDays: Int {
  7. alarm.sensorLifetimeDays ?? 10
  8. }
  9. private var lifetimeBinding: Binding<Int?> {
  10. Binding(
  11. get: { alarm.sensorLifetimeDays ?? 10 },
  12. set: { alarm.sensorLifetimeDays = $0 }
  13. )
  14. }
  15. var body: some View {
  16. Group {
  17. InfoBanner(
  18. text: "Warn me before the sensor’s \(lifetimeDays)-day change-over.",
  19. alarmType: alarm.type
  20. )
  21. AlarmGeneralSection(alarm: $alarm)
  22. AlarmStepperSection(
  23. header: "Sensor Lifetime",
  24. footer: "Number of days your CGM sensor lasts " +
  25. "(e.g. 10 for Dexcom G6, 15 for G7 15-day).",
  26. title: "Lifetime",
  27. range: 7 ... 15,
  28. step: 1,
  29. unitLabel: "days",
  30. value: lifetimeBinding
  31. )
  32. AlarmStepperSection(
  33. header: "Early Reminder",
  34. footer: "Number of hours before the \(lifetimeDays)-day mark that the alert " +
  35. "will fire.",
  36. title: "Reminder Time",
  37. range: 1 ... 24,
  38. step: 1,
  39. unitLabel: "hours",
  40. value: $alarm.threshold
  41. )
  42. AlarmActiveSection(alarm: $alarm)
  43. AlarmAudioSection(alarm: $alarm)
  44. AlarmSnoozeSection(alarm: $alarm)
  45. }
  46. }
  47. }