SensorAgeAlarmEditor.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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: String(localized: "Warn me before the sensor’s \(lifetimeDays)-day change-over."),
  19. alarmType: alarm.type
  20. )
  21. AlarmGeneralSection(alarm: $alarm)
  22. AlarmStepperSection(
  23. header: String(localized: "Sensor Lifetime"),
  24. footer: String(localized: "Number of days your CGM sensor lasts (e.g. 10 for Dexcom G6, 15 for G7 15-day)."),
  25. title: String(localized: "Lifetime"),
  26. range: 7 ... 15,
  27. step: 1,
  28. unitLabel: String(localized: "days"),
  29. value: lifetimeBinding
  30. )
  31. AlarmStepperSection(
  32. header: String(localized: "Early Reminder"),
  33. footer: String(localized: "Number of hours before the \(lifetimeDays)-day mark that the alert will fire."),
  34. title: String(localized: "Reminder Time"),
  35. range: 1 ... 24,
  36. step: 1,
  37. unitLabel: String(localized: "hours"),
  38. value: $alarm.threshold
  39. )
  40. AlarmActiveSection(alarm: $alarm)
  41. AlarmAudioSection(alarm: $alarm)
  42. AlarmSnoozeSection(alarm: $alarm)
  43. }
  44. }
  45. }