Skip to content

Commit fab3da0

Browse files
committed
Add a popover playground
1 parent 6f6d297 commit fab3da0

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
struct PopoverPlayground: View {
8+
9+
@State private var infoShown = false
10+
@State private var chooserShown = false
11+
@State private var picked = "nothing"
12+
13+
var body: some View {
14+
ScrollView {
15+
VStack(alignment: .leading, spacing: 0) {
16+
Example("Info popover") {
17+
Button("Show details") { infoShown = true }
18+
.popover(isPresented: $infoShown) {
19+
VStack(alignment: .leading, spacing: 8) {
20+
Text("Quick details")
21+
Text("This bubble is anchored to the button.")
22+
Button("Got it") { infoShown = false }
23+
}
24+
}
25+
}
26+
Example("Popover that reports a choice") {
27+
VStack(alignment: .leading, spacing: 8) {
28+
Text("Picked: \(picked)")
29+
Button("Choose") { chooserShown = true }
30+
.popover(isPresented: $chooserShown) {
31+
VStack(alignment: .leading, spacing: 8) {
32+
Button("Option A") { picked = "A"; chooserShown = false }
33+
Button("Option B") { picked = "B"; chooserShown = false }
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
.navigationTitle("Popover")
41+
}
42+
}

0 commit comments

Comments
 (0)