-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[net10.0] Fix SafeArea management on iOS #30629
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
base: net10.0
Are you sure you want to change the base?
Conversation
* Fixed the SafeArea test case issues and 22417(mac) main issue * Removed the Fails condition on Mac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fix SafeArea management on iOS by introducing caching and smart adjustments during measure and layout, and ensure nested UIScrollView
scenarios are handled correctly.
- Introduce
SafeAreaPadding
struct and extensions to compute and apply safe area insets. - Update
MauiView
andMauiScrollView
to cache safe area, adjust constraints inSizeThatFits
,CrossPlatformMeasure
, andCrossPlatformArrange
, and trigger extra layout passes when insets change. - Add new public API overrides (
AdjustedContentInsetDidChange
,SafeAreaInsetsDidChange
), renameISafeAreaView2
toISafeAreaPage
, and include UI tests and HostApp pages for issues 27715 and 24246.
Reviewed Changes
Copilot reviewed 16 out of 28 changed files in this pull request and generated 8 comments.
Show a summary per file
File | Description |
---|---|
src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs | Add Thread.Sleep(100) after app activation to wait for animations |
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Add overrides for AdjustedContentInsetDidChange and SafeAreaInsetsDidChange |
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Add overrides for AdjustedContentInsetDidChange and SafeAreaInsetsDidChange |
src/Core/src/Platform/iOS/SafeAreaPadding.cs | New SafeAreaPadding record struct and ToSafeAreaInsets extension |
src/Core/src/Platform/iOS/MauiView.cs | Integrate safe area caching, measurement, and arrangement adjustments |
src/Core/src/Platform/iOS/MauiScrollView.cs | Detect nested scroll views, cache safe area, adjust measure/layout logic |
src/Core/src/Core/ISafeAreaPage.cs | Rename ISafeAreaView2 to ISafeAreaPage |
src/Controls/src/Core/Page/Page.cs | Update Page to implement ISafeAreaPage and adjust explicit interface implementation |
src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs | Clamp desired size on Mac Catalyst to constraints |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27715.cs | Add UI test for ScrollView adjusted insets issue |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24246.cs | Add UI test for SafeArea arrange insets issue |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22417.cs | Update conditional compilation directive for a failing test |
src/Controls/tests/TestCases.HostApp/Issues/Issue27715.xaml.cs | Add HostApp code-behind page for issue 27715 |
src/Controls/tests/TestCases.HostApp/Issues/Issue27715.xaml | Add XAML page for ScrollView insets test |
src/Controls/tests/TestCases.HostApp/Issues/Issue24246.xaml.cs | Add HostApp code-behind page for issue 24246 |
src/Controls/tests/TestCases.HostApp/Issues/Issue24246.xaml | Add XAML page for SafeArea arrange test |
src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs
Outdated
Show resolved
Hide resolved
…and improve RTL layout handling
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
return; | ||
} | ||
|
||
if (!ValidateSafeArea()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder this check will have some performance impact.. Will look up the tree and all.. can we cache this in some way?
@@ -148,6 +193,34 @@ public override void LayoutSubviews() | |||
CrossPlatformArrange(bounds); | |||
} | |||
|
|||
bool ValidateSafeArea() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be shared with MauiScrollView?
Description of Change
Regarding the
MauiScrollView
one, the fix simply checks whether theMauiScrollView
lives inside anotherUIScrollView
.In such case we can give for granted that the ancestor one is properly accounting for safe area.
Regarding safe area, the main problem is that MAUI was measuring the content without accounting for the safe area.
This PR makes the
SizeThatFits
smarter by accounting for safe area adjustments:Then when arranging we can simply adjust for safe area using the cached thickness.
We only need to pay attention when the
SafeAreaInsets
change and trigger an invalidation of the ancestors.Issues Fixed
Fixes #27715
Fixes #24246