Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] Setting Android using NavigationBar.Color in xaml or code permanently changes the navigationBar color everywhere rather than just that ContentPage

Open UnreachableCode opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

  • [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

Current Behavior

Setting the NavigationBar.Color in xaml or code sets it app wide. This is easy to do using Android styles.xml and colors.xml anyway.

Expected Behavior

I would expect the color to only be changed for the specifc ContentPage I was on, so that in my own applications I can set specific colours for specific screens for a specific look and feel.

Steps To Reproduce

Run the sample app on Android and navigate to Platform Specific -> NavigationBar.

Use the slider to set the NavigationBar color like so:

Screenshot 2024-06-26 at 16 14 20

And then navigate away from this screen:

Screenshot 2024-06-26 at 16 14 32

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui/tree/main/samples/CommunityToolkit.Maui.Sample/Pages/PlatformSpecific

Environment

- .NET MAUI CommunityToolkit:9.0.1
- OS: Android
- .NET MAUI: 8.0.300 (I think)

Anything else?

Thanks!

UnreachableCode avatar Jun 26 '24 15:06 UnreachableCode

I believe the desired behavior is to allow you to control it on a per page basis but you would need to clear it when navigating away from the page yourself. Or set it on the next page.

That being said I understand your expectation. The difficult thing would be to change this if we decided it was a bug as it could break developers. If we wanted to introduce a fix we could add a property to determine whether this is unset on navigating away.

bijington avatar Jun 26 '24 16:06 bijington

It could work like that where I change it on entry and exit, but it's a lot of overhead. And that's on the presumption that the default light grey is fine for every other screen (that doesn't have the same entry/exit behavior).

I hear what you're saying about breaking changes. I'm not sure how people are currently using this and what their expectation is. But I would have thought that the point is that it can set in one ContentPage at a time, especially given you can do it in xaml.

Is there a way to access the default navbar color for when I revert it?

UnreachableCode avatar Jun 27 '24 12:06 UnreachableCode