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] Top bar item colors - fix #26964

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jan 5, 2025

Description

Android docs: https://developer.android.com/reference/com/google/android/material/tabs/TabLayout#setTabIconTint(android.content.res.ColorStateList)

An easy fix is to just add _tabLayout.TabIconTint = colors; I did it in the first commit. However, I've noticed that thanks to it there's no longer need to have SetIconColorFilter() method, and, thereby, significantly reduce the size and complexity of this class. But maybe I'm missing something 🤔

Issues Fixed

Fixes #26905
Fixes #26662

Before After
Screen.Recording.2025-01-05.at.19.53.17.mov
Screen.Recording.2025-01-05.at.19.54.38.mov

@jsuarezruiz what do you think?

@kubaflo kubaflo requested a review from a team as a code owner January 5, 2025 19:11
Copy link
Contributor

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo kubaflo force-pushed the android-top-bar-icon-colors branch from 90bf31b to 3831a77 Compare January 5, 2025 19:22
@jfversluis
Copy link
Member

jfversluis commented Jan 5, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman
Copy link
Contributor

@kubaflo, I believe removing SetIconColorFilter is not appropriate, as it could cause issues in certain scenarios involving FontImageSource color.

Recently, I fixed the FontImageSource color issue on the TabbedPage icon. The PR can be found here: [iOS] [Android] Fix for the FontImageSource color is not applied properly to the Tab Icon by Tamilarasan-Paranthaman · Pull Request #26757 · dotnet/maui

For instance, if there are two ContentPage instances as children of a TabbedPage, setting SelectedTabColor to red while applying different FontImageSource colors to each page may not work as expected.

The SetIconColorFilter method handles the Icon.InvalidateSelf call, ensuring that the icon is updated correctly.

@kubaflo
Copy link
Contributor Author

kubaflo commented Jan 6, 2025

Hi @Tamilarasan-Paranthaman this pr actually fixes the issue in your PR. And there's no need for SetIconColorFilter

Screen.Recording.2025-01-06.at.18.09.05.mov

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

rmarinho commented Jan 7, 2025

Can we make sure adding a menu item and disable and enable it with have the correct colors?

@Tamilarasan-Paranthaman
Copy link
Contributor

Hi @Tamilarasan-Paranthaman this pr actually fixes the issue in your PR. And there's no need for SetIconColorFilter

Screen.Recording.2025-01-06.at.18.09.05.mov

@kubaflo, can you please fully utilize my test sample? I have added the SelectedTabColor and UnSelectedTabColor, but no FontImageSource color is specified for the first page. Only the second and third pages have the FontImageSource color defined.

With your fix, the FontImageSource color is not applied to the second and third pages.

undefined

I have handled the FontImageSource color for different scenarios by using combinations of SelectedTabColor, UnSelectedTabColor, and the FontImageSource color in my PR. It works properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants