|
Greetings, I need your brilliant minds here, as I've been trying anything and everything, to no avail. I've followed this "tutorial" to create a custom As you can see, tapping on the + button opens the menu and tapping again closes it. When I tap on Log Weight, which has no action assigned, it closes as well. Navigating to another tab menu also closes the menu. It's only when I tap on Add Measure that it does not close itself. The new fullscreen sheet is presented, but on dismiss, the PoPup menu is still open. To make sure it was not my custom implementation or something like that, I've created a new project just to replicate the issue and still happens. Here is all the code for review. You may copy/paste it on your end, if you wish/need to. ContentView:
PopUpMenu:
ViewRouter:
AddMeasures:
Thank you very much for all the help you can provide :) |
|
You have to pass ContentView
PopUpMenu
AddMeasures
The logic is to toggle showMenu cuz it makes you buttons appear. So to make them disappear you have to revert showMenu back to false state. |
|
Thank you very much @ygeras! I'm pretty sure I tried that, but somehow didn't work for me. Great explanation too. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
One more question if I may: I thought I had figured out how to detect a tap done on none of the menu item, which makes the PopUp menu disappear, as I want, but the side effect is that I have to long press now to execute the actions, instead of a single tap. In ContentView, I've added an
Again, it works for closing the PopUp menu, but renders the usability cumbersome. |
|
Sorry didn't get that part
What do you have to long press? Cuz I can press without long press those showmenu buttons and it dismisses them. When you added below code
only
before
BUT I don't think you app will use empty screens so you have to think your logic here. You already use to many gestures so you'd better to refactor it. Otherwise you'll soon confuse even yourself what is responsible for what. |
|
My apologies if I was not clear. What I meant to say is that the behavior of hiding the popup menu works when tapping anywhere in In my actual app, I have views displayed when tapping on an icon in the tab bar, and these views have lists and buttons and text boxes. And they don't react to single tap anymore. I'm probably going at this the wrong way, and I'm all ears if there is a better way to do it. Eventually, what I need is the following behavior: When I tap on the + icon, the menu shows or hides based on if it's the first tap or second tap => that works fine
When I tap on any of the menu icons, an action is triggered and the menu hides => that works now fine thanks to you
When I tap anywhere else on the screen (as in not the + sign or a menu item), the menu hides => this is where I have the issue. I've put the logic on the icons of the tab bar, but I need the same on the rest of the screen, aka Hope this helps understand better :) |
|
Well without details of what you have on your tab views it is difficult to say what exactly interferes with you tap gesture. But definitely if you have buttons and other tappable items on the screen and on top put another
It will make all area of that VStack kind of tappable. So it should change your state of showMenu to false when you tap in that area. And as you disabled all items above they will not react to their own taps but only the taps in contentShape will be recognized. And once you tap and showMenu disappears those items become active again and you can use them. |
|
Thanks for the effort, but it's still behaving the same, as in the PopUp hides wherever I tap, but it still interacts with the regular tap gesture and does not do anything with a simple tap. I'll have to figure this out another way. It's not critical, but in terms of user experience, you'd expect the PopUp menu to hide when you tap anywhere else, not just stays open like it does now. |
|
Hi @mezzomix23,
Try adding this to your
|
|
Hi @Hectorcrdna. Did exaclty work, was only using a portion of the screen doing so. But experimenting with the idea, I ended up adding this, for now (as I could always change my mind :-D):
I know having hardcoded 117 is not ideal, but for now and my tests it works, but will need to figure out the right formula to make sure the tab bar does not move up and down when the color happens. Thank you for the idea :-) |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.