[O] CurrentAlarm should not be optional

This commit is contained in:
Hykilpikonna
2021-01-27 18:27:15 -05:00
parent ba0caaade3
commit b0c5a2f458
@@ -14,7 +14,7 @@ import AVFoundation
class AlarmActivationViewController: UIViewController class AlarmActivationViewController: UIViewController
{ {
var timer: Timer? var timer: Timer?
var currentAlarm: Alarm? var currentAlarm: Alarm
// Puzzle outlets // Puzzle outlets
@IBOutlet weak var puzzleView: UIView! @IBOutlet weak var puzzleView: UIView!
@@ -39,7 +39,6 @@ class AlarmActivationViewController: UIViewController
init?(coder: NSCoder, currentAlarm: Alarm) init?(coder: NSCoder, currentAlarm: Alarm)
{ {
self.currentAlarm = currentAlarm self.currentAlarm = currentAlarm
//print(currentAlarm.wakeMethod)
super.init(coder: coder) super.init(coder: coder)
} }
@@ -57,7 +56,7 @@ class AlarmActivationViewController: UIViewController
// Set the time and date // Set the time and date
dateLabel.text = Date().str("MMM d, Y") dateLabel.text = Date().str("MMM d, Y")
timeLabel.text = currentAlarm?.timeText timeLabel.text = currentAlarm.timeText
// Hide all inactive wakemethods // Hide all inactive wakemethods
puzzleView.hide() puzzleView.hide()
@@ -76,7 +75,7 @@ class AlarmActivationViewController: UIViewController
*/ */
@objc func playSound() @objc func playSound()
{ {
AudioServicesPlayAlertSound(currentAlarm!.alarmTone) AudioServicesPlayAlertSound(currentAlarm.alarmTone)
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
} }
@@ -85,24 +84,18 @@ class AlarmActivationViewController: UIViewController
*/ */
func runAlarm() func runAlarm()
{ {
if let alarm = currentAlarm
switch currentAlarm.wakeMethod.name
{ {
switch alarm.wakeMethod.name case "Factor":
{ initFactorProblem()
case "Factor": puzzleView.show()
initFactorProblem() case "RPS":
puzzleView.show() rpsView.show()
case "RPS": case "Shake":
rpsView.show() shakeView.show()
case "Shake": default:
shakeView.show() print("Invalid alarm type")
shakeAction()
if regulate {
endAlarm()
}
default:
print("Invalid alarm type")
}
} }
} }