Skip to content

Commit

Permalink
[iOS] Tab Selected Icon Color not changing if using Font icons - fix (#…
Browse files Browse the repository at this point in the history
…22437)

* Added a UITest (#22032)

* Fix #22032

* Added snapshots

* Updated test

* Fixed namespace

* Pending Android snapshot

* Update Issue22032.cs

* UI test improvements

---------

Co-authored-by: Javier Suárez <[email protected]>
  • Loading branch information
kubaflo and jsuarezruiz authored Sep 20, 2024
1 parent a7e3ff8 commit 4b8e604
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22032.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue22032"
SelectedTabColor="Red"
UnselectedTabColor="Green">
<ContentPage Title="Tab1">
<ContentPage.IconImageSource>
<FontImageSource
FontFamily="OpenSansRegular"
Glyph=""
Size="15" />
</ContentPage.IconImageSource>
<Button Text="Switch page"
Clicked="Button_Clicked"
AutomationId="button"/>
</ContentPage>
<ContentPage x:Name="tab2" Title="Tab2">
<ContentPage.IconImageSource>
<FontImageSource
FontFamily="OpenSansRegular"
Glyph="¼"
Size="15" />
</ContentPage.IconImageSource>
<Label
Text="Hello, Maui!"
TextColor="White"
AutomationId="label"/>
</ContentPage>
</TabbedPage>
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22032.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.ComponentModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 22032, "Shell FlyoutItem Tab Selected Icon Color not changing if using Font icons", PlatformAffected.iOS)]
public partial class Issue22032 : TabbedPage
{
public Issue22032()
{
InitializeComponent();
}

void Button_Clicked(object sender, EventArgs e)
{
CurrentPage = tab2;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

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

public override string Issue => "Shell FlyoutItem Tab Selected Icon Color not changing if using Font icons";

[Test]
[Category(UITestCategories.TabbedPage)]
public void SelectedTabIconShouldChangeColor()
{
App.WaitForElement("button");
App.Click("button");
App.WaitForElement("label");

// The test passes if tab1 icon is green and tab2 red
VerifyScreenshot();
}
}
}
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.
2 changes: 1 addition & 1 deletion src/Core/src/ImageSources/iOS/ImageSourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static partial class ImageSourceExtensions
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();

return image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
return image.ImageWithRenderingMode(UIImageRenderingMode.Automatic);
}

internal static UIImage? GetPlatformImage(this IFileImageSource imageSource)
Expand Down

0 comments on commit 4b8e604

Please sign in to comment.