Skip to content

[iOS] - Fix Custom FlyoutIcon from Being Overridden to Default Color in Shell#27580

Merged
PureWeen merged 10 commits intodotnet:inflight/currentfrom
prakashKannanSf3972:fix-6738
Dec 22, 2025
Merged

[iOS] - Fix Custom FlyoutIcon from Being Overridden to Default Color in Shell#27580
PureWeen merged 10 commits intodotnet:inflight/currentfrom
prakashKannanSf3972:fix-6738

Conversation

@prakashKannanSf3972
Copy link
Contributor

@prakashKannanSf3972 prakashKannanSf3972 commented Feb 5, 2025

Issue: The color of the custom FlyoutIcon in Shell resets to the default blue instead of retaining its original color.

RootCause

By default, UIImageRenderingMode is set to Automatic, allowing the rendering behavior to be determined based on the UI context. When a custom FlyoutIcon is applied, it does not retain its original color but instead adapts to the predefined tinting behavior, leading to unintended color changes.

Description of Change

The image rendering mode is now set to UIImageRenderingMode.AlwaysOriginal, ensuring that custom icons maintain their original colors without being altered by default rendering behavior.

  • When no custom FlyoutIcon is set, its color can still be modified using Shell.ForegroundColor.
  • When a custom FlyoutIcon is applied, it now preserves its original image color without automatic tinting.
  • If color customization for the custom icon is needed, Shell.ForegroundColor should be set accordingly to allow the color modification to be applied.

Issues Fixed

Fixes #6738

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output

Before After

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 5, 2025
@jsuarezruiz jsuarezruiz added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Feb 6, 2025
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 7, 2025
@azure-pipelines

This comment was marked as off-topic.

@prakashKannanSf3972 prakashKannanSf3972 marked this pull request as ready for review February 11, 2025 14:59
Copilot AI review requested due to automatic review settings February 11, 2025 14:59
@prakashKannanSf3972 prakashKannanSf3972 requested a review from a team as a code owner February 11, 2025 14:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

@jsuarezruiz

This comment was marked as off-topic.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@azure-pipelines

This comment was marked as off-topic.

icon = result?.Value;

var foregroundColor = _context.Shell.GetValue(Shell.ForegroundColorProperty);
if (foregroundColor is null)
Copy link
Member

Choose a reason for hiding this comment

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

What if I change the foreground color? Will it change back? Should there be an else statement that sets the UIImageRenderingMode the other way? Can we have that in a (additional) test that we can toggle between the colors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jfversluis,

The Flyout icon updates its color correctly when the foreground color changes dynamically. It does not remain in UIImageRenderingMode.AlwaysOriginal since the image is always loaded with its default rendering mode, allowing it to adapt to the assigned ForegroundColor.

I have added a test to validate this behavior. Let me know if any further refinements are needed.

Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

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

See comment above

@PureWeen PureWeen modified the milestones: .NET 9 SR5, .NET 9 SR6 Mar 7, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Mar 18, 2025
@rmarinho rmarinho changed the base branch from main to inflight/current March 20, 2025 11:28
@rmarinho
Copy link
Member

/rebase

@dotnet dotnet deleted a comment from azure-pipelines bot Mar 20, 2025
@dotnet dotnet deleted a comment from jfversluis Mar 20, 2025
@dotnet dotnet deleted a comment from jsuarezruiz Mar 20, 2025
@dotnet dotnet deleted a comment from jsuarezruiz Mar 20, 2025
App.WaitForElement(defaultColor);
App.Tap(defaultColor);
App.WaitForElement(defaultColor);
VerifyScreenshot("EnsureFlyoutIconAsDefaultIconColor");
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshot on Mac.

Baseline snapshot not yet created: /Users/runner/work/1/s/artifacts/bin/Controls.TestCases.Mac.Tests/Release/net9.0/snapshots/mac/EnsureFlyoutIconAsDefaultIconColor.png
Ensure new snapshot is correct:    /Users/runner/work/1/a/Controls.TestCases.Shared.Tests/snapshots-diff/mac/EnsureFlyoutIconAsDefaultIconColor.png

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 pointing this out. I have added the pending snapshot.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -0,0 +1,43 @@
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a parameter to include or not the TitleBar:

, bool includeTitleBar = false

Could you try it?

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, Yes, including the TitleBar helps clarify the issue with the FlyoutIcon on the Windows platform. Since there is an existing issue, where the ForegroundColor does not work as expected, it has already been reported and tracked in the following issue: #26148

Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

PR Review: Approved ✅

Summary

This PR correctly fixes issue #6738 where custom FlyoutIcon colors in Shell were being overridden to iOS's default blue tint.

Fix Analysis

The solution uses UIImageRenderingMode.AlwaysOriginal when no ForegroundColor is set, which correctly preserves the custom icon's original colors while still allowing tinting when ForegroundColor is explicitly set.

Key changes reviewed:

  1. ✅ Property change handlers correctly trigger UpdateLeftToolbarItems() for ForegroundColorProperty
  2. ✅ Logic correctly checks both CurrentPage and Shell for ForegroundColor
  3. ✅ Test coverage is adequate for iOS/Mac (Windows/Android correctly excluded)
  4. ✅ Test file preprocessor directive #if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID correctly limits tests to iOS/Mac

Minor Suggestion (Optional)

Consider adding a defensive null check on icon before calling ImageWithRenderingMode():

if (foregroundColor is null && icon is not null)
{
    icon = icon.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
}

While unlikely to be null in practice (since image != null is already checked), this would be more defensive.

Tested

  • Built and ran reproduction scenario on iOS simulator
  • Confirmed the fix approach is correct for iOS/UIKit behavior

LGTM! 🚀

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios shell-flyout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the flyout icon color

10 participants