-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Net10] [iOS] Set NavigationBar.Translucent based on NavigationPage BarBackgroundColor transparency #30981
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
[Net10] [iOS] Set NavigationBar.Translucent based on NavigationPage BarBackgroundColor transparency #30981
Conversation
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
This PR modifies the NavigationPage on iOS to automatically determine navigation bar translucency based on the transparency of BarBackgroundColor, aligning with Shell's existing behavior. The iOS-specific platform configuration for setting translucency is marked as obsolete in .NET 10.
Key changes:
- Navigation bar translucency is now automatically set based on
BarBackgroundColoralpha value - iOS-specific translucency API is marked obsolete with appropriate deprecation warnings
- Legacy explicit translucency settings are still respected for backward compatibility
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| PublicAPI.Unshipped.txt (iOS/MacCatalyst) | Removes public API methods for translucency mapping |
| NavigationPage.cs | Marks iOS-specific translucency API as obsolete |
| NavigationPageExtensions.cs | Removes obsolete translucency update method |
| NavigationPage.iOS.cs | Removes translucency mapping methods |
| NavigationPage.Mapper.cs | Removes translucency property mapping |
| NavigationRenderer.cs | Implements new translucency logic based on background color alpha |
Comments suppressed due to low confidence (1)
src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs:879
- There is an extra closing brace here. The RefreshBarBackground method appears to have an additional closing brace that doesn't match an opening brace, which will cause a compilation error.
}
|
/rebase |
57fda58 to
42228e6
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
42228e6 to
df0256e
Compare
df0256e to
abe8c22
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
abe8c22 to
1b7aaa6
Compare
1b7aaa6 to
0724965
Compare
|
/rebase |
0724965 to
0023974
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| #region Translucent | ||
| /// <summary>Bindable property for <see cref="IsNavigationBarTranslucent"/>.</summary> | ||
|
|
||
| [Obsolete("IsNavigationBarTranslucent is deprecated. The Translucent will be enabled by default by setting the BarBackgroundColor to a transparent color.")] |
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.
What about the BarBackground property? (using a brush). If create a brush from transparent to a color, should apply the Translucent too?
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.
@jsuarezruiz, yes, if we set the BarBackground to a transparent color brush, it will behave as translucent, similar to how BarBackgroundColor works.
| if (_currentBarBackgroundColor?.Alpha < 1f) | ||
| navigationBarAppearance.ConfigureWithTransparentBackground(); | ||
| // If user explicitly set translucent property, respect that value | ||
| if (isNavigationBarTranslucentExplicitlySet) |
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.
Duplicate logic in both iOS 13+ and pre-iOS 13 branches, could creare a method and reuse it?
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.
@jsuarezruiz, the way translucency/opacity is applied differs between iOS 13+ (UINavigationBarAppearance) and pre-iOS 13 (BarTintColor / SetBackgroundImage), so I don’t think we can fully unify those blocks without introducing another branch inside the shared method. I extracted the common decision logic into a method but kept the application code separate since the APIs differ and require a different approach.
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!
Description of Change
Currently, the NavigationBar.Translucent property could only be set using the iOS-specific platform configuration.
This PR updates the behavior to align with Shell, where translucency is automatically determined based on the transparency (alpha) of the background color.
For
Shell, it is based onShell.BackgroundColor.For
NavigationPage, it is now based onNavigationPage.BarBackgroundColor.The iOS-specific platform configuration for setting Translucent has been marked as obsolete in .NET 10.
In .NET 10:
If the platform-specific setting is explicitly set, it will still be respected, even if BarBackgroundColor is transparent.
If the platform-specific setting is not set, translucency will be determined based on the alpha value of NavigationPage.BarBackgroundColor.