// LoopFollow
// NotLoopingAlarmEditor.swift

import SwiftUI

struct NotLoopingAlarmEditor: View {
    @Binding var alarm: Alarm

    private let bgRange: ClosedRange<Double> = 40 ... 300

    var body: some View {
        Group {
            InfoBanner(
                text: String(localized: "Alerts when no successful loop has occurred for the time you set below."), alarmType: alarm.type
            )

            AlarmGeneralSection(alarm: $alarm)

            AlarmStepperSection(
                header: String(localized: "No Loop for…"),
                footer: String(localized: "Number of minutes since the last successful loop. When this time has elapsed, the alarm becomes eligible."),
                title: String(localized: "Elapsed time"),
                range: 16 ... 61,
                step: 5,
                unitLabel: alarm.type.snoozeTimeUnit.label,
                value: $alarm.threshold
            )

            AlarmBGLimitSection(
                header: String(localized: "Low Limit"),
                footer: String(localized: "Alert only if BG is equal to or below this value."),
                toggleText: String(localized: "Enable low limit"),
                pickerTitle: String(localized: "Below"),
                range: bgRange,
                defaultOnValue: 100,
                value: $alarm.belowBG
            )

            AlarmBGLimitSection(
                header: String(localized: "High Limit"),
                footer: String(localized: "Alert only if BG is equal to or above this value."),
                toggleText: String(localized: "Enable high limit"),
                pickerTitle: String(localized: "Above"),
                range: bgRange,
                defaultOnValue: 160,
                value: $alarm.aboveBG
            )

            AlarmActiveSection(alarm: $alarm)
            AlarmAudioSection(alarm: $alarm)
            AlarmSnoozeSection(alarm: $alarm)
        }
    }
}
