-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implement SafeArea attached property for per-edge safe area control #30337
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
Move the ISafeAreaView2 up to the view class. We don't need to make sure it works for every view at the platform level yet though, just move the implementation of the interface up to the view class Also, go through every test you can find that uses the obsolete safe area APIs and create a copy of that test using this new api |
Completed both tasks in commit a053e24:
All 17 tests pass, confirming the new API works correctly across all view types. |
I was mistaken on my last instruction Can you make it so that
All implement ISafeAreaView2 but not View Also, we want ContentView and Page both to make use of this API so the code that's inside Layout will probably need to be generalized somewhere (probably into the attached property class you added) |
Completed in bf4be4f. Restructured ISafeAreaView2 implementation as requested:
All 19 SafeAreaGuides unit tests pass, confirming the new structure works correctly while maintaining backward compatibility. |
Can you add a MAUI sample into the HostApp project that has the ability to test all permutations of disabling and enabling the safea layout guies on each edge? Just look at any of the files inside the
folder to see an example of how to setup the maui sample. You don't need to create a new project just add a single page that I can use to test setting and unsetting |
Created a comprehensive test page (Issue28986.xaml) in the HostApp that allows testing all permutations of SafeAreaGuides per-edge control. The page includes:
The page follows the same pattern as other issue test files in the TestCases.HostApp/Issues folder and provides an interactive way to validate the SafeAreaGuides.IgnoreSafeArea attached property functionality across all edge combinations. Commit: dae5dc1 |
currently failing with |
alright let's give up on the diagnostic logging for now and just go back to making changes to this PR Can you make the following changes And don't worry if you're not able to build the project |
I'm unable to access the specific discussion thread at #30337 (comment) directly. Could you please specify what changes you'd like me to make? I can see from the PR comments that there have been requests about:
What specific changes from that discussion would you like me to apply? |
Co-authored-by: PureWeen <[email protected]>
Co-authored-by: StephaneDelcroix <[email protected]>
I'm unable to access the specific GitHub discussion at that URL. Could you please specify what changes you'd like me to make? I can see the SafeArea implementation is in place, but I need to know what specific modifications from that discussion thread you want applied. |
|
…f just text content Co-authored-by: PureWeen <[email protected]>
Fixed the SafeArea UI tests to follow the "SafeAreaMainGridBasicFunctionality" model pattern. The tests now validate actual screen positioning instead of just text content: Updated tests:
Both tests now verify the actual UI behavior by checking that SafeAreaEdges changes cause the ContentGrid to inset/remove insets as expected. Commit: 8f433f0 |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
SafeArea Feature Specification
Caution as you test this PR
The safe area calculations in some scenarios are off until we can merge this PR #30629. These aren't bugs with this PR they are general bugs we've been trying to fix for sometimes.
Overview
The SafeArea feature provides fine-grained, per-edge safe area control for .NET MAUI applications, enabling developers to selectively control safe area behavior on specific edges while maintaining backward compatibility.
Public APIs
1. SafeAreaRegions Enum
2. SafeAreaEdges Struct
3. SafeAreaEdges Properties
Available on these controls:
Layout.SafeAreaEdges
ContentView.SafeAreaEdges
ContentPage.SafeAreaEdges
Border.SafeAreaEdges
ScrollView.SafeAreaEdges
4. XAML TypeConverter
Supports multiple input formats:
"None"
or"All"
- applies to all edges"All,None"
- horizontal,vertical pattern"All,None,All,None"
- Left,Top,Right,Bottom orderUsage Examples
XAML Usage
C# Usage
Behavior Specification
SafeAreaRegions Behaviors
Control-Specific Defaults
All
when value isDefault
None
when value isDefault
Default
when value isDefault
(uses iOS ContentInsetAdjustmentBehavior)Platform Integration
iOS Implementation
.automatic
.never
.always
.never
with manual ContentInset calculationInterface Integration
IgnoreSafeAreaForEdge(int edge)
andSafeAreaInsets
setterBackward Compatibility
Layout.IgnoreSafeArea
property continues to work unchangedTesting Coverage