Reputation: 3241
I'm trying to implement a menu bar button that presents a popover when it is pressed.
It works as expected on iOS:
[![enter image description here][1]][1]
But this is how it works on Catalyst
[![enter image description here][2]][2]
This is the Catalyst-specific code:
struct CatalystHomescreenNavBarButton: View {
let action: () -> Void
let iconName: IconName
var body: some View {
Button(action: action ) {
iconName.image
}
.buttonStyle(.borderless)
.foregroundColor(TOP_BAR_IMAGE_BUTTON_FOREGROUND_COLOR)
// .hoverEffect() // ignored on Catalyst?
}
}
CatalystHomescreenNavBarButton(action: { showSearchPopover.toggle() },
iconName: PROJECT_SEARCH_ICON_NAME)
.popover(isPresented: $showSearchPopover, attachmentAnchor:
.point(.bottom), arrowEdge: .bottom) {
SearchPopoverContentView()
.presentationCompactAdaptation(.popover)
}
[1]: https://i.sstatic.net/iVXSaY1j.png
[2]: https://i.sstatic.net/2J2SmFM6.png
Upvotes: 0
Views: 15