Skip to content

Instantly share code, notes, and snippets.

View appsbymw's full-sized avatar

Apps by MW appsbymw

View GitHub Profile
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
import SwiftUI
struct ContentView: View {
@State private var selection = Tabs.inbox
private enum Tabs: Hashable {
case inbox
case projects
case settings
}
private enum Tabs: Hashable {
case inbox
case projects
case settings
}
import SwiftUI
struct ContentView: View {
@State private var selection = 0
var body: some View {
TabView(selection: $selection){
Text("First View")
.font(.title)
.tabItem {
//
// ContentView.swift
// count-up-timer
//
// Created by Maegan Wilson on 4/28/20.
// Copyright © 2020 Maegan Wilson. All rights reserved.
//
import SwiftUI
func restartTimer(){
hours = 0
minutes = 0
seconds = 0
}
//
// ContentView.swift
// count-up-timer
//
// Created by Maegan Wilson on 4/28/20.
// Copyright © 2020 Maegan Wilson. All rights reserved.
//
import SwiftUI
func stopTimer(){
timerIsPaused = true
timer?.invalidate()
timer = nil
}
Button(action:{
self.startTimer()
}){
Image(systemName: "play.fill")
.padding(.all)
}
.padding(.all)
@appsbymw
appsbymw / 005-count-up-timer.swift
Last active May 1, 2020 01:23
005-count-up-timer
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