diff --git a/ProjectClock/AlarmActivationViewController.swift b/ProjectClock/AlarmActivationViewController.swift
index 3e24a79..bad2d6f 100644
--- a/ProjectClock/AlarmActivationViewController.swift
+++ b/ProjectClock/AlarmActivationViewController.swift
@@ -13,6 +13,12 @@ class AlarmActivationViewController: UIViewController
var timer: Timer?
var currentAlarm: Alarm?
+ //Outlets
+ @IBOutlet weak var puzzleView: UIView!
+ @IBOutlet weak var puzzleQuestionLabel: UILabel!
+ @IBOutlet weak var puzzleAnswerInput: UITextField!
+ var puzzleAnswers: [Int] = []
+
init?(coder: NSCoder, currentAlarm: Alarm)
{
self.currentAlarm = currentAlarm
@@ -27,6 +33,9 @@ class AlarmActivationViewController: UIViewController
override func viewDidLoad()
{
super.viewDidLoad()
+ //Hide all inactive wakemethods
+ puzzleView.isHidden = true
+
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
setAlarmType()
print(MathExpression.random())
@@ -48,7 +57,8 @@ class AlarmActivationViewController: UIViewController
case "Jump":
jumpAction()
case "Puzzle":
- puzzleAction()
+ self.puzzleAnswers = puzzleAction(puzzleQuestionLabel: puzzleQuestionLabel)
+ puzzleView.isHidden = false
case "Smash":
print("")
default:
@@ -56,4 +66,10 @@ class AlarmActivationViewController: UIViewController
}
}
}
+
+ @IBAction func checkPuzzleSolution(_ sender: Any) {
+ if puzzleAnswers.contains(Int(puzzleAnswerInput.text!)!) {
+ print("alarm solved")
+ }
+ }
}
diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard
index b7099d7..98e9ab2 100644
--- a/ProjectClock/Base.lproj/Main.storyboard
+++ b/ProjectClock/Base.lproj/Main.storyboard
@@ -639,6 +639,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -653,10 +683,15 @@
+
+
+
+
+
-
+
@@ -692,6 +727,9 @@
+
+
+
diff --git a/ProjectClock/NotificationLogic.swift b/ProjectClock/NotificationLogic.swift
index 2f06fe5..8738f7d 100644
--- a/ProjectClock/NotificationLogic.swift
+++ b/ProjectClock/NotificationLogic.swift
@@ -8,6 +8,7 @@
import Foundation
import CoreMotion
import UserNotifications
+import UIKit
let motionManager = CMMotionManager()
@@ -27,14 +28,15 @@ func jumpAction() {
}
-func puzzleAction() {
+func puzzleAction(puzzleQuestionLabel: UILabel) -> [Int] {
var problem = QuadraticProb()
let answer = problem.getAnswer()
let problemString = problem.getProblem()
- print("Problem: \(problemString)")
+ puzzleQuestionLabel.text = "Solve: \(problemString)"
print("Answer: \(answer)")
+ return answer
}
func smashAction() {