Android Bug: NavigationPage as modal inside shell application, removes default page animation #21749
Description
Description
To support complex flows where one page would contain too much information for the user to have a good experience, I've created a page with "modalAnimated" as the presentation mode.
Shell.SetPresentationMode(this, PresentationMode.ModalAnimated);
When navigating to the next step in the flow, the page is pushed on top of it as another modal. Every page that comes after the modal-presented page will be presented in a similar way. When navigating back to MainPage (ShellRoot), all the pages on the modal stack are popped one by one.
So to solve this...
I have create a generic navigation page, with a page as the generic parameter
public class NavigationPage<T> : NavigationPage where T : Page
{
public NavigationPage(T page) : base(page)
{
Shell.SetPresentationMode(this, PresentationMode.ModalAnimated);
}
}
I have done this so that i can register the flow routes like this:
Routing.RegisterRoute("FlowPage1NavigationPage", typeof(NavigationPage<ComplexFlowPage1>));
Routing.RegisterRoute("FlowPage2", typeof(ComplexFlowPage2));
This is working perfectly fine on iOS, but on Android, some of the navigation animations are not working. The initial modal animation is working as it should, but when navigating deeper into the modal stack, the current page is hidden and the next page pops into view. This is happening very fast so it can be hard to see, but I've tested it in a complex app, where the load is higher. The closing animation is also working as it should (one animation).
I don´t know if this is shell specific or Maui specific, but the animations used to work in Xamarin.Forms without shell 😕
Steps to Reproduce
I've attched a repository that reproduce the 2 described bugs. When running you will be presented with two buttons where
- "Open Complex Flow" will open the "flow" without the navigation page
- "Open Complex Flow (Contained in" will open the "flow" wrapped in a navigation page
Both button will open a page where you can navigate and see the navigation problems:
- "Open Complex Flow" ➡️ Pages are pushed on top
- "Open Complex Flow (Contained in NavigationPage)"➡️ Animations are not working
When navigated to the last page you can press complete and see the navigation to MainPage
- "Open Complex Flow" ➡️ Pages are popped on by one
- "Open Complex Flow (Contained in NavigationPage)" ➡️ The navigaition page with all subpages are popped as one animation
Expected behavior
"Open Complex Flow"
I do not know if the Shell.SetPresentationMode(this, PresentationMode.ModalAnimated) is intented to make all subsequent pages Modal. So dont really know what is expected here.
"Open Complex Flow (Contained in NavigationPage)"
The animation in page navigation is expected to work and be visible
Link to public reproduction project repository
https://github.com/JohnTraDolta/NavigationPageAndroidBug
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
I did not find any workarounds yet, and any suggestions are welcome.
Relevant log output
No response
Activity