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] - Fix Custom FlyoutIcon from Being Overridden to Default Color in Shell #27580

Open
wants to merge 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected virtual void HandleShellPropertyChanged(object sender, PropertyChanged
{
if (e.Is(VisualElement.FlowDirectionProperty))
UpdateFlowDirection();
else if (e.Is(Shell.FlyoutIconProperty))
else if (e.Is(Shell.FlyoutIconProperty) || e.Is(Shell.ForegroundColorProperty))
UpdateLeftToolbarItems();
}

Expand Down Expand Up @@ -350,6 +350,12 @@ void UpdateLeftToolbarItems()
if (image != null)
{
icon = result?.Value;

var foregroundColor = _context.Shell.GetValue(Shell.ForegroundColorProperty);
if (foregroundColor is null)
{
icon = icon.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
}
}
else if (String.IsNullOrWhiteSpace(text) && IsRootPage && _flyoutBehavior == FlyoutBehavior.Flyout)
{
Expand Down
35 changes: 35 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/IssueShell6738.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.None, 6738, "The color of the custom icon in Shell always resets to the default blue", PlatformAffected.iOS | PlatformAffected.macOS)]
public class IssueShell6738 : TestShell
{
protected override void Init()
{
FlyoutBehavior = FlyoutBehavior.Flyout;
FlyoutIcon = "star_flyout.png";

ContentPage contentPage = new ContentPage
{
Content = new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label
{
AutomationId = "Label",
Text = "ContentPage Label"
}
}
}
};

Items.Add(new ShellContent
{
Title = "Home",
Content = contentPage
});
}
}
}
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
@@ -0,0 +1,27 @@
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID
// Windows: The snapshot does not capture the FlyoutIcon applied to the TitleBar.
// Android: The fix has not been implemented, so the icon defaults to white.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class IssueShell6738 : _IssuesUITest
{
public override string Issue => "The color of the custom icon in Shell always resets to the default blue";

public IssueShell6738(TestDevice testDevice) : base(testDevice)
{
}

[Test]
[Category(UITestCategories.Shell)]
public void EnsureCustomFlyoutIconColor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending macOS snapshot. Already available in the latest build:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz,

Thank you for highlighting this! The Pending Snapshot has been added.

{
App.WaitForElement("Label");
VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.