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

[Android][NavigationBar] MainCommand icon fails to update when switching themes #1335

Open
2 tasks done
erikvilima opened this issue Feb 3, 2025 · 4 comments
Open
2 tasks done
Assignees
Labels
kind/bug Something isn't working

Comments

@erikvilima
Copy link
Contributor

Current behavior

When switching themes (light/dark) the icon set as MainCommand of a NavigationBar fails to update its color.

How to reproduce it (as minimally and precisely as possible)

UnoApp1.zip

  1. Download and run (on android) the repro
  2. Navigate to the Second Page
  3. Press the ToggleSwitch to switch themes
  4. Observe that the back button won't update its color

Nuget Package:
Uno.Sdk - 5.6.20
Uno.Toolkit.WinUI - 6.4.1

Affected platform(s):

  • Android

IDE:

  • Visual Studio 2022

Relevant plugins:

Anything else we need to know?

@erikvilima erikvilima added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Feb 3, 2025
@kazo0 kazo0 removed the triage/untriaged Indicates an issue requires triaging or verification. label Feb 4, 2025
@rajamatt rajamatt self-assigned this Feb 4, 2025
@rajamatt
Copy link
Contributor

rajamatt commented Feb 4, 2025

Seems like an AppBarButton issue because the icon switches themes accordingly after removing the explicit MainCommand.

Doesn't look like its caused by the changes in #1302 because adding back those lines doesn't fix it.

@rajamatt
Copy link
Contributor

rajamatt commented Feb 5, 2025

Indeed theme switching doesn't work on an explicit MainCommand even with toolkit 6.2.0-dev.35, which was 6 months ago. So might be something we never handled.

@rajamatt
Copy link
Contributor

rajamatt commented Feb 7, 2025

The AppBarButtonRenderer.Invalidate() is never invoked when switching themes. But other invalidate methods like NavigationBarPresenter.Invalidate() are invoked because of properties like NavigationBar.Background changing.

After switching themes, if I force the invalidate on the MainCommand/AppBarButton the theme of the AppBarButton still doesn't change. So I think the properties of the AppBarButton are never updated in the first place, or they are updated on the wrong element since the property listeners don't observe any changes.

@kazo0
Copy link
Contributor

kazo0 commented Feb 26, 2025

@rajamatt

This is because the AppBarButton instance is never actually realized in the visual tree for the MainCommand. Unlike the PrimaryCommands, we cannot actually place the MainCommand AppBarButton inside of the native navbar. So we are simply doing a one-time forwarding of the relevant properties to the Android Toolbar navigation item.

I'm not sure if there would be an easy way to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants