Skip to content

Instantly share code, notes, and snippets.

@xavierLowmiller
Created September 2, 2020 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierLowmiller/378e63c22aee6a07a650fe01305e2f6e to your computer and use it in GitHub Desktop.
Save xavierLowmiller/378e63c22aee6a07a650fe01305e2f6e to your computer and use it in GitHub Desktop.
A simple counter app for watchOS
import SwiftUI
@main
struct WatchOS_CounterApp: App {
@AppStorage("counter") var counter = 0
var body: some Scene {
WindowGroup {
VStack {
Text("\(counter)")
.font(.system(size: 72, design: .rounded))
HStack {
Button(action: { counter = 0 }, label: {
Image(systemName: "xmark.bin")
.scaleEffect(1.5)
})
Button(action: { counter += 1 }, label: {
Image(systemName: "plus")
.scaleEffect(1.5)
})
}
.padding()
}
.foregroundColor(.white)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment