|
|
@@ -339,7 +339,7 @@ class AlarmViewController: FormViewController {
|
|
|
|
|
|
<<< SegmentedRow<String>("otherAlerts3"){ row in
|
|
|
row.title = ""
|
|
|
- row.options = ["IOB", "COB"]
|
|
|
+ row.options = ["IOB", "COB", "Battery"]
|
|
|
if UserDefaultsRepository.url.value == "" {
|
|
|
row.hidden = true
|
|
|
}
|
|
|
@@ -389,6 +389,7 @@ class AlarmViewController: FormViewController {
|
|
|
|
|
|
buildIOB()
|
|
|
buildCOB()
|
|
|
+ buildBatteryAlarm()
|
|
|
|
|
|
buildSnoozeAll()
|
|
|
buildAlarmSettings()
|
|
|
@@ -3178,6 +3179,56 @@ class AlarmViewController: FormViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func buildBatteryAlarm(){
|
|
|
+ form
|
|
|
+ +++ Section(header: "Battery Alarm", footer: "Activates a notification alert whenever the battery level drops below a user-defined threshold, allowing for proactive device charging and power management.") { row in
|
|
|
+ row.hidden = "$otherAlerts3 != 'Battery'"
|
|
|
+ }
|
|
|
+ <<< SwitchRow("alertBatteryActive"){ row in
|
|
|
+ row.title = "Active"
|
|
|
+ row.value = UserDefaultsRepository.alertBatteryActive.value
|
|
|
+ }.onChange { [weak self] row in
|
|
|
+ guard let value = row.value else { return }
|
|
|
+ UserDefaultsRepository.alertBatteryActive.value = value
|
|
|
+ }
|
|
|
+ <<< StepperRow("alertBatteryLevel") { row in
|
|
|
+ row.title = "Battery Level"
|
|
|
+ row.cell.stepper.stepValue = 5
|
|
|
+ row.cell.stepper.minimumValue = 0
|
|
|
+ row.cell.stepper.maximumValue = 100
|
|
|
+ row.value = Double(UserDefaultsRepository.alertBatteryLevel.value)
|
|
|
+ row.displayValueFor = { value in
|
|
|
+ guard let value = value else { return nil }
|
|
|
+ return "\(Int(value))%"
|
|
|
+ }
|
|
|
+ }.onChange { [weak self] row in
|
|
|
+ guard let value = row.value else { return }
|
|
|
+ UserDefaultsRepository.alertBatteryLevel.value = Int(value)
|
|
|
+ }
|
|
|
+ <<< PickerInputRow<String>("alertBatterySound") { row in
|
|
|
+ row.title = "Sound"
|
|
|
+ row.options = soundFiles
|
|
|
+ row.value = UserDefaultsRepository.alertBatterySound.value
|
|
|
+ row.displayValueFor = { value in
|
|
|
+ guard let value = value else { return nil }
|
|
|
+ return "\(String(value.replacingOccurrences(of: "_", with: " ")))"
|
|
|
+ }
|
|
|
+ }.onChange { [weak self] row in
|
|
|
+ guard let value = row.value else { return }
|
|
|
+ UserDefaultsRepository.alertBatterySound.value = value
|
|
|
+ AlarmSound.setSoundFile(str: value)
|
|
|
+ AlarmSound.stop()
|
|
|
+ AlarmSound.playTest()
|
|
|
+ }
|
|
|
+ <<< SwitchRow("alertBatteryRepeat"){ row in
|
|
|
+ row.title = "Repeat Sound"
|
|
|
+ row.value = UserDefaultsRepository.alertBatteryRepeat.value
|
|
|
+ }.onChange { [weak self] row in
|
|
|
+ guard let value = row.value else { return }
|
|
|
+ UserDefaultsRepository.alertBatteryRepeat.value = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
func buildAlarmSettings() {
|
|
|
form
|
|
|
+++ Section(header: "Alarm Settings", footer: "")
|