forked from AparokshaUI/adwaita-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CounterDemo.swift
48 lines (38 loc) · 1010 Bytes
/
CounterDemo.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
//
// CounterDemo.swift
// Adwaita
//
// Created by david-swift on 25.09.23.
//
// swiftlint:disable missing_docs
import Adwaita
struct CounterDemo: View {
@State("count", folder: "io.github.AparokshaUI.Demo/count")
private var count = 0
var view: Body {
VStack {
HStack {
CountButton(count: $count, icon: .goPrevious) { $0 -= 1 }
Text("\(count)")
.title1()
.frame(minWidth: 100)
CountButton(count: $count, icon: .goNext) { $0 += 1 }
}
.halign(.center)
}
.valign(.center)
.padding()
}
private struct CountButton: View {
@Binding var count: Int
var icon: Icon.DefaultIcon
var action: (inout Int) -> Void
var view: Body {
Button(icon: .default(icon: icon)) {
action(&count)
}
.circular()
}
}
}
// swiftlint:enable missing_docs