Skip to content

[iOS] [Android] Fix for the FontImageSource color is not applied properly to the Tab Icon #26757

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

Merged
merged 9 commits into from
Mar 19, 2025

Conversation

Tamilarasan-Paranthaman
Copy link
Contributor

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Dec 20, 2024

Root Cause of the issue

iOS

  • The regression occurred because a previous PR changed the UIImageRenderingMode to Automatic, causing the TabbedPage tab icon to ignore the FontImageSource.Color.

Android

  • In Android, setting the FontImageSource.Color is not taken into account for the TabbedPage icon.

Description of Change

iOS

I have resolved the issue by setting the UIImageRenderingMode to Automatic when the FontImageSource is null. If the color is already applied to the FontImageSource, the UIImageRenderingMode is set to AlwaysOriginal.

Android

I have fixed the TabIcon color issue for the default TabBar placement in the SetIconColorFilter method. If the FontImageSource color is specified in the sample, it returns null and no need to update the color. If the FontImageSource color is null, the method retrieves the color using GetItemIconTintColorState to apply the appropriate color based on SelectedTabColor and UnselectedTabColor.

Additionally, some common cases were broken in the GetItemIconTintColorState method. For example, if no SelectedTabColor, UnselectedTabColor, or ContentPage FontImageSource color is provided, the TabIcons should use the default color. However, the method was returning null prematurely, preventing the default color from being applied to the TabIcons.

I have also addressed these additional cases. For instance, if none of the SelectedTabColor, UnselectedTabColor, or ContentPage FontImageSource colors are specified, the TabIcons will now correctly use the default color.

Regressed PR

Revert PR

Issues Fixed

Fixes #26662
Fixes #27000

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Android

Before Issue Fix After Issue Fix

iOS

Before Issue Fix After Issue Fix

This comment was marked as outdated.

@jfversluis

This comment was marked as off-topic.

@github-actions github-actions bot force-pushed the fix-26662 branch 2 times, most recently from 0140b78 to 45a3f7e Compare January 20, 2025 11:44
{
FontFamily = "Ion",
Glyph = "\uf30c",
Color = Colors.Violet,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test that only changes the Color on the FontImageSource and verify that that will update the color?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PureWeen ,

Changing the Color property directly in IconImageSource does not trigger notifications at the Source level.

In TabbedPageManager on Android, Page.PropertyChanged only detects changes to IconImageSource, and this behavior is consistent across all platforms.

Currently, FontImageSource property changes are not handled in the TabbedPage implementation across platforms. We may need to add support for these changes to ensure proper updates.

Additionally, the user is following the same approach used in our test sample.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should trigger on the Source Level

changing the color triggers a source changed event

image

which fires a source changed event
image

It seems like we're just doing a bad job of listening for that event?

I don't think we need to block this PR on this but it seems like we should be watching for the SourceChanged event more places and then reacting based on that. Can you create an issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PureWeen ,
I meant the previous comment, as no implementation was added while changing the image source color property. As you mentioned, I have created a separate issue #27549 for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR was merged, do we have a test in this PR yet?

PureWeen
PureWeen previously approved these changes Feb 3, 2025
@AlleSchonWeg
Copy link
Contributor

Hi @Tamilarasan-Paranthaman
in my app i set UnselectedTabColor and SelectedTabColor:

 UnselectedTabColor="{AppThemeBinding Light=Blue, Dark=Red}"
 SelectedTabColor="{AppThemeBinding Light=Yellow, Dark=Green}"

i also used FontImageSource , but without a color:

<NavigationPage.IconImageSource>
	<FontImageSource FontFamily="..."
					 Glyph="..."
					 Size="20" />
</NavigationPage.IconImageSource>

Is this still working if you PR is merged? Do you use UnselectedTabColor/SelectedTabColor is no color is set in FontImageSource?

Thank you

@Tamilarasan-Paranthaman
Copy link
Contributor Author

Hi @Tamilarasan-Paranthaman in my app i set UnselectedTabColor and SelectedTabColor:

 UnselectedTabColor="{AppThemeBinding Light=Blue, Dark=Red}"
 SelectedTabColor="{AppThemeBinding Light=Yellow, Dark=Green}"

i also used FontImageSource , but without a color:

<NavigationPage.IconImageSource>
	<FontImageSource FontFamily="..."
					 Glyph="..."
					 Size="20" />
</NavigationPage.IconImageSource>

Is this still working if you PR is merged? Do you use UnselectedTabColor/SelectedTabColor is no color is set in FontImageSource?

Thank you

@AlleSchonWeg, I would like to confirm that if no color is specified for the FontImageSource icon, the icon color will be determined by the SelectedTabColor/UnselectedTabColor. Additionally, I have added a test case in this PR to verify that when no color is provided for the FontImageSource icon on the first page, the icon color is correctly applied based on the SelectedTabColor/UnselectedTabColor.

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite a review, but we probably don't need to list the issues just the reasoning.

Comment on lines 53 to 56
// resolving the TabbedPage Icon color and ToolbarItem Icon color issues
// https://github.com/dotnet/maui/issues/25912
// https://github.com/dotnet/maui/issues/26662
// https://github.com/dotnet/maui/issues/12250
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// resolving the TabbedPage Icon color and ToolbarItem Icon color issues
// https://github.com/dotnet/maui/issues/25912
// https://github.com/dotnet/maui/issues/26662
// https://github.com/dotnet/maui/issues/12250

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow, Got it! I have removed the issue list.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I have 2 questions:

  • Is there a myimagesource.Color = newColor test?
  • There may be a bad code path that appears that it will never be hit, but just in case...

else
{
defaultColor = GetDefaultColor(defaultColor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am understanding the code path of the usage of the GetDefaultColor, if the BarItemColor is not set, then the value of defaultColor that is passed into the method will be the initial 0. In fact, since this is a local variable, it will always be 0. Is that OK?

Copy link
Contributor

@Ahamed-Ali Ahamed-Ali Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I have modified the test sample to change the icon color directly in the button click event method.

  • I have removed the unnecessary parameter from the GetDefaultColor method.

Could you please review and let us know if you have any other concerns? @mattleibow

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta pick red or green for the machine!

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Mar 3, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Mar 18, 2025
@dotnet dotnet deleted a comment from PureWeen Mar 18, 2025
@rmarinho rmarinho changed the base branch from main to inflight/current March 19, 2025 17:25
@rmarinho
Copy link
Member

/rebase

@dotnet dotnet deleted a comment from azure-pipelines bot Mar 19, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Mar 19, 2025
@rmarinho
Copy link
Member

/azp run MAUI-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen merged commit d4b3319 into dotnet:inflight/current Mar 19, 2025
10 of 17 checks passed
@github-project-automation github-project-automation bot moved this from Ready To Review to Done in MAUI SDK Ongoing Mar 19, 2025
anandhan-rajagopal pushed a commit to anandhan-rajagopal/maui that referenced this pull request Mar 26, 2025
…erly to the Tab Icon (dotnet#26757)

* Tab icon color fix

* Test sample changes

* Added snapshots

* Added details

* Added Mac snapshots

* Removed unwanted parameters and modified the test sample

* Committed the proper mac snap

* Removed the unwanted issue list comments

* Addressed the review concerns

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
anandhan-rajagopal pushed a commit to anandhan-rajagopal/maui that referenced this pull request Mar 26, 2025
…erly to the Tab Icon (dotnet#26757)

* Tab icon color fix

* Test sample changes

* Added snapshots

* Added details

* Added Mac snapshots

* Removed unwanted parameters and modified the test sample

* Committed the proper mac snap

* Removed the unwanted issue list comments

* Addressed the review concerns

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Mar 26, 2025
…erly to the Tab Icon (#26757)

* Tab icon color fix

* Test sample changes

* Added snapshots

* Added details

* Added Mac snapshots

* Removed unwanted parameters and modified the test sample

* Committed the proper mac snap

* Removed the unwanted issue list comments

* Addressed the review concerns

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Mar 26, 2025
…erly to the Tab Icon (#26757)

* Tab icon color fix

* Test sample changes

* Added snapshots

* Added details

* Added Mac snapshots

* Removed unwanted parameters and modified the test sample

* Committed the proper mac snap

* Removed the unwanted issue list comments

* Addressed the review concerns

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Mar 27, 2025
…erly to the Tab Icon (#26757)

* Tab icon color fix

* Test sample changes

* Added snapshots

* Added details

* Added Mac snapshots

* Removed unwanted parameters and modified the test sample

* Committed the proper mac snap

* Removed the unwanted issue list comments

* Addressed the review concerns

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-tabbedpage TabbedPage community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
Status: Done
9 participants