Merge branch 'main' into account

This commit is contained in:
Hykilpikonna
2021-01-23 23:26:03 -05:00
8 changed files with 394 additions and 38 deletions
+4
View File
@@ -23,6 +23,7 @@
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; };
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; };
C7E638E825B88F8B00799512 /* MathExpressions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7E638E725B88F8B00799512 /* MathExpressions.swift */; };
F0DF7C0725BCD9FC0064A26B /* StopwatchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0DF7C0625BCD9FC0064A26B /* StopwatchViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -46,6 +47,7 @@
7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = "<group>"; };
7C83963825AF68980027A94C /* TestingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingViewController.swift; sourceTree = "<group>"; };
C7E638E725B88F8B00799512 /* MathExpressions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MathExpressions.swift; sourceTree = "<group>"; };
F0DF7C0625BCD9FC0064A26B /* StopwatchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopwatchViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -92,6 +94,7 @@
4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */,
4FD642D225B48C380069171E /* AlarmActivator.swift */,
4FF0684425A5F18700304E6B /* Main.storyboard */,
F0DF7C0625BCD9FC0064A26B /* StopwatchViewController.swift */,
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
4F98955125A9260400F51321 /* Net.swift */,
4F509BD125AE22D100726227 /* Models.swift */,
@@ -187,6 +190,7 @@
4F98955225A9260400F51321 /* Net.swift in Sources */,
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */,
4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */,
F0DF7C0725BCD9FC0064A26B /* StopwatchViewController.swift in Sources */,
4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */,
4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */,
4FD642DB25B4B7F60069171E /* Utils.swift in Sources */,
@@ -13,12 +13,17 @@ class AlarmActivationViewController: UIViewController
var timer: Timer?
var currentAlarm: Alarm?
//Outlets
//Puzzle outlets
@IBOutlet weak var puzzleView: UIView!
@IBOutlet weak var puzzleQuestionLabel: UILabel!
@IBOutlet weak var puzzleAnswerInput: UITextField!
var puzzleAnswers: [Int] = []
//RPS Outlets
@IBOutlet weak var rpsView: UIView!
@IBOutlet weak var rpsResult: UILabel!
init?(coder: NSCoder, currentAlarm: Alarm)
{
self.currentAlarm = currentAlarm
@@ -35,6 +40,7 @@ class AlarmActivationViewController: UIViewController
super.viewDidLoad()
//Hide all inactive wakemethods
puzzleView.isHidden = true
rpsView.isHidden = true
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
setAlarmType()
@@ -61,6 +67,10 @@ class AlarmActivationViewController: UIViewController
puzzleView.isHidden = false
case "Smash":
print("")
case "RPS":
rpsView.isHidden = false
//Get Choice here
//rpsAction(choice: choice)
default:
print("Invalid alarm type")
}
@@ -78,6 +88,31 @@ class AlarmActivationViewController: UIViewController
}
}
//Gets RPS choice
@IBAction func rockChoice(_ sender: Any) {
if rpsAction(choice: .rock)! {
endAlarm()
} else {
rpsResult.text = "Paper: You lost, try again"
}
}
@IBAction func paperChoice(_ sender: Any) {
if rpsAction(choice: .paper)! {
endAlarm()
} else {
rpsResult.text = "Scissors: You lost, try again"
}
}
@IBAction func scissorChoice(_ sender: Any) {
if rpsAction(choice: .scissors)! {
endAlarm()
} else {
rpsResult.text = "Rock: You lost, try again"
}
}
//Standard way to turn off and close the alarm
func endAlarm() {
timer?.invalidate()
+206 -15
View File
@@ -4,6 +4,7 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -198,7 +199,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="240.57971014492756" y="868.52678571428567"/>
<point key="canvasLocation" x="897" y="869"/>
</scene>
<!--Debug-->
<scene sceneID="x23-kV-b5u">
@@ -268,7 +269,144 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mZu-oh-Lmb" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="952" y="869"/>
<point key="canvasLocation" x="1652" y="869"/>
</scene>
<!--Stopwatch-->
<scene sceneID="HUO-7o-NzS">
<objects>
<viewController id="PYt-Lf-JNp" customClass="StopwatchViewController" customModule="ProjectClock" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="wac-VZ-OTJ">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="51" translatesAutoresizingMaskIntoConstraints="NO" id="Apb-MM-jue">
<rect key="frame" x="20" y="89" width="374" height="714"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="34" translatesAutoresizingMaskIntoConstraints="NO" id="Lnz-vd-hkl">
<rect key="frame" x="0.0" y="0.0" width="374" height="60"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="54s-5X-INP">
<rect key="frame" x="0.0" y="0.0" width="100" height="60"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=":" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W12-19-4Jh">
<rect key="frame" x="134" y="0.0" width="10.5" height="60"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rpt-j6-UiB">
<rect key="frame" x="178.5" y="0.0" width="58.5" height="60"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=":" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rGI-kH-dgk">
<rect key="frame" x="271" y="0.0" width="10.5" height="60"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SdB-cz-eTv">
<rect key="frame" x="315.5" y="0.0" width="58.5" height="60"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="50"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="4j4-zF-LWF">
<rect key="frame" x="0.0" y="111" width="374" height="150"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jse-AL-cOs">
<rect key="frame" x="0.0" y="0.0" width="374" height="30"/>
<color key="backgroundColor" name="AccentColor"/>
<state key="normal" title="Start">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="start:" destination="PYt-Lf-JNp" eventType="touchUpInside" id="ucf-fN-SgP"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="O4A-eq-kEz">
<rect key="frame" x="0.0" y="40" width="374" height="30"/>
<color key="backgroundColor" name="AccentColor"/>
<state key="normal" title="Stop">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="stop:" destination="PYt-Lf-JNp" eventType="touchUpInside" id="ncg-GB-bAj"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Q7i-3U-NbI">
<rect key="frame" x="0.0" y="80" width="374" height="30"/>
<color key="backgroundColor" name="AccentColor"/>
<state key="normal" title="Reset">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="reset:" destination="PYt-Lf-JNp" eventType="touchUpInside" id="3ff-of-rJl"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="794-VN-m96">
<rect key="frame" x="0.0" y="120" width="374" height="30"/>
<color key="backgroundColor" name="AccentColor"/>
<state key="normal" title="Lap">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="lap:" destination="PYt-Lf-JNp" eventType="touchUpInside" id="UT9-pP-BWA"/>
</connections>
</button>
</subviews>
</stackView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="O7B-Tj-vT0">
<rect key="frame" x="0.0" y="312" width="374" height="402"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="lapCell" id="2Je-Lw-ZAb">
<rect key="frame" x="0.0" y="28" width="374" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="2Je-Lw-ZAb" id="HNi-3j-MIV">
<rect key="frame" x="0.0" y="0.0" width="374" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="PYt-Lf-JNp" id="HRZ-MF-SqM"/>
<outlet property="delegate" destination="PYt-Lf-JNp" id="uCp-Op-uuX"/>
</connections>
</tableView>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="0Lp-Fy-R0s"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="0Lp-Fy-R0s" firstAttribute="bottom" secondItem="Apb-MM-jue" secondAttribute="bottom" constant="10" id="4Rv-Vr-MaH"/>
<constraint firstItem="0Lp-Fy-R0s" firstAttribute="trailing" secondItem="Apb-MM-jue" secondAttribute="trailing" constant="20" id="ENw-M0-fRs"/>
<constraint firstItem="Apb-MM-jue" firstAttribute="top" secondItem="0Lp-Fy-R0s" secondAttribute="top" constant="45" id="RHG-Fs-SLZ"/>
<constraint firstItem="Apb-MM-jue" firstAttribute="leading" secondItem="0Lp-Fy-R0s" secondAttribute="leading" constant="20" id="l5v-Y0-GXP"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Stopwatch" image="clock.arrow.circlepath" catalog="system" selectedImage="clock.arrow.circlepath" id="hNc-UI-vIQ"/>
<connections>
<outlet property="hourLabel" destination="54s-5X-INP" id="Ugg-ul-ebm"/>
<outlet property="lapButton" destination="794-VN-m96" id="1aX-pS-Cjr"/>
<outlet property="minuteLabel" destination="rpt-j6-UiB" id="Qaf-xg-UCX"/>
<outlet property="resetButton" destination="Q7i-3U-NbI" id="gYT-DB-XpP"/>
<outlet property="secondLabel" destination="SdB-cz-eTv" id="syA-P8-NFX"/>
<outlet property="startButton" destination="Jse-AL-cOs" id="iq2-xE-Nir"/>
<outlet property="stopButton" destination="O4A-eq-kEz" id="dd7-v0-fqc"/>
<outlet property="tableView" destination="O7B-Tj-vT0" id="kfu-vG-sgE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ZlX-5W-Pjn" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="192.75362318840581" y="868.52678571428567"/>
</scene>
<!--Add Alarm View Controller-->
<scene sceneID="sJi-AZ-FUw">
@@ -507,19 +645,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Jan 17, Sunday" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="42Q-0v-ZS3">
<rect key="frame" x="20" y="152.5" width="374" height="25"/>
<rect key="frame" x="20" y="152.5" width="374" height="25.5"/>
<fontDescription key="fontDescription" type="system" pointSize="21"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Smash your phone to dismiss" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mjE-Hr-RIc">
<rect key="frame" x="95" y="410.5" width="224" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<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"/>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OMQ-qK-fej" userLabel="factorView">
<rect key="frame" x="20" y="249" 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">
@@ -548,6 +680,55 @@
</subviews>
<color key="backgroundColor" systemColor="systemGray6Color"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Smash your phone to dismiss" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mjE-Hr-RIc">
<rect key="frame" x="95.5" y="411" width="223.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NmX-iJ-1D0" userLabel="rpsView">
<rect key="frame" x="20" y="261" width="374" height="343"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" fixedFrame="YES" spacing="64" translatesAutoresizingMaskIntoConstraints="NO" id="213-rS-oYj">
<rect key="frame" x="19" y="134" width="336" height="42"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ndj-R4-AKk">
<rect key="frame" x="0.0" y="0.0" width="55" height="42"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Rock"/>
<connections>
<action selector="rockChoice:" destination="hDW-11-g9U" eventType="touchUpInside" id="w4O-MC-ohr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Iiv-Co-j8G">
<rect key="frame" x="119" y="0.0" width="62" height="42"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Paper"/>
<connections>
<action selector="paperChoice:" destination="hDW-11-g9U" eventType="touchUpInside" id="giR-wy-jqv"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="U4y-ls-yuK">
<rect key="frame" x="245" y="0.0" width="91" height="42"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Scissors"/>
<connections>
<action selector="scissorChoice:" destination="hDW-11-g9U" eventType="touchUpInside" id="BVu-ST-Hfr"/>
</connections>
</button>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="RPS: What do you choose?" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HEP-oh-VSY">
<rect key="frame" x="31" y="8" width="313" 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="systemGray4Color"/>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
@@ -566,11 +747,13 @@
<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"/>
<outlet property="rpsResult" destination="HEP-oh-VSY" id="W2G-eZ-mzI"/>
<outlet property="rpsView" destination="NmX-iJ-1D0" id="Rhg-Hm-2Xx"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="78q-sr-CNz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1700.0000000000002" y="1101.5625"/>
<point key="canvasLocation" x="2391" y="1102"/>
</scene>
<!--Alarm Activator-->
<scene sceneID="c7a-VN-D68">
@@ -587,6 +770,7 @@
<segue destination="BYZ-38-t0r" kind="relationship" relationship="viewControllers" destinationCreationSelector="Account" id="NN6-JO-Hmi"/>
<segue destination="r8W-6e-Hn2" kind="relationship" relationship="viewControllers" destinationCreationSelector="Testing" id="SLn-vq-UnH"/>
<segue destination="hDW-11-g9U" kind="showDetail" identifier="activate-alarm" destinationCreationSelector="sendAlarm:" id="z9o-Jh-fnM"/>
<segue destination="PYt-Lf-JNp" kind="relationship" relationship="viewControllers" id="uMq-nh-i7c"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="S6R-Xr-Nfe" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -679,7 +863,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="M0T-zq-vZ0" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="267" y="1325"/>
<point key="canvasLocation" x="949" y="1342"/>
</scene>
<!--ManageVC-->
<scene sceneID="jRZ-qD-YDj">
@@ -696,7 +880,7 @@
<rect key="frame" x="0.0" y="0.0" width="374" height="170"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="person.crop.circle.badge.checkmark" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="yVW-fL-SIQ">
<rect key="frame" x="130.5" y="0.0" width="111.5" height="109.5"/>
<rect key="frame" x="132" y="0.0" width="110" height="109.5"/>
<constraints>
<constraint firstAttribute="width" constant="110" id="So8-k5-nLS"/>
<constraint firstAttribute="height" constant="110" id="inA-vb-CrL"/>
@@ -764,22 +948,29 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pLc-eQ-yBW" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="267" y="1687"/>
<point key="canvasLocation" x="948" y="1676"/>
</scene>
</scenes>
<resources>
<image name="alarm.fill" catalog="system" width="124" height="128"/>
<image name="checkmark" catalog="system" width="128" height="114"/>
<image name="clock.arrow.circlepath" catalog="system" width="128" height="110"/>
<image name="hammer.fill" catalog="system" width="128" height="117"/>
<image name="person.crop.circle" catalog="system" width="128" height="121"/>
<image name="person.crop.circle.badge.checkmark" catalog="system" width="128" height="113"/>
<image name="trash.fill" catalog="system" width="121" height="128"/>
<namedColor name="AccentColor">
<color red="0.0" green="0.46000000000000002" blue="0.89000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGray4Color">
<color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray6Color">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
+13 -18
View File
@@ -163,10 +163,19 @@ class RPS {
case rock = "ROCK"
case paper = "PAPER"
case scissors = "SCISSORS"
static func randomComputerChoice() -> Choice {
let choices: [Choice] = [.rock, .paper, .scissors]
return choices[Int.random(in: 0...2)]
}
static func randomComputerChoice() -> Choice {
let choices: [Choice] = [.rock, .paper, .scissors]
return choices[Int.random(in: 0...2)]
}
func playRPS(you: Choice, computer: Choice) -> Bool? {
if you == .rock && computer == .scissors { return true }
else if you == .paper && computer == .rock { return true}
else if you == .scissors && computer == .paper { return true }
else {
return false
}
}
@@ -186,18 +195,4 @@ class RPS {
resultsLabel.text = playRPS(you: .scissors, computer: computerChoice)
}
*/
func playRPS(you: Choice, computer: Choice) -> Bool? {
if you == computer { return nil }
else if you == .rock && computer == .scissors { return true }
else if you == .paper && computer == .rock { return false}
else if you == .scissors && computer == .paper { return true }
else {
let randomNum = Int.random(in: 0...2)
if randomNum == 0 { return false }
// DO THESE RETURN THE RIGHT THING?
else if randomNum == 1 { return false}
else { return false }
}
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ struct WVM: Codable
let wvms = [
WVM(name: "Factor", desc: "Factor a binomial"),
WVM(name: "RPS", desc: "Win a game of rock paper scissors"),
WVM(name: "Smash", desc: "It'll never truns off"),
WVM(name: "Smash", desc: "It'll never turn off"),
WVM(name: "Walk", desc: "Walk a few steps"),
WVM(name: "Jump", desc: "Make a few jumps")
]
+4 -2
View File
@@ -15,10 +15,12 @@ func walkAction() {
}
func jumpAction() {
let rps = RPS()
}
func rpsAction() {
func rpsAction(choice: RPS.Choice) -> Bool? {
let rps = RPS()
return rps.playRPS(you: choice, computer: RPS.randomComputerChoice())
}
+129
View File
@@ -0,0 +1,129 @@
//
// StopwatchViewController.swift
// ProjectClock
//
// Created by Dallon Archibald on 1/23/21.
// Reference: https://youtu.be/H691qFRpaWA
import UIKit
class StopwatchViewController: UIViewController {
@IBOutlet weak var hourLabel: UILabel!
@IBOutlet weak var minuteLabel: UILabel!
@IBOutlet weak var secondLabel: UILabel!
@IBOutlet weak var startButton: UIButton!
@IBOutlet weak var stopButton: UIButton!
@IBOutlet weak var resetButton: UIButton!
@IBOutlet weak var lapButton: UIButton!
@IBOutlet weak var tableView: UITableView!
var hours = 0
var minutes = 0
var seconds = 0
var lappedTimes: [String] = []
var timer = Timer()
override func viewDidLoad() {
super.viewDidLoad()
//lapButton.isHidden = true
}
@IBAction func start(_ sender: UIButton) {
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(count), userInfo: nil, repeats: true)
//startButton.isHidden = true
//lapButton.isHidden = false
}
@objc fileprivate func count() {
seconds += 1
if seconds == 60 {
minutes += 1
seconds = 0
}
if minutes == 60 {
hours += 1
minutes = 0
}
if hours == 24 {
resetTimes()
}
if seconds >= 10 { secondLabel.text = "\(seconds)" }
else { secondLabel.text = "0\(seconds)" }
if minutes >= 10 { minuteLabel.text = "\(minutes)" }
else { minuteLabel.text = "0\(minutes)" }
if hours >= 10 { hourLabel.text = "\(hours)" }
else { hourLabel.text = "0\(hours)" }
}
@IBAction func stop(_ sender: UIButton) {
timer.invalidate()
//startButton.isHidden = false
}
@IBAction func reset(_ sender: UIButton) {
resetTimes()
}
func resetTimes() {
seconds = 0
minutes = 0
seconds = 0
lappedTimes = []
timer.invalidate()
secondLabel.text = "00"
minuteLabel.text = "00"
hourLabel.text = "00"
tableView.reloadData()
//startButton.isHidden = false
//lapButton.isHidden = true
}
@IBAction func lap(_ sender: UIButton) {
var currentSec = ""
if seconds >= 10 { currentSec = "\(seconds)" }
else { currentSec = "0\(seconds)" }
var currentMin = ""
if minutes >= 10 { currentMin = "\(minutes)" }
else { currentMin = "0\(minutes)" }
var currentHour = ""
if hours >= 10 { currentHour = "\(hours)" }
else { currentHour = "0\(hours)" }
let currentTime = "\(currentHour):\(currentMin):\(currentSec)" //CHECK THIS
lappedTimes.append(currentTime)
let indexPath = IndexPath(row: lappedTimes.count - 1, section: 0)
tableView.insertRows(at: [indexPath], with: .automatic)
}
}
extension StopwatchViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return lappedTimes.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "lapCell", for: indexPath)
cell.textLabel?.text = lappedTimes[indexPath.row]
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
lappedTimes.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
}
+1 -1
View File
@@ -58,7 +58,7 @@ class TestingViewController: UIViewController
@IBAction func addAlarm(_ sender: Any)
{
let (h, m, _) = Date().getHMS()
Alarms.fromLocal().apply { $0.list.append(Alarm(hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[0], repeats: [true, true, true, true, true, true, true], oneTime: true, lastActivate: Date().added(.minute, -1))) }.localSave()
Alarms.fromLocal().apply { $0.list.append(Alarm(hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[1], repeats: [true, true, true, true, true, true, true], oneTime: true, lastActivate: Date().added(.minute, -1))) }.localSave()
}
@IBAction func deleteAlarm(_ sender: Any)