I am updating my app from beta2 to beta3. Looks like the old format for creating a popover has been replaced with a new mechanism.
My goal is to create the 'ellipses' menu item for my app.
My old SwiftUI code looked like:
struct MenuButton : View {
@State var showMenu: Bool = false
var body: some View {
Button(action: { self.showMenu = true }) {
Image(systemName: "ellipsis")
}
.presentation(showMenu ? Popover(content: MenuView(isMenuPresented: $showMenu), dismissHandler: {
self.showMenu = false }) : nil)
}
}
But the .presentation(...) code was marked as removed. So, I moved to a new format, that seems appropriate, .popOver(...)
struct MenuButton : View {
@State var showMenu: Bool = false
var body: some View {
Button(action: { self.menuButtonTapped() }) {
Image(systemName: "ellipsis")
}
.popover(isPresented: $showMenu) { MenuView(isMenuPresented: self.$showMenu) }
// FIXME: Need to compute the attachmentAnchor point, but I'm not clear how to
// do that in Beta3.
}
func menuButtonTapped() {
self.showMenu = true
}
}
You can see I am stuck trying to compute the 'attachmentAnchor' point as an argument for the popover.
Anyone know how to compute the attachment point for the button. I don't see how to get the location of the button.
Thanks in advance,
Charlie