Skip to content

Commit c2d0a8b

Browse files
committed
Add custom views playground
1 parent fdc027b commit c2d0a8b

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
struct RepresentablePlayground: View {
8+
@State private var stars = 3.5
9+
var body: some View {
10+
ScrollView {
11+
VStack(alignment: .leading, spacing: 0) {
12+
Example("Native Android RatingBar") {
13+
VStack(alignment: .leading, spacing: 8) {
14+
ComposableView("RatingBar", props: ["rating": .double(stars), "max": 5])
15+
.frame(height: 60)
16+
HStack {
17+
Button("−½") { stars = max(0, stars - 0.5) }
18+
Button("") { stars = min(5, stars + 0.5) }
19+
Text("\(stars) / 5")
20+
}
21+
}
22+
}
23+
Example("Compose function with SwiftUI children") {
24+
ComposableView("DashedBorder", props: ["color": .color(.blue)]) {
25+
VStack(alignment: .leading, spacing: 6) {
26+
Text("These SwiftUI views").bold()
27+
Text("sit inside a Compose-drawn dashed border.")
28+
}
29+
}
30+
}
31+
Example("Unregistered name (diagnostic)") {
32+
ComposableView("DoesNotExist")
33+
.frame(height: 40)
34+
}
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)