Skip to content
Merged
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 @@ -209,10 +209,6 @@ public static void UpdateBarTextColor(this AToolbar nativeToolbar, Toolbar toolb
{
nativeToolbar.SetTitleTextColor(defaultTitleTextColor);
}
else if (GetDefaultForegroundColor() is { } defaultForegroundColor)
{
nativeToolbar.SetTitleTextColor(defaultForegroundColor.ToPlatform().ToArgb());
}

nativeToolbar.UpdateNavigationIconColor(toolbar);
nativeToolbar.UpdateOverflowIconColor(toolbar);
Expand Down Expand Up @@ -245,32 +241,28 @@ static void UpdateNavigationIconColor(this AToolbar nativeToolbar, Toolbar toolb
{
icon.Color = textColor.ToPlatform().ToArgb();
}
else if (GetDefaultForegroundColor() is { } defaultForegroundColor)
{
icon.Color = defaultForegroundColor.ToPlatform().ToArgb();
}
else if (GetDefaultNavigationIconColor(nativeToolbar) is int defaultNavigationIconColor)
{
icon.Color = defaultNavigationIconColor;
}
}
}

static Color? GetDefaultForegroundColor()
{
return Application.Current?.RequestedTheme switch
{
ApplicationModel.AppTheme.Light => Colors.Black,
ApplicationModel.AppTheme.Dark => Colors.White,
_ => null
};
}

static ColorStateList? GetDefaultTitleTextColor(AToolbar nativeToolbar)
{
var context = nativeToolbar.Context?.GetThemedContext();
return PlatformInterop.GetColorStateListForToolbarStyleableAttribute(context,
Resource.Attribute.toolbarStyle, Resource.Styleable.Toolbar_titleTextColor);
if (RuntimeFeature.IsMaterial3Enabled)
{
var colorContext = context is null
? null
: ColorStateList.ValueOf(new global::Android.Graphics.Color(context.GetThemeAttrColor(Resource.Attribute.colorOnSurface)));
Comment on lines +254 to +258
return colorContext;
}
else
{
return PlatformInterop.GetColorStateListForToolbarStyleableAttribute(context,
Resource.Attribute.toolbarStyle, Resource.Styleable.Toolbar_titleTextColor);
}
}

static int? GetDefaultNavigationIconColor(AToolbar nativeToolbar)
Expand All @@ -281,6 +273,11 @@ static void UpdateNavigationIconColor(this AToolbar nativeToolbar, Toolbar toolb
return null;
}

if (RuntimeFeature.IsMaterial3Enabled)
{
return context.GetThemeAttrColor(Resource.Attribute.colorOnSurface);
}

using var icon = new DrawerArrowDrawable(context);
return icon.Color;
}
Expand All @@ -292,7 +289,7 @@ static void UpdateOverflowIconColor(this AToolbar nativeToolbar, Toolbar toolbar
return;
}

var iconColor = toolbar.IconColor ?? toolbar.BarTextColor ?? GetDefaultForegroundColor();
var iconColor = toolbar.IconColor ?? toolbar.BarTextColor;
if (iconColor is null)
{
overflowIcon.ClearColorFilter();
Expand Down
Loading