Skip to content

Commit fa787a2

Browse files
committed
Add a disclosure group playground
1 parent e743c02 commit fa787a2

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
struct DisclosurePlayground: View {
8+
9+
@State private var advancedOpen = false
10+
11+
var body: some View {
12+
ScrollView {
13+
VStack(alignment: .leading, spacing: 0) {
14+
Example("Self-managed expansion") {
15+
DisclosureGroup("What's included") {
16+
Text("• Unlimited projects")
17+
Text("• Priority support")
18+
Text("• Early access")
19+
}
20+
}
21+
Example("Bound expansion") {
22+
VStack(alignment: .leading, spacing: 8) {
23+
DisclosureGroup("Advanced settings", isExpanded: $advancedOpen) {
24+
Text("Experimental features live here.")
25+
Toggle("Beta channel", isOn: .constant(true))
26+
}
27+
Button(advancedOpen ? "Collapse from outside" : "Expand from outside") {
28+
advancedOpen.toggle()
29+
}
30+
}
31+
}
32+
Example("With a Label header") {
33+
DisclosureGroup(content: {
34+
Text("Grouped under a labeled header.")
35+
}, label: {
36+
Label("Notifications", systemImage: "star.fill")
37+
})
38+
}
39+
}
40+
}
41+
.navigationTitle("DisclosureGroup")
42+
}
43+
}

0 commit comments

Comments
 (0)