[+] Add comments to AlarmActivationViewController
This commit is contained in:
@@ -8,28 +8,34 @@
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
|
||||
/**
|
||||
View controlling alarm activation and dismissal
|
||||
*/
|
||||
class AlarmActivationViewController: UIViewController
|
||||
{
|
||||
var timer: Timer?
|
||||
var currentAlarm: Alarm?
|
||||
|
||||
//Puzzle outlets
|
||||
// Puzzle outlets
|
||||
@IBOutlet weak var puzzleView: UIView!
|
||||
@IBOutlet weak var puzzleQuestionLabel: UILabel!
|
||||
@IBOutlet weak var puzzleAnswerInput: UITextField!
|
||||
var puzzleAnswers: [Int] = []
|
||||
|
||||
//RPS Outlets
|
||||
// RPS Outlets
|
||||
@IBOutlet weak var rpsView: UIView!
|
||||
@IBOutlet weak var rpsResult: UILabel!
|
||||
|
||||
//Shake Outlets
|
||||
// Shake Outlets
|
||||
@IBOutlet weak var shakeView: UIView!
|
||||
|
||||
//Other Outlets
|
||||
// Other Outlets
|
||||
@IBOutlet weak var timeLabel: UILabel!
|
||||
@IBOutlet weak var dateLabel: UILabel!
|
||||
|
||||
/**
|
||||
Constructor to receive alarm data from segue
|
||||
*/
|
||||
init?(coder: NSCoder, currentAlarm: Alarm)
|
||||
{
|
||||
self.currentAlarm = currentAlarm
|
||||
@@ -37,10 +43,14 @@ class AlarmActivationViewController: UIViewController
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
/**
|
||||
Unused init
|
||||
*/
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
/**
|
||||
Called when the alarm activates
|
||||
*/
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
@@ -61,19 +71,26 @@ class AlarmActivationViewController: UIViewController
|
||||
runAlarm()
|
||||
}
|
||||
|
||||
/**
|
||||
Play alarm sound
|
||||
*/
|
||||
@objc func playSound()
|
||||
{
|
||||
AudioServicesPlayAlertSound(currentAlarm!.alarmTone)
|
||||
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
|
||||
}
|
||||
|
||||
/**
|
||||
Run alarm dismissal logic
|
||||
*/
|
||||
func runAlarm()
|
||||
{
|
||||
|
||||
|
||||
if let alarm = currentAlarm
|
||||
{
|
||||
switch alarm.wakeMethod.name {
|
||||
switch alarm.wakeMethod.name
|
||||
{
|
||||
case "Walk":
|
||||
walkAction()
|
||||
case "Jump":
|
||||
@@ -99,7 +116,9 @@ class AlarmActivationViewController: UIViewController
|
||||
}
|
||||
}
|
||||
|
||||
//Verfies and ends factoring WVM
|
||||
/**
|
||||
Verfies and ends factoring WVM
|
||||
*/
|
||||
@IBAction func checkBinomialSolution(_ sender: Any) {
|
||||
if let input = puzzleAnswerInput.text {
|
||||
if let numericalInput = Int(input) {
|
||||
@@ -110,7 +129,9 @@ class AlarmActivationViewController: UIViewController
|
||||
}
|
||||
}
|
||||
|
||||
//Gets RPS choice
|
||||
/**
|
||||
Gets RPS choice
|
||||
*/
|
||||
@IBAction func rockChoice(_ sender: Any) {
|
||||
if rpsAction(choice: .rock)! {
|
||||
endAlarm()
|
||||
@@ -118,7 +139,6 @@ class AlarmActivationViewController: UIViewController
|
||||
rpsResult.text = "Paper: You lost, try again"
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func paperChoice(_ sender: Any) {
|
||||
if rpsAction(choice: .paper)! {
|
||||
endAlarm()
|
||||
@@ -134,10 +154,11 @@ class AlarmActivationViewController: UIViewController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Standard way to turn off and close the alarm
|
||||
func endAlarm() {
|
||||
/**
|
||||
Standard way to turn off and close the alarm
|
||||
*/
|
||||
func endAlarm()
|
||||
{
|
||||
timer?.invalidate()
|
||||
print("Alarm solved")
|
||||
dismiss(animated: true, completion: nil)
|
||||
|
||||
Reference in New Issue
Block a user