Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
066dc2b386 | ||
|
|
6aff162426 | ||
|
|
0640f65746 | ||
|
|
34741d614e | ||
|
|
97fc9d92c3 | ||
|
|
34ba756807 | ||
|
|
990ab4d897 | ||
|
|
3387d557c5 | ||
|
|
3187886ab1 | ||
|
|
13128d5152 | ||
|
|
2e74e12cb0 | ||
|
|
0312806ea9 | ||
|
|
7928e2d70d | ||
|
|
b566021273 |
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
@@ -13,7 +13,6 @@
|
||||
16C2E9412266302E00C8FA04 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16C2E93F2266302E00C8FA04 /* LaunchScreen.storyboard */; };
|
||||
16C2E94C2266302E00C8FA04 /* Project308Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16C2E94B2266302E00C8FA04 /* Project308Tests.swift */; };
|
||||
16C2E9572266302E00C8FA04 /* Project308UITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16C2E9562266302E00C8FA04 /* Project308UITests.swift */; };
|
||||
D712DAC82271F43B008E73D8 /* AlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D712DAC72271F43B008E73D8 /* AlarmViewController.swift */; };
|
||||
D745B592226A512500C85F2A /* StopWatchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D745B591226A512500C85F2A /* StopWatchViewController.swift */; };
|
||||
D745B594226A55EF00C85F2A /* TimerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D745B593226A55EF00C85F2A /* TimerViewController.swift */; };
|
||||
D7A41CAA227009750094886D /* WorldClockViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 169F53B8226A243700546074 /* WorldClockViewController.swift */; };
|
||||
@@ -50,7 +49,6 @@
|
||||
16C2E9522266302E00C8FA04 /* Project308UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Project308UITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
16C2E9562266302E00C8FA04 /* Project308UITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Project308UITests.swift; sourceTree = "<group>"; };
|
||||
16C2E9582266302E00C8FA04 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D712DAC72271F43B008E73D8 /* AlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmViewController.swift; sourceTree = "<group>"; };
|
||||
D745B591226A512500C85F2A /* StopWatchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopWatchViewController.swift; sourceTree = "<group>"; };
|
||||
D745B593226A55EF00C85F2A /* TimerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerViewController.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -104,11 +102,10 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
16C2E9362266302E00C8FA04 /* AppDelegate.swift */,
|
||||
169F53B8226A243700546074 /* WorldClockViewController.swift */,
|
||||
D745B591226A512500C85F2A /* StopWatchViewController.swift */,
|
||||
D745B593226A55EF00C85F2A /* TimerViewController.swift */,
|
||||
D712DAC72271F43B008E73D8 /* AlarmViewController.swift */,
|
||||
16C2E93A2266302E00C8FA04 /* Main.storyboard */,
|
||||
169F53B8226A243700546074 /* WorldClockViewController.swift */,
|
||||
16C2E93D2266302E00C8FA04 /* Assets.xcassets */,
|
||||
16C2E93F2266302E00C8FA04 /* LaunchScreen.storyboard */,
|
||||
16C2E9422266302E00C8FA04 /* Info.plist */,
|
||||
@@ -265,7 +262,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D712DAC82271F43B008E73D8 /* AlarmViewController.swift in Sources */,
|
||||
D7A41CAA227009750094886D /* WorldClockViewController.swift in Sources */,
|
||||
D745B592226A512500C85F2A /* StopWatchViewController.swift in Sources */,
|
||||
D745B594226A55EF00C85F2A /* TimerViewController.swift in Sources */,
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// AlarmViewController.swift
|
||||
// Project308
|
||||
//
|
||||
// Created by Davis, Timothy A. on 4/25/19.
|
||||
// Copyright © 2019 Helton, Aaron S. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class AlarmViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -25,11 +25,40 @@
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l0r-dF-pdB">
|
||||
<rect key="frame" x="0.0" y="141" width="375" height="162"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="Qye-JV-Pqh" id="02w-lm-Z9W"/>
|
||||
<outlet property="delegate" destination="Qye-JV-Pqh" id="m1q-dS-MSb"/>
|
||||
</connections>
|
||||
</pickerView>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fgz-0X-Yzp">
|
||||
<rect key="frame" x="169" y="585" width="36" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Clear"/>
|
||||
<connections>
|
||||
<action selector="clearPressed:" destination="Qye-JV-Pqh" eventType="touchUpInside" id="k3c-P9-NUQ"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="k0f-EI-Kte">
|
||||
<rect key="frame" x="170" y="491" width="34" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Start"/>
|
||||
<connections>
|
||||
<action selector="startStopPressed:" destination="Qye-JV-Pqh" eventType="touchUpInside" id="0V3-fL-bco"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<viewLayoutGuide key="safeArea" id="cf5-pJ-AmR"/>
|
||||
</view>
|
||||
<tabBarItem key="tabBarItem" title="Timer" id="btY-Uw-RMI"/>
|
||||
<connections>
|
||||
<outlet property="startStopButton" destination="k0f-EI-Kte" id="OT6-bi-f84"/>
|
||||
<outlet property="timeLabel" destination="SOV-8m-KXd" id="hM0-Ka-UhC"/>
|
||||
<outlet property="timePicker" destination="l0r-dF-pdB" id="VFa-sJ-uik"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Mav-Yg-pGe" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
@@ -184,25 +213,6 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-130.40000000000001" y="-560.09852216748766"/>
|
||||
</scene>
|
||||
<!--Alarm-->
|
||||
<scene sceneID="nfI-d8-z44">
|
||||
<objects>
|
||||
<viewController id="Yix-zb-nSS" customClass="AlarmViewController" customModule="Project308" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="dPH-7l-OY1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<accessibility key="accessibilityConfiguration">
|
||||
<bool key="isElement" value="YES"/>
|
||||
</accessibility>
|
||||
<viewLayoutGuide key="safeArea" id="kfW-9n-dhJ"/>
|
||||
</view>
|
||||
<tabBarItem key="tabBarItem" title="Alarm" id="dtk-9h-BZq"/>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="7y4-nt-dcy" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="823" y="-562"/>
|
||||
</scene>
|
||||
<!--Tab Bar Controller-->
|
||||
<scene sceneID="UeV-jl-WCT">
|
||||
<objects>
|
||||
@@ -216,7 +226,6 @@
|
||||
<segue destination="IVq-r8-MM7" kind="relationship" relationship="viewControllers" id="W8Z-YI-Va4"/>
|
||||
<segue destination="Qye-JV-Pqh" kind="relationship" relationship="viewControllers" id="8F1-z2-RlH"/>
|
||||
<segue destination="Gtu-61-Naf" kind="relationship" relationship="viewControllers" id="Xze-lT-3SH"/>
|
||||
<segue destination="Yix-zb-nSS" kind="relationship" relationship="viewControllers" id="MRM-WC-Sou"/>
|
||||
</connections>
|
||||
</tabBarController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="mw0-IS-Rh3" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
||||
@@ -8,7 +8,132 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class TimerViewController: UIViewController {
|
||||
class TimerViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {
|
||||
var hour = 0.0
|
||||
var minute = 0.0
|
||||
var second = 0.0
|
||||
var time = 0.0
|
||||
|
||||
|
||||
@IBAction func clearPressed(_ sender: UIButton) {
|
||||
hour = 0.0
|
||||
minute = 0.0
|
||||
second = 0.0
|
||||
time = 0.0
|
||||
elapsedTime = 0.0
|
||||
timeLabel.text = "00:00:00"
|
||||
timePicker.isHidden = false
|
||||
timePicker.reloadAllComponents()
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
@IBAction func startStopPressed(_ sender: UIButton) {
|
||||
if isRunning == false {
|
||||
isRunning = true
|
||||
timePicker.isHidden = true
|
||||
startStopButton.setTitle("Stop", for: UIControl.State.normal)
|
||||
timeLoop()
|
||||
}
|
||||
else{
|
||||
isRunning = false
|
||||
timePicker.isHidden = false
|
||||
timePicker.reloadAllComponents()
|
||||
startStopButton.setTitle("Start", for: UIControl.State.normal)
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet weak var startStopButton: UIButton!
|
||||
|
||||
@IBOutlet weak var timeLabel: UILabel!
|
||||
|
||||
@IBOutlet weak var timePicker: UIPickerView!
|
||||
|
||||
|
||||
|
||||
func numberOfComponents(in pickerView: UIPickerView) -> Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
|
||||
if component == 0{
|
||||
return 99
|
||||
}
|
||||
else{
|
||||
return 60
|
||||
}
|
||||
}
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
|
||||
return "\(row)"
|
||||
}
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
|
||||
hour = Double(timePicker.selectedRow(inComponent: 0))
|
||||
minute = Double(timePicker.selectedRow(inComponent: 1))
|
||||
second = Double(timePicker.selectedRow(inComponent: 2))
|
||||
time = hour*3600 + minute*60 + second
|
||||
let timeString = "\(timePicker.selectedRow(inComponent: 0)):\(timePicker.selectedRow(inComponent: 1)):\(timePicker.selectedRow(inComponent: 2))"
|
||||
timeLabel.text! = timeString
|
||||
}
|
||||
|
||||
var isRunning = false
|
||||
var elapsedTime = 0.0
|
||||
|
||||
func timeLoop() {
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
var currentTime = Date()
|
||||
var previousTime = currentTime
|
||||
|
||||
while(self.isRunning) {
|
||||
currentTime = Date()
|
||||
self.elapsedTime += currentTime.timeIntervalSince(previousTime)
|
||||
previousTime = currentTime
|
||||
|
||||
let hours = Int((self.time-self.elapsedTime))/3600
|
||||
let minutes = (Int((self.time-self.elapsedTime))%3600)/60
|
||||
let seconds = (Int((self.time-self.elapsedTime))%3600)%60
|
||||
|
||||
|
||||
|
||||
let hourStr = String.init(format: "%d", hours)
|
||||
let minuteStr = String.init(format: "%02d", minutes)
|
||||
let secondsStr = String.init(format: "%02d", seconds)
|
||||
let timeString = "\(hourStr):\(minuteStr):\(secondsStr)"
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.timeLabel.text! = timeString
|
||||
}
|
||||
|
||||
if hours == 0 && minutes == 0 && seconds == 0{
|
||||
let alertController = UIAlertController(title: "TIME IS UP",
|
||||
message: "YOUR TIMER IS OVER",
|
||||
preferredStyle: UIAlertController.Style.alert)
|
||||
|
||||
let defaultAction = UIAlertAction(title: "STOP BEING LAZY",
|
||||
style: UIAlertAction.Style.cancel,
|
||||
handler: nil)
|
||||
|
||||
// add the buttons into the alert controller object
|
||||
alertController.addAction(defaultAction)
|
||||
|
||||
// display
|
||||
self.present(alertController, animated: true, completion: nil)
|
||||
|
||||
self.finish()
|
||||
self.isRunning = false
|
||||
}
|
||||
|
||||
usleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func finish(){
|
||||
elapsedTime = 0
|
||||
startStopButton.setTitle("Start", for: UIControl.State.normal)
|
||||
timePicker.isHidden = false
|
||||
timePicker.reloadAllComponents()
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@@ -16,7 +141,9 @@ class TimerViewController: UIViewController {
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user