[XF] Can't pop modal without any modals pushed
Not sure that this is an issue or just something to be aware of, but it's easy to duplicate. Using the latest pre3? Prism XF. Create a page1 with a button that uses the default navigation service to open a page2 modally. On that page created a button that calls .goback. Navigate to page 2 and then tap the button that calls go back twice quickly before it can finish the navigation. Now try the button to navigate back to page two and you'll get the exception in the title.
I'm going to try to work around it by adding some sort of IsNavigating check so the button calling GoBack can't fire twice, which I also did on the button that navigates to page two so you can't modally open two page twos with a double tap. I've got to figure out some event to use to know the go back finished in order to set the IsNavigating flag to false. Since Goback just removes the page from the stack, nothing (I know of) is fired when the page has been removed from the stack so it'll be fun.
Might be good to build in some sort of check into the navigation service, so it won't allow navigation calls before the previous has completed if that's possible.
Yeah, I have noticed this. As you eluded to, this isn't so much an issue with Prism, but rather Xamarin.Forms. I can't prevent the number of clicks that occur on buttons or the tap gesture, but you do have a good idea though. I think I could add a simple internal boolean property (IsNavigating) to the navigation service. Then check the value of that before performing a navigation. If false, navigate, if true then don't navigate. This should protect prism apps from the dreaded double tap/click for navigation actions.
I'll look into this. Thanks fo rthe idea.
Cool, turns out I was overthinking this one. Given that in our case the page is always navigated to modally, and once you click the button to go back you don't ever want the button to work again (you want the page to disappear) It's just a matter of:
If (!IsNavigating) { IsNavigating = true; await _navigationService.GoBack(); }
IsNavigating defaults to false, so it just works.
Great! Glad you figure it out. I was playing around with adding an IsNavigating check in the navigation service itself, but due to the async nature of navigation, it won't work how I was hoping. So it sounds like your solution is the right one.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.