forked from AparokshaUI/adwaita-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiceDemo.swift
47 lines (39 loc) · 889 Bytes
/
DiceDemo.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
//
// DiceDemo.swift
// Adwaita
//
// Created by david-swift on 12.10.23.
//
// swiftlint:disable missing_docs no_magic_numbers
import Adwaita
struct DiceDemo: View {
@State private var number: Int?
private var label: String {
if let number {
return "\(number)"
} else {
return "Roll the Dice!"
}
}
var view: Body {
VStack {
Button(label) {
number = .random(in: 1...6)
}
.pill()
.suggested()
.style("dice-button")
.css {
"""
.dice-button {
background-color: @green_5;
}
"""
}
.frame(maxWidth: 100)
}
.valign(.center)
.padding()
}
}
// swiftlint:enable missing_docs no_magic_numbers