dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.01k stars 1.72k forks source link

ModalPresentationStyle is not respected when using NavigationPage #20284

Open Axemasta opened 7 months ago

Axemasta commented 7 months ago

Description

I wanted to set the ModalPresentationStyle of a page to FormSheet and get something that looked like this in my app:

62240

I followed this guide and got everything setup, anytime I navigated the presentation style would not be applied and the default (OverFullscreen) appearance was visible.

After some investigating its clear that navigation pages are supported with this presentation style natively:

87023

I made a reproduction in the latest version of maui and I found that setting ModalPresentationStyle on the ContentPage is not respected when the page is in a NavigationPage and you actually need to set this style on the NavigationPage instead.

The reason this IS a bug and not a janky tooling is that PresentationStyle natively is respected from the UIViewController, not the UINavigationController: 82204

There should be a check to see the presentation style of the root content page of the NavigationPage to apply the pages behaviour, otherwise the documentation should be updated to reflect that you need to set this directly on the NavigationPage. I would not like that outcome since I use prism and my navigation flow is somewhat decoupled from my codebase (handled by prism) and accessing the navigation page to set this property would be extremely annoying.

Steps to Reproduce

  1. Create a modal navigation (to a ContentPage)
  2. On the modal page set On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
  3. Run the app and observe the form sheet presentation style
  4. Embed the modal page in a NavigationPage
  5. Run the app again and observe the modal presentation style is not respected

Link to public reproduction project repository

The reproduction I used to write this issue is ModalPresentationStyle

Version with bug

8.0.6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

Yes, if you set the ModalPresentationStyle on the NavigationPage directly, the setting will be picked up and respected on the UI

var secondPage = serviceProvider.GetRequiredService<SecondPage>();

var modal = new NavigationPage(secondPage);

// This isn't nice :(
modal.On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);

await Navigation.PushModalAsync(modal);

Relevant log output

No response

ghost commented 7 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

rmarinho commented 7 months ago

@PureWeen do you know if we changed something here?

PureWeen commented 7 months ago

@rmarinho doesn't look familiar