Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SafeArea adjustments #23729

Merged
merged 2 commits into from
Sep 3, 2024
Merged

Fix SafeArea adjustments #23729

merged 2 commits into from
Sep 3, 2024

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Jul 19, 2024

Description of Change

This PR relates to some issues found here #22476 when trying to layout a Button when it's inside a layout that is partly inside the safearea.

The problem we found is that the MauiView returns a size from SizeThatFits that doesn't include the SafeAreaInsets. The arrange pass insets its Bounds and passes this value to CrossPlatformArrange but the Bounds being used is the size of the children not including the SafeAreaInsets which means the bounds used for arranging is wrong.

You can see from the screenshots below that the VSL surrounding the the entry gets arranged incorrectly

Comparison

Given the following XAML

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Maui.Controls.Sample.MainPage"
    xmlns:local="clr-namespace:Maui.Controls.Sample"
    xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
    ios:Page.UseSafeArea="false"
    >
    <VerticalStackLayout x:Name="layout" Background="Purple" IgnoreSafeArea="False" VerticalOptions="Start" IsClippedToBounds="True" >
        <Entry x:Name="label" Background="Green" Text="Hello there"></Entry>
    </VerticalStackLayout>
</ContentPage>

Before

image

After

image

Issues Fixed

Fixes #24246

@PureWeen PureWeen added this to the .NET 8 SR8 milestone Jul 22, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR8, .NET 8 SR9 Aug 6, 2024
@PureWeen
Copy link
Member Author

PureWeen commented Aug 9, 2024

/rebase

@PureWeen PureWeen marked this pull request as ready for review August 14, 2024 19:34
@PureWeen PureWeen requested a review from a team as a code owner August 14, 2024 19:34
@PureWeen PureWeen changed the title Account for safearea Fix SafeArea adjustments Aug 14, 2024
@PureWeen
Copy link
Member Author

/rebase

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested a bunch of things, and it seems to work as I would expect.

@mattleibow mattleibow merged commit 14b29b0 into main Sep 3, 2024
97 checks passed
@mattleibow mattleibow deleted the adjust_safearea branch September 3, 2024 17:30
PureWeen added a commit that referenced this pull request Sep 4, 2024
rmarinho pushed a commit that referenced this pull request Sep 5, 2024
PureWeen added a commit that referenced this pull request Sep 5, 2024
@samhouts samhouts added the fixed-in-net8.0-nightly This may be available in a nightly release! label Sep 5, 2024
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Oct 1, 2024
@samhouts samhouts added fixed-in-9.0.0-rc.2.24503.2 and removed fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Oct 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[iOS] SafeArea arrange insets are currently insetting based on an incorrect Bounds
3 participants