How to show multiple popover in SwiftUI

Issue #765

In SwiftUI currently, it’s not possible to attach multiple .popover to the same View. But we can use condition to show different content

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
struct ClipboardCell: View {
enum PopoverStyle {
case raw
case preview
}

@Binding
var showsPopover: Bool
@Binding
var popoverStyle: PopoverStyle

var body: some View {
VStack {
header
content
.popover(isPresented: $showsPopover) {
switch popoverStyle {
case .raw:
ViewRawView(item: item)
case .preview:
PreviewView(item: item)
}
}
footer
}
}
}

Comments