File tree Expand file tree Collapse file tree 1 file changed +34
-8
lines changed
Examples/Sources/CounterExample Expand file tree Collapse file tree 1 file changed +34
-8
lines changed Original file line number Diff line number Diff line change 1
1
import DefaultBackend
2
+ import Foundation
2
3
import SwiftCrossUI
3
4
4
5
#if canImport(SwiftBundlerRuntime)
@@ -9,20 +10,45 @@ import SwiftCrossUI
9
10
@HotReloadable
10
11
struct CounterApp : App {
11
12
@State var count = 0
13
+ @State var theme : ColorScheme = . dark
14
+
15
+ @Environment ( \. openURL) var openURL
12
16
13
17
var body : some Scene {
14
18
WindowGroup ( " CounterExample: \( count) " ) {
15
19
#hotReloadable {
16
- HStack ( spacing: 20 ) {
17
- Button ( " - " ) {
18
- count -= 1
19
- }
20
- Text ( " Count: \( count) " )
21
- Button ( " + " ) {
22
- count += 1
20
+ ZStack {
21
+ theme == . dark ? Color . black : Color . white
22
+
23
+ VStack {
24
+ HStack ( spacing: 20 ) {
25
+ Button ( " - " ) {
26
+ count -= 1
27
+ }
28
+ Text ( " Count: \( count) " )
29
+ Button ( " + " ) {
30
+ count += 1
31
+ }
32
+ }
33
+ . padding ( )
34
+
35
+ Menu ( " Settings " ) {
36
+ Text ( " Current theme: \( theme) " )
37
+ Menu ( " Theme " ) {
38
+ Button ( " Light " ) {
39
+ theme = . light
40
+ }
41
+ Button ( " Dark " ) {
42
+ theme = . dark
43
+ }
44
+ }
45
+ Button ( " Open documentation " ) {
46
+ openURL ( URL ( string: " https://stackotter.dev " ) !)
47
+ }
48
+ }
23
49
}
24
50
}
25
- . padding ( )
51
+ . colorScheme ( . dark )
26
52
}
27
53
}
28
54
. defaultSize ( width: 400 , height: 200 )
You can’t perform that action at this time.
0 commit comments