Skip to content

Commit ec68db2

Browse files
kubaflormarinho
authored andcommitted
ToolbarItem behavior with ImageSource iOS - fix (#28833)
* ToolbarItem behavior with ImageSource iOS - fix * Added snapshots
1 parent 5cde5df commit ec68db2

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

src/Controls/src/Core/Compatibility/iOS/Extensions/ToolbarItemExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ void UpdateIconAndStyle(ToolbarItem item)
112112
}
113113
item.IconImageSource.LoadImage(mauiContext, result =>
114114
{
115-
Image = result?.Value;
115+
Image = item.IconImageSource is not FontImageSource
116+
? result?.Value.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
117+
: result?.Value;
116118
Style = UIBarButtonItemStyle.Plain;
117119
});
118120
}
22.6 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
4+
[Issue(IssueTracker.Github, 28822, "ToolbarItem behavior with ImageSource iOS", PlatformAffected.iOS)]
5+
public class Issue28822NavigationPage : NavigationPage
6+
{
7+
public Issue28822NavigationPage() : base(new Issue28822()) { }
8+
9+
public class Issue28822 : ContentPage
10+
{
11+
public Issue28822()
12+
{
13+
ToolbarItems.Add(new ToolbarItem()
14+
{
15+
IconImageSource = ImageSource.FromFile("dotnet_bot.png"),
16+
});
17+
18+
ToolbarItems.Add(new ToolbarItem()
19+
{
20+
IconImageSource = new FontImageSource()
21+
{
22+
Glyph = "+",
23+
Color = Colors.Red,
24+
Size = 20,
25+
}
26+
});
27+
28+
Content = new Label()
29+
{
30+
Text = "Hello, World!",
31+
AutomationId = "HelloWorldLabel"
32+
};
33+
}
34+
}
35+
}
36+
}
8.73 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class Issue28822 : _IssuesUITest
8+
{
9+
public Issue28822(TestDevice testDevice) : base(testDevice)
10+
{
11+
}
12+
13+
public override string Issue => "ToolbarItem behavior with ImageSource iOS";
14+
15+
[Test]
16+
[Category(UITestCategories.ToolbarItem)]
17+
public void ToolbarItemShouldBeCorrectlyRendered()
18+
{
19+
App.WaitForElement("HelloWorldLabel");
20+
VerifyScreenshot();
21+
}
22+
}
23+
}
6.35 KB
Loading
28 KB
Loading

0 commit comments

Comments
 (0)