Integrating PuzzleWakeMethod (1/2)
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,6 +639,36 @@
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OMQ-qK-fej" userLabel="PuzzleAlarm">
|
||||
<rect key="frame" x="20" y="261" width="374" height="343"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Solve: " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CZ0-R6-FDq">
|
||||
<rect key="frame" x="39" y="35" width="300" height="33"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="27"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eTb-g7-8x3">
|
||||
<rect key="frame" x="39" y="154" width="309" height="34"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" textContentType="cc-number"/>
|
||||
<connections>
|
||||
<action selector="checkPuzzleSolution:" destination="hDW-11-g9U" eventType="editingChanged" id="nuZ-mN-UR3"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Input 1 answer:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vHe-pz-8w2">
|
||||
<rect key="frame" x="39" y="113" width="174" height="33"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="27"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemGray6Color"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
@@ -653,10 +683,15 @@
|
||||
<constraint firstItem="hS6-fS-yWp" firstAttribute="trailing" secondItem="vmg-Oj-8tB" secondAttribute="trailing" constant="20" id="vVE-ID-dgj"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="puzzleAnswerInput" destination="eTb-g7-8x3" id="xIh-TJ-vhq"/>
|
||||
<outlet property="puzzleQuestionLabel" destination="CZ0-R6-FDq" id="gon-N6-XTD"/>
|
||||
<outlet property="puzzleView" destination="OMQ-qK-fej" id="KLT-oe-RJX"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="78q-sr-CNz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1701" y="1102"/>
|
||||
<point key="canvasLocation" x="1700.0000000000002" y="1101.5625"/>
|
||||
</scene>
|
||||
<!--Alarm Activator-->
|
||||
<scene sceneID="c7a-VN-D68">
|
||||
@@ -692,6 +727,9 @@
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemGray6Color">
|
||||
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemOrangeColor">
|
||||
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user