Skip to content

Commit

Permalink
[Android] Avoid to update Shell Toolbar colors if already disposed th…
Browse files Browse the repository at this point in the history
…e Tracker (dotnet#12539)

* Avoid to update Shell Toolbar colors if already disposed the Tracker

* Changes from PR feedback

* Update src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarAppearanceTracker.cs

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>

---------

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
  • Loading branch information
2 people authored and TJ Lambert committed Feb 21, 2023
1 parent 6b39903 commit e6644ae
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ public virtual void ResetAppearance(AToolbar toolbar, IShellToolbarTracker toolb

protected virtual void SetColors(AToolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title)
{
_shellContext.Shell.Toolbar.BarTextColor = title ?? ShellRenderer.DefaultTitleColor;
_shellContext.Shell.Toolbar.BarBackground = new SolidColorBrush(background ?? ShellRenderer.DefaultBackgroundColor);
_shellContext.Shell.Toolbar.IconColor = foreground ?? ShellRenderer.DefaultForegroundColor;
if (_disposed)
return;

Toolbar shellToolbar = _shellContext?.Shell?.Toolbar;

if (shellToolbar is null)
return;

shellToolbar.BarTextColor = title ?? ShellRenderer.DefaultTitleColor;
shellToolbar.BarBackground = new SolidColorBrush(background ?? ShellRenderer.DefaultBackgroundColor);
shellToolbar.IconColor = foreground ?? ShellRenderer.DefaultForegroundColor;
}

#region IDisposable
Expand Down

0 comments on commit e6644ae

Please sign in to comment.