Skip to content

Commit a1ce7a4

Browse files
committed
Add SimpleGridExample
1 parent 1585c43 commit a1ce7a4

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

Examples/Bundler.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ version = '0.1.0'
5454
identifier = 'dev.swiftcrossui.PathsExample'
5555
product = 'PathsExample'
5656
version = '0.1.0'
57+
58+
[apps.SimpleGridExample]
59+
identifier = 'dev.swiftcrossui.SimpleGridExample'
60+
product = 'SimpleGridExample'
61+
version = '0.1.0'

Examples/Package.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ let package = Package(
6868
.executableTarget(
6969
name: "PathsExample",
7070
dependencies: exampleDependencies
71-
)
71+
),
72+
.executableTarget(
73+
name: "SimpleGridExample",
74+
dependencies: exampleDependencies
75+
),
76+
7277
]
7378
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import DefaultBackend
2+
import SwiftCrossUI
3+
4+
#if canImport(SwiftBundlerRuntime)
5+
import SwiftBundlerRuntime
6+
#endif
7+
8+
@main
9+
@HotReloadable
10+
struct SimpleGridApp: App {
11+
let rowColors: [Color] = [Color.red, Color.green, Color.blue]
12+
let columnColors: [Color] = [Color.yellow, Color.orange, Color.purple]
13+
var body: some Scene {
14+
WindowGroup("SimpleGridExample") {
15+
Grid(horizontalSpacing: 30, verticalSpacing: 30) {
16+
ForEach(0..<rowColors.count) { row in
17+
GridRow {
18+
ForEach(0..<columnColors.count) { column in
19+
Text("(Column: \(column), Row: \(row))")
20+
.font(.system(size: 24))
21+
.background(rowColors[column])
22+
}
23+
}
24+
.foregroundColor(columnColors[row])
25+
}
26+
}
27+
}
28+
.defaultSize(width: 800, height: 500)
29+
}
30+
}

0 commit comments

Comments
 (0)