Skip to content

Instantly share code, notes, and snippets.

@erica
Created June 7, 2019 14:41
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 erica/3b5e9068d0a79ffdb4391928f0e66dcb to your computer and use it in GitHub Desktop.
Save erica/3b5e9068d0a79ffdb4391928f0e66dcb to your computer and use it in GitHub Desktop.
import PlaygroundSupport
import SwiftUI
struct MouseState {
var corded = 0
var cordless = 0
var magic = 0
var total: Int {
return corded + cordless + magic
}
}
struct LiveView: View {
@State var mouseState = MouseState()
var body: some View {
ZStack {
Rectangle()
.foregroundColor(Color.white)
VStack(spacing: 50) {
HStack {
Image(systemName: "desktopcomputer")
.padding()
.background(Color.white)
.mask(Circle())
Text("Mouse Stocks")
.font(.largeTitle)
.color(Color.white)
}.padding() // HStack
VStack(spacing: 0) {
Stepper(value: $mouseState.corded,
in: 0 ... .max,
step: 1,
label: { return Text("Corded (\(mouseState.corded))").font(.body) })
Stepper(value: $mouseState.cordless,
in: 0 ... .max,
step: 1,
label: { return Text("Cordless (\(mouseState.cordless))").font(.body) })
Stepper(value: $mouseState.magic,
in: 0 ... .max,
step: 1,
label: { return Text("Magic (\(mouseState.magic))").font(.body) })
}
.padding()
.background(Color.white.cornerRadius(8)) // VStack
HStack {
Text("Total Mice in Inventory:")
Text("\(mouseState.total)")
}
.font(.headline).padding() // HStack
}
.padding()
.background(Color.blue.opacity(0.5).cornerRadius(16)) // VStack
}.background(Color.white) // ZStack
}
}
PlaygroundPage.current.liveView = UIHostingController(rootView: LiveView())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment