Dynamically sets time until alarm during addition.

This commit is contained in:
Aaron
2021-01-24 16:27:15 -05:00
parent 599fc8a125
commit b758087a96
2 changed files with 23 additions and 0 deletions
+19
View File
@@ -26,6 +26,7 @@ class AddAlarmViewController: UIViewController
@IBOutlet weak var repeatWeekdaysSwitch: UISwitch!
@IBOutlet weak var repeatWeekendsSwitch: UISwitch!
@IBOutlet weak var alarmNameTextField: UITextField!
@IBOutlet weak var timeTillAlarmLabel: UILabel!
@IBAction func defaultRingtonesButton(_ sender: Any)
{
@@ -37,6 +38,24 @@ class AddAlarmViewController: UIViewController
}
/**
Called when the time for the alarm is changed.
Sets the time away at the top of the View.
*/
@IBAction func alarmTimeUpdated(_ sender: Any) {
//Create alarm without adding it to the queue.
let (h, m, _) = timePicker.date.getHMS()
// Create the alarm
let a = Alarm(hour: h, minute: m,
text: alarmNameTextField.text ?? "Alarm",
wakeMethod: wvms[wvmPicker.selectedRow(inComponent: 0)],
lastActivate: Date())
var timeTill = a.nextActivate!.timeIntervalSince(Date()).str()
print(timeTill)
timeTillAlarmLabel.text = "Going off in \(timeTill)"
}
/**
Called when the user clicks the remove button and brings them back to the home page
*/