Skip to content

Commit

Permalink
Changed snoozing from hours to minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorkert committed May 5, 2024
1 parent c2f9bab commit f28a7b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LoopFollow/Controllers/Alarms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ extension MainViewController {
AlarmSound.whichAlarm = "Rec. Bolus"

if UserDefaultsRepository.alertRecBolusRepeat.value { numLoops = -1 }
triggerAlarm(sound: UserDefaultsRepository.alertRecBolusSound.value, snooozedBGReadingTime: nil, overrideVolume: UserDefaultsRepository.overrideSystemOutputVolume.value, numLoops: numLoops, snoozeTime: UserDefaultsRepository.alertRecBolusSnoozeHours.value, snoozeIncrement: 1, audio: true)
triggerAlarm(sound: UserDefaultsRepository.alertRecBolusSound.value, snooozedBGReadingTime: nil, overrideVolume: UserDefaultsRepository.overrideSystemOutputVolume.value, numLoops: numLoops, snoozeTime: UserDefaultsRepository.alertRecBolusSnooze.value, snoozeIncrement: 5, audio: true)
return
}
}
Expand Down
15 changes: 7 additions & 8 deletions LoopFollow/ViewControllers/AlarmViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3303,20 +3303,19 @@ class AlarmViewController: FormViewController {
guard let value = row.value else { return }
UserDefaultsRepository.alertRecBolusLevel.value = value
}

<<< StepperRow("alertRecBolusSnoozeHours") { row in
row.title = "Snooze Hours"
row.cell.stepper.stepValue = 1
row.cell.stepper.minimumValue = 1
row.cell.stepper.maximumValue = 24
row.value = Double(UserDefaultsRepository.alertRecBolusSnoozeHours.value)
<<< StepperRow("alertRecBolusSnooze") { row in
row.title = "Default Snooze"
row.cell.stepper.stepValue = 5
row.cell.stepper.minimumValue = 5
row.cell.stepper.maximumValue = 60
row.value = Double(UserDefaultsRepository.alertRecBolusSnooze.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.alertRecBolusSnoozeHours.value = Int(value)
UserDefaultsRepository.alertRecBolusSnooze.value = Int(value)
}
<<< PickerInputRow<String>("alertRecBolusSound") { row in
row.title = "Sound"
Expand Down
4 changes: 2 additions & 2 deletions LoopFollow/ViewControllers/SnoozeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ class SnoozeViewController: UIViewController, UNUserNotificationCenterDelegate {
} else if AlarmSound.whichAlarm == "Rec. Bolus" {
UserDefaultsRepository.alertRecBolusIsSnoozed.value = true

UserDefaultsRepository.alertRecBolusSnoozedTime.value = Date().addingTimeInterval(TimeInterval(snoozeForMinuteStepper.value * 60 * 60))
UserDefaultsRepository.alertRecBolusSnoozedTime.value = Date().addingTimeInterval(TimeInterval(snoozeForMinuteStepper.value * 60))
guard let alarms = self.tabBarController!.viewControllers?[1] as? AlarmViewController else { return }
alarms.reloadIsSnoozed(key: "alertRecBolusIsSnoozed", value: true)
alarms.reloadSnoozeTime(key: "alertRecBolusSnoozedTime", setNil: false, value: Date().addingTimeInterval(TimeInterval(snoozeForMinuteStepper.value * 60 * 60)))
alarms.reloadSnoozeTime(key: "alertRecBolusSnoozedTime", setNil: false, value: Date().addingTimeInterval(TimeInterval(snoozeForMinuteStepper.value * 60)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/repository/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class UserDefaultsRepository {
static let alertRecBolusSound = UserDefaultsValue<String>(key: "alertRecBolusSound", default: "Dhol_Shuffleloop")
static let alertRecBolusRepeat = UserDefaultsValue<Bool>(key: "alertRecBolusRepeat", default: false)
static let alertRecBolusIsSnoozed = UserDefaultsValue<Bool>(key: "alertRecBolusIsSnoozed", default: false)
static let alertRecBolusSnooze = UserDefaultsValue<Int>(key: "alertRecBolusSnooze", default: 5)
static let alertRecBolusSnoozedTime = UserDefaultsValue<Date?>(key: "alertRecBolusSnoozedTime", default: nil)
static let alertRecBolusSnoozeHours = UserDefaultsValue<Int>(key: "alertRecBolusSnoozeHours", default: 1)
static var deviceRecBolus: UserDefaultsValue<Double> = UserDefaultsValue(key: "deviceRecBolus", default: 0.0)
}

0 comments on commit f28a7b4

Please sign in to comment.