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

fix: Android and iOS maincommand tint #1339

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 @@ -84,7 +84,7 @@ protected override void Render()

// Foreground
var hasIconColor = element.TryGetIconColor(out var foregroundColor);
var foregroundOpacity = hasIconColor ? foregroundColor.A / 255d : 0d;
var foregroundOpacity = hasIconColor ? foregroundColor.A / 255d : 1.0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this fix is better than the last (see first commit). We can remove the TryGetColorWithOpacity() check behind the scenes. We are already getting and setting the opacity here so

(1) If the user really wants a lower opacity they can just specify it in the AppBarButton.Opacity property.
(2) If its really just the BitmapIcon's opacity that the user wants to lower it will work as before because we have this


// Visibility
if (element.Visibility == Visibility.Visible)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ protected override void Render()
backButtonAppearance.Normal.TitleTextAttributes = attributes;
backButtonAppearance.Highlighted.TitleTextAttributes = attributes;

backImage = backImage?.ApplyTintColor(foreground);
if (mainCommand is { } && mainCommand.TryGetIconColor(out var _))
{
backImage = backImage?.ApplyTintColor(foregroundColor);
}
}

if (backImage is { })
Expand Down
6 changes: 0 additions & 6 deletions src/Uno.Toolkit.UI/Extensions/AppBarButtonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ public static bool TryGetIconColor(this AppBarButton appBarButton, out Color ico
return true;
}

if (ColorHelper.TryGetColorWithOpacity(appBarButton.Foreground, out var buttonForeground))
{
iconColor = buttonForeground;
return true;
}

return false;
}
}
Expand Down
Loading