version up
This commit is contained in:
39
FlowerApp/Platforms/iOS/PageExtensions.cs
Normal file
39
FlowerApp/Platforms/iOS/PageExtensions.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.Maui.Platform;
|
||||
using UIKit;
|
||||
|
||||
namespace Blahblah.FlowerApp;
|
||||
|
||||
public static partial class PageExtensions
|
||||
{
|
||||
public static UIViewController ShowBottomSheet(this Page page, IView content, bool dimDismiss = false)
|
||||
{
|
||||
var mauiContext = page.Handler?.MauiContext ?? throw new Exception("MauiContext is null");
|
||||
var viewController = page.ToUIViewController(mauiContext);
|
||||
|
||||
var viewControllerToPresent = content.ToUIViewController(mauiContext);
|
||||
viewControllerToPresent.ModalInPresentation = !dimDismiss;
|
||||
|
||||
var sheet = viewControllerToPresent.SheetPresentationController;
|
||||
if (sheet != null)
|
||||
{
|
||||
sheet.Detents = new[]
|
||||
{
|
||||
UISheetPresentationControllerDetent.CreateLargeDetent()
|
||||
};
|
||||
//sheet.LargestUndimmedDetentIdentifier = dimDismiss ?
|
||||
// UISheetPresentationControllerDetentIdentifier.Unknown :
|
||||
// UISheetPresentationControllerDetentIdentifier.Medium;
|
||||
sheet.PrefersScrollingExpandsWhenScrolledToEdge = false;
|
||||
sheet.PrefersEdgeAttachedInCompactHeight = true;
|
||||
sheet.WidthFollowsPreferredContentSizeWhenEdgeAttached = true;
|
||||
}
|
||||
|
||||
viewController.PresentViewController(viewControllerToPresent, true, null);
|
||||
return viewControllerToPresent;
|
||||
}
|
||||
|
||||
public static void CloseBottomSheet(this UIViewController sheet)
|
||||
{
|
||||
sheet.DismissViewController(true, null);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user