Skip to content

[2025/05/26] Candidate - In Flight Branch #29623

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 39 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4b9ceef
[Testing] Feature Matrix UITest Cases for CollectionView Dynamic cha…
NafeelaNazhir May 13, 2025
f5e12ee
Remove (#29476)
MartyIX May 13, 2025
753e12d
[iOS] Fixed picker title's color (#20205)
kubaflo May 13, 2025
aac1ddc
[iOS] Setting background color on the Searchbar - fix (#23355)
kubaflo May 13, 2025
a5821bc
Clear Parent on old image source (#29481)
PureWeen May 14, 2025
0b6aad7
[create-pull-request] automated change (#29505)
github-actions[bot] May 15, 2025
9e6dd7e
[Testing] Enabling more UI Tests by removing platform specific condit…
NafeelaNazhir May 15, 2025
2e9c6a9
[Android] Fix WebView Navigated is fired when source is null (#29234)
bhavanesh2001 May 15, 2025
4a54772
Set result to tcs when user cancels (#29498)
bhavanesh2001 May 15, 2025
09348a6
[housekeeping] Automated PR to fix formatting errors on inflight/current
github-actions[bot] May 15, 2025
00851b6
[iOS] ScrollView content offset RTL - fix (#29469)
kubaflo May 15, 2025
7c7f85d
[Windows] Fix for ArgumentException thrown when setting a negative pa…
SyedAbdulAzeemSF4852 May 16, 2025
f80142a
[housekeeping] Automated PR to fix formatting errors on inflight/current
github-actions[bot] May 16, 2025
14bf504
Enhance debugging in ViewHandler.cs (#29538)
pictos May 19, 2025
4aa0858
Compute LayoutConstraints on new *StackLayout and Grid (#28931)
albyrock87 May 20, 2025
19fca33
[housekeeping] Automated PR to fix formatting errors on inflight/current
github-actions[bot] May 20, 2025
26b6ed8
Fixed Maui.Graphics GetStringSize Inverts Width and Height (#29574)
Dhivya-SF4094 May 21, 2025
bc5d075
Fix CarouselView ItemTemplate Runtime Updates (#29546)
Shalini-Ashokan May 21, 2025
fd8a326
[Testing] Re-Enabled UI Test - Issue12574Test (#29436)
TamilarasanSF4853 May 21, 2025
5b7012d
[Windows] Fixed Shell flyout background image does not displayed (#28…
SubhikshaSf4851 May 21, 2025
aa7db69
[housekeeping] Automated PR to fix formatting errors on inflight/current
github-actions[bot] May 21, 2025
bd118f6
[Android] Fix: Modal Animation Repeats When Returning from Background…
bhavanesh2001 May 21, 2025
2b44883
[housekeeping] Automated PR to fix formatting errors on inflight/current
github-actions[bot] May 21, 2025
afd836a
[Windows] Fix for FlyoutItem in overflow menu not fully interactable …
TamilarasanSF4853 May 22, 2025
a8170a7
Fix Build issue in inflight/Current (#29614)
bhavanesh2001 May 22, 2025
4d11070
[Android] The number of SearchHandler toolbar item increases abnormal…
kubaflo May 22, 2025
82aa099
[Android] Fix: Prevent Duplicate MapSource Invocations on setting Ima…
bhavanesh2001 May 22, 2025
3e6ffa6
Fixed the label span issue. (#28851)
NanthiniMahalingam May 22, 2025
88c0db6
[Testing] Feature Matrix UITest Cases for CarouselView (#29548)
NafeelaNazhir May 22, 2025
e4a6709
[Testing] Added UITest for MenuFlyoutItem Clicked/Command delegate (#…
anandhan-rajagopal May 22, 2025
ca91b22
[Android] Fix for the FontImageSource color is not applied properly t…
Ahamed-Ali May 23, 2025
b020918
Fixed Test case failure in PR 20205 - [2025/05/26] (#29686)
kubaflo May 27, 2025
008dfb4
[Revert][Android] Fix: Modal Animation Repeats When Returning from Ba…
bhavanesh2001 May 27, 2025
00118bd
Fixed Test case failure in PR 29623 - [2025/05/26] Candidate (#29636)
LogishaSelvarajSF4525 May 28, 2025
71a47f4
Fixed Test case failure in PR 29469 - [2025/05/26] (#29688)
kubaflo May 28, 2025
c768997
[Catalyst] Click-Dragging Behavior in CollectionView (#29616)
Tamilarasan-Paranthaman May 28, 2025
5dcbaed
Fix iOS Label being truncated when using Padding (#29031)
albyrock87 May 29, 2025
44c7fad
Fixed Test case failure in PR 29469 - [2025/05/26] (#29735)
kubaflo May 29, 2025
9877ebc
added snapshot (#29742)
LogishaSelvarajSF4525 May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Android] Fix for the FontImageSource color is not applied properly t…
…o the Bottom Tab Icon (#29317)

* Fixed the FontImageSource Icon color issues on the BottomNavigationView Tabs

* Committed the test sample and case

* Added comment over the fix

* Remove unnecessary space
  • Loading branch information
Ahamed-Ali authored and rmarinho committed May 30, 2025
commit ca91b226507d1dc6b1d1d8f266a1c8fbd09ae7f2
41 changes: 38 additions & 3 deletions src/Controls/src/Core/Platform/Android/TabbedPageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
{
menuItem.SetIcon(result.Value);
});
SetupBottomNavigationViewIconColor(page, menuItem, index);
}
else
{
Expand Down Expand Up @@ -652,8 +653,13 @@ int GetItemTextColor(Color customColor, ColorStateList originalColors)
return customColor?.ToPlatform().ToArgb() ?? originalColors?.DefaultColor ?? 0;
}

protected virtual ColorStateList GetItemIconTintColorState()
protected virtual ColorStateList GetItemIconTintColorState(Page page)
{
if (page.IconImageSource is FontImageSource fontImageSource && fontImageSource.Color is not null)
{
return null;
}

if (_orignalTabIconColors is null)
{
_orignalTabIconColors = IsBottomTabPlacement ? _bottomNavigationView.ItemIconTintList : _tabLayout.TabIconTint;
Expand Down Expand Up @@ -773,7 +779,14 @@ void UpdateItemIconColor()
_newTabIconColors = null;

if (IsBottomTabPlacement)
_bottomNavigationView.ItemIconTintList = GetItemIconTintColorState() ?? _orignalTabIconColors;
{
for (int i = 0; i < _bottomNavigationView.Menu.Size(); i++)
{
var menuItem = _bottomNavigationView.Menu.GetItem(i);
var page = Element.Children[i];
SetupBottomNavigationViewIconColor(page, menuItem, i);
}
}
else
{
for (int i = 0; i < _tabLayout.TabCount; i++)
Expand All @@ -785,6 +798,28 @@ void UpdateItemIconColor()
}
}

void SetupBottomNavigationViewIconColor(Page page, IMenuItem menuItem, int i)
{
// Updating the icon color of each BottomNavigationView item individually works correctly.
// This is necessary because `ItemIconTintList` applies the color globally to all items,
// which doesn't allow for per-item customization.
// Currently, there is no modern API that provides the desired behavior.
// Therefore, the obsolete `BottomNavigationItemView` approach is used.
#pragma warning disable XAOBS001 // Type or member is obsolete
if (_bottomNavigationView.GetChildAt(0) is BottomNavigationMenuView menuView)
{
var itemView = menuView.GetChildAt(i) as BottomNavigationItemView;

if (itemView != null && itemView.Id == menuItem.ItemId)
{
ColorStateList colors = GetItemIconTintColorState(page);

itemView.SetIconTintList(colors);
}
}
#pragma warning restore XAOBS001 // Type or member is obsolete
}

internal void UpdateTabItemStyle()
{
Color barItemColor = BarItemColor;
Expand Down Expand Up @@ -830,7 +865,7 @@ void SetIconColorFilter(Page page, TabLayout.Tab tab, bool selected)
if (icon == null)
return;

ColorStateList colors = (page.IconImageSource is FontImageSource fontImageSource && fontImageSource.Color is not null) ? null : GetItemIconTintColorState();
ColorStateList colors = GetItemIconTintColorState(page);
if (colors == null)
ADrawableCompat.SetTintList(icon, null);
else
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29109.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;
using Button = Microsoft.Maui.Controls.Button;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 29109, "[Android] Unable to set unselected iconImageSource color when toolbar placement is set to bottom", PlatformAffected.Android)]
public class Issue29109 : TestTabbedPage
{
protected override void Init()
{
// Set the toolbar placement to bottom (android specific)
On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetToolbarPlacement(Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom);
// Set tab colors
this.SelectedTabColor = Colors.Red;
this.UnselectedTabColor = Colors.Gray;

// Add tabs
this.Children.Add(new Issue29109Tab1());
this.Children.Add(new Issue29109Tab2());
this.Children.Add(new Issue29109Tab3());
}
}

public class Issue29109Tab1 : ContentPage
{
public Issue29109Tab1()
{
//If no FontImageSource color is given, tab icon should be applied based on the SelectedTabColor and UnselectedTabColor.
IconImageSource = new FontImageSource
{
FontFamily = "Ion",
Glyph = "\uf47e",
Size = 15
};
Button button = new Button
{
Text = "Change Tab Icon Color",
BackgroundColor = Colors.Green,
TextColor = Colors.White
};
button.AutomationId = "Button";
button.Clicked += (s, e) =>
{
//If the FontImageSource color is given, the tab icon color should be applied solely based on the specified color, regardless of the SelectedTabColor or UnselectedTabColor.
(this.IconImageSource as FontImageSource).Color = Colors.Orange;
};
Title = "Tab 1";
var verticalStackLayout = new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label
{
HorizontalOptions = LayoutOptions.Center,
Text = "Tab 1"
},
button
}

};
Content = verticalStackLayout;
}
}

public class Issue29109Tab2 : ContentPage
{
public Issue29109Tab2()
{
//The FontImageSource color is given. So, the tab icon color should be applied based solely on the given color, regardless of the selected tab or unselected tab color.
IconImageSource = new FontImageSource
{
FontFamily = "Ion",
Glyph = "\uf47e",
Color = Colors.DodgerBlue,
Size = 15
};

Title = "Tab 2";
var verticalStackLayout = new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
HorizontalOptions = LayoutOptions.Center,
Text = "Tab 2"
},
}
};
Content = verticalStackLayout;
}
}
public class Issue29109Tab3 : ContentPage
{
public Issue29109Tab3()
{
//The FontImageSource color is given. So, the icon color should be applied based solely on the given color, regardless of the selected tab or unselected tab color.
IconImageSource = new FontImageSource
{
FontFamily = "Ion",
Glyph = "\uf47e",
Color = Colors.Green,
Size = 15
};

Title = "Tab 3";
var verticalStackLayout = new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
HorizontalOptions = LayoutOptions.Center,
Text = "Tab 3"
},
}
};
Content = verticalStackLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if ANDROID
//Since bottom tab placement is specific to Android, I enabled it only for Android: https://learn.microsoft.com/en-us/dotnet/maui/android/platform-specifics/tabbedpage-toolbar-placement?view=net-maui-9.0
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue29109 : _IssuesUITest
{
public Issue29109(TestDevice device) : base(device) { }

public override string Issue => "[Android] Unable to set unselected iconImageSource color when toolbar placement is set to bottom";

[Test, Order(1)]
[Category(UITestCategories.TabbedPage)]
public void FontImageSourceColorShouldApplyOnBottomTabIconOnAndroid()
{
App.WaitForElement("Button");
VerifyScreenshot();
}

[Test, Order(2)]
[Category(UITestCategories.TabbedPage)]
public void DynamicFontImageSourceColorShouldApplyOnBottomTabIconOnAndroid()
{
App.WaitForElement("Button");
App.Tap("Button");
VerifyScreenshot();
}
}
}
#endif