adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
552 stars 45 forks source link

How to use IgnoreSafeArea and SetUseSafeArea in iOS? #212

Closed cris-m closed 3 months ago

cris-m commented 4 months ago

I would like to know how to use SetUseSafeArea on ContentPage or IgnoreSafeArea on layout like Grid,...

adospace commented 4 months ago

Please be more detailed in your question and how it's related to MauiReactor

cris-m commented 4 months ago

I am try to use SetUseSafeArea or IgnoreSafeArea in maui reactor component. I don't know how to do it. I was reading about it on Microsoft documentation https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/ios/page-safe-area-layout

<ContentPage 
     xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
     Title="Safe Area"
     ios:Page.UseSafeArea="true">
    <StackLayout>

    </StackLayout>
</ContentPage>

or

On<iOS>().SetUseSafeArea(true);

I want to know how to achieve this in MauiReactor

adospace commented 4 months ago

it's an attached property so something like this should work:

        return ContentPage(
             Grid(
            )
        )
        .OnAppearing(OnCalcSafeAreaSize)
        .OniOS(_ => _
            .Set(MauiControls.PlatformConfiguration.iOSSpecific.Page.UseSafeAreaProperty, false));
cris-m commented 3 months ago

This fix the issue about iOS UseSafeAreaProperty but I am unable to use IgnoreSafeArea on layout like Grid or StackLayout.

According to Microsoft documentation:

The Layout class defines a IgnoreSafeArea property that ensures that content is positioned on an area of the screen that is safe for all iOS devices. This property can be set to true on any layout class, such as a Grid or StackLayout, to perform the equivalent of this platform-specific.

how to use the IgnoreSafeArea on the Grid inside the ContentPage?

return ContentPage(
             Grid(
            )
        )
        .OnAppearing(OnCalcSafeAreaSize)
        .OniOS(_ => _
            .Set(MauiControls.PlatformConfiguration.iOSSpecific.Page.UseSafeAreaProperty, false));
adospace commented 3 months ago

Hi, unfortunately, IgnoreSafeArea is not a dependency property so for now you have to set explicitly:

            Grid(gridRef => 
            {
                if (gridRef != null)
                    gridRef.IgnoreSafeArea = true;
            })

in future version I'll integrate it in MauiReactor so you'll be able to write something like:

Grid().IgnoreSafeArea(true)