maui icon indicating copy to clipboard operation
maui copied to clipboard

Android Bug: NavigationPage as modal inside shell application, removes default page animation

Open JohnTraDolta opened this issue 1 year ago • 3 comments

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

  1. "Open Complex Flow" will open the "flow" without the navigation page
  2. "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:

  1. "Open Complex Flow" ➡️ Pages are pushed on top
  2. "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

  1. "Open Complex Flow" ➡️ Pages are popped on by one
  2. "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

JohnTraDolta avatar Apr 10 '24 08:04 JohnTraDolta

Can repro this issue at Android platform on the latest 17.10.0 Preview 3(8.0.14&8.0.20).

RoiChen001 avatar Apr 10 '24 09:04 RoiChen001

@RoiChen001 can you confirm on previous versions of MAUI?

PureWeen avatar Apr 10 '24 18:04 PureWeen

@PureWeen It can also be reproduced on 8.0.3,8.0.6,8.0.7and 8.0.10.

RoiChen001 avatar Apr 11 '24 06:04 RoiChen001