the49ltd / The49.Maui.BottomSheet

.NET MAUI library used to display pages as Bottom Sheets
MIT License
324 stars 31 forks source link

AppShell menu opening behind sheet on iOS #18

Open jesshannon opened 1 year ago

jesshannon commented 1 year ago

I've been able to keep the background interactive on iOS by adding the Medium detent and LargestUndimmedDetentIdentifier property in the Showing event handler.

The issue I have now is that the sheet is always in front of the entire AppShell view controller. I can close it on navigating away from the view I want it visible on, but I can't find a way to place it behind the flyout menu or hide it on opening the menu. Any ideas?

paulvarache commented 1 year ago

Hi,

Nice workaround for the custom detent issue on iOS.

Because this uses the native iOS sheets, I don't believe it is possible to have any other view over the sheet

If you want to close the sheet when you menu opens you should be able to call Dismiss on the sheet

paulvarache commented 1 year ago

I will dig into the implementation of the flyout on iOS to see if it is possible to change the viewController that presents the bottomsheet

jesshannon commented 1 year ago

Thanks. I did try changing the ViewController that the present method was called on in the the iOS handler but I couldn't get it to work, I tried walking down the children from the top most one and calling on each. Either it didn't show or went over everything.

I've not actually tested it in Swift to see if it would do what I want natively.

I was hoping I could do something like the Apple Find My app where the sheet goes behind a tab bar.

paulvarache commented 1 year ago

I have tried something similar. I managed to get the flyout's viewcontroller an present from there but it always shows on top.

I suspect the flyout is just a view that slides in inside the shell view, not a view attached to the window as this line suggests: https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellFlyoutRenderer.cs#L442

I'm not sure we can do more from within this plugin. Maybe it is possible to move the flyout renderer's view but it might cause a series of issues.

While not the ideal option, Observing the IsOpen of the flyout and closing/re-opening the sheet might be the only way for now

jesshannon commented 1 year ago

Thanks for looking into it. I'll go with the property observer on the flyout.

One thing that might help, could we have an overload on Show and Dismiss to set the animated boolean? If I can disable the animation it might make it less obvious that I'm hiding and showing it. I might even be able to use CaptureAsync to swap the sheet for an image in the parent view that will happily sit behind the menu.

paulvarache commented 1 year ago

I'll have a look to see if this is the same on Android. I suspect we can actually put in behind the flyout on Android as the sheet is added to the coordinator layout.

If that is the case and you do find a solution using CaptureAsync for iOS I'd be interested in integrating that into the plugin

paulvarache commented 1 year ago

rc1 was just released with an extra parameter added to both ShowAsync and DismissAsync to control the animations

borrmann commented 1 year ago

Dialogs like Application.Current.MainPage.DisplayActionSheet also open behind the BottomSheets.

Bersez commented 8 months ago

I have the same problem on Android. Could you tell me how the problem was solved?

jesshannon commented 8 months ago

I have the same problem on Android. Could you tell me how the problem was solved?

I gave up and rolled my own using a pan gesture and some simple animations. I wanted something that worked like the bottom sheet in Google Maps app, and this library isn't that.