-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateWrapper.swift
57 lines (50 loc) · 1.71 KB
/
StateWrapper.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import SwiftUI
struct StateWrapper: View {
@State var count: Int = 0
let backgroundColor: Color = .indigo
var body: some View {
ZStack {
backgroundColor.edgesIgnoringSafeArea(.all)
VStack(spacing: 40) {
Text("Counter")
.font(.title)
Text("Count: \(count)")
.font(.title2)
.underline()
HStack(spacing: 20) {
Button(
action: {
count -= 1
},
label: {
Text("- Decrement")
.padding(.horizontal, 10)
.padding()
.background(
Capsule()
.stroke(.white, lineWidth: 2.0)
)
}
)
Button(
action: {
count += 1
},
label: {
Text("Increment +")
.padding(.horizontal, 10)
.padding()
.background(
Capsule()
.stroke(.white, lineWidth: 2.0)
)
}
)
}
}.foregroundStyle(.white)
}
}
}
#Preview {
StateWrapper()
}