This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var value: Double = 0.0 | |
var body: some View { | |
VStack{ | |
Text("value is \(value)") | |
Capsule() | |
.foregroundColor(.blue) | |
.frame(width: 50.0, height: 200.0) | |
.gesture(DragGesture() | |
.onChanged({ value in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// count-up-timer | |
// | |
// Created by Maegan Wilson on 4/28/20. | |
// Copyright © 2020 Maegan Wilson. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func restartTimer(){ | |
hours = 0 | |
minutes = 0 | |
seconds = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// count-up-timer | |
// | |
// Created by Maegan Wilson on 4/28/20. | |
// Copyright © 2020 Maegan Wilson. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stopTimer(){ | |
timerIsPaused = true | |
timer?.invalidate() | |
timer = nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Button(action:{ | |
self.startTimer() | |
}){ | |
Image(systemName: "play.fill") | |
.padding(.all) | |
} | |
.padding(.all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func startTimer(){ | |
timerIsPaused = false | |
// 1. Make a new timer | |
timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true){ tempTimer in | |
// 2. Check time to add to H:M:S | |
if self.seconds == 59 { | |
self.seconds = 0 | |
if self.minutes == 59 { | |
self.minutes = 0 | |
self.hours = self.hours + 1 |
NewerOlder