Skip to content

Commit

Permalink
edit layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Pattarasai Markpeng authored and Pattarasai Markpeng committed Oct 15, 2018
1 parent 226a2d9 commit f95e71c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "micky-mouse-gesture/ViewController.swift"
timestampString = "561257252.685322"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "39"
endingLineNumber = "39"
landmarkName = "touchesBegan(_:with:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "micky-mouse-gesture/ViewController.swift"
timestampString = "561257252.685854"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "130"
endingLineNumber = "130"
landmarkName = "setActionToRedBtn()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "micky-mouse-gesture/ViewController.swift"
timestampString = "561257252.686165"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "97"
endingLineNumber = "97"
landmarkName = "updateTimer()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
34 changes: 19 additions & 15 deletions micky-mouse-gesture/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ViewController: UIViewController {

if(timeSecCount < 0) {
timeMinCount = timeMinCount-1 <= 0 ? 0 : timeMinCount-1;
timeSecCount = 0;
timeSecCount = 59;
}

timeCounter.text = "\(String(format: "%02d", timeMinCount)):\(String(format: "%02d", timeSecCount))";
Expand All @@ -73,15 +73,18 @@ class ViewController: UIViewController {
isCounting = true;
setActionToRedBtn();
} else {
stopTimer();
isCounting = false;
setActionToGreenBtn();
processStopTimer();
}
}

func runTimer() {
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(ViewController.updateTimer)), userInfo: nil, repeats: true)

}

func processStopTimer() {
stopTimer();
isCounting = false;
setActionToGreenBtn();
}

func stopTimer() {
Expand All @@ -91,20 +94,21 @@ class ViewController: UIViewController {
@objc func updateTimer() {
timeSecCount = timeSecCount - 1;
if(timeSecCount == 0 && timeMinCount == 0) {
let alert = UIAlertController(title: "Micky Alert", message: "Time Out", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Default action"), style: .default, handler: { _ in
NSLog("The \"OK\" alert occured.")
}))
self.present(alert, animated: true, completion: nil)
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))

stopTimer();
isCounting = false;
setActionToGreenBtn();
showTimeOutAlert();
processStopTimer();
}
calculateAndUpdateTimerLabel();
}

func showTimeOutAlert() {
let alert = UIAlertController(title: "Micky Alert", message: "Time Out", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Default action"), style: .default, handler: { _ in
NSLog("The \"OK\" alert occured.")
}))
self.present(alert, animated: true, completion: nil)
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
}

func calculateAndUpdateTimerLabel() {
if(timeSecCount < 0) {
timeMinCount = timeMinCount-1 <= 0 ? 0 : timeMinCount-1;
Expand Down

0 comments on commit f95e71c

Please sign in to comment.