Skip to content

Commit 91bf0b9

Browse files
committed
Show two-way RatingBar binding in the playground
1 parent 8052e15 commit 91bf0b9

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Demo/App.swiftpm/Sources/RepresentablePlaygrounds.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ struct RepresentablePlayground: View {
99
var body: some View {
1010
ScrollView {
1111
VStack(alignment: .leading, spacing: 0) {
12-
Example("Native Android RatingBar") {
12+
Example("Native RatingBar (two-way)") {
1313
VStack(alignment: .leading, spacing: 8) {
14-
ComposableView("RatingBar", props: ["rating": .double(stars), "max": 5])
15-
.frame(height: 60)
14+
ComposableView(
15+
"RatingBar",
16+
props: ["rating": .double(stars), "max": 5],
17+
actions: ["onRatingChanged": .double { stars = $0 }]
18+
)
19+
.frame(height: 60)
1620
HStack {
1721
Button("−½") { stars = max(0, stars - 0.5) }
1822
Button("") { stars = min(5, stars + 0.5) }
1923
Text("\(stars) / 5")
2024
}
25+
Text("Drag the stars or use the buttons — both drive the same state.")
2126
}
2227
}
2328
Example("Compose function with SwiftUI children") {

0 commit comments

Comments
 (0)