File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments