-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[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
[iOS] [Android] Fix for the FontImageSource color is not applied properly to the Tab Icon #26757
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
0140b78
to
45a3f7e
Compare
{ | ||
FontFamily = "Ion", | ||
Glyph = "\uf30c", | ||
Color = Colors.Violet, |
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.
Can we add a test that only changes the Color on the FontImageSource and verify that that will update the 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.
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.
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.
It should trigger on the Source Level
changing the color triggers a source changed event
which fires a source changed event
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?
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.
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.
That PR was merged, do we have a test in this PR yet?
Hi @Tamilarasan-Paranthaman 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. |
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.
not quite a review, but we probably don't need to list the issues just the reasoning.
// 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 |
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.
// 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 |
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.
@mattleibow, Got it! I have removed the issue list.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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.
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); |
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.
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?
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.
-
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
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.
Gotta pick red or green for the machine!
/rebase |
3400fd9
to
7f14050
Compare
/azp run MAUI-public |
Azure Pipelines successfully started running 1 pipeline(s). |
…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>
…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>
…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>
…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>
…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>
Root Cause of the issue
iOS
Android
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
Screenshot
Android
iOS