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

[iOS] SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored - fix #27389

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27377.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue27377"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<VerticalStackLayout>
<Border
VerticalOptions="Start"
StrokeThickness="1">
<SwipeView x:Name="swipeView">
<SwipeView.RightItems>
<SwipeItem
Text="Action"
x:Name="swipeItem"
BackgroundColor="Orange">
<SwipeItem.IconImageSource>
<FontImageSource
FontFamily="Ionicons"
Color="Red"
Size="22"
Glyph="T"/>
</SwipeItem.IconImageSource>
</SwipeItem>
</SwipeView.RightItems>
<Label
Text="SwipeView"
HeightRequest="100"
VerticalTextAlignment="Center"/>
</SwipeView>
</Border>
<Button Text="Open"
AutomationId="Button"
Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ContentPage>
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27377.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 27377, "SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored", PlatformAffected.iOS)]
public partial class Issue27377 : ContentPage
{
public Issue27377()
{
InitializeComponent();
}

private void Button_Clicked(object sender, EventArgs e)
{
swipeView.Open(OpenSwipeItem.RightItems, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if ANDROID || IOS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

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

public override string Issue => "SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored";

[Test]
[Category(UITestCategories.SwipeView)]
public void FontImageSourceShouldHonorColor()
{
App.WaitForElement("Button");
App.Click("Button");
VerifyScreenshot();
kubaflo marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ public override void SetImageSource(UIImage? platformImage)

try
{
button.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
var tintColor = item.GetTextColor();

if (tintColor != null)
button.TintColor = tintColor.ToPlatform();
if (item.Source is IFontImageSource fontImageSource && fontImageSource.Color != null)
{
button.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.Automatic), UIControlState.Normal);
}
else
{
button.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);

var tintColor = item.GetTextColor();

if (tintColor != null)
button.TintColor = tintColor.ToPlatform();
}
}
catch (Exception)
{
Expand Down
Loading