Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 24738ae

Browse files
committed
Merge pull request #133 from github/shana/110-theme-changes
Fix icon color switch on theme change
2 parents 4c5fee0 + 23819c0 commit 24738ae

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/GitHub.VisualStudio/Base/TeamExplorerNavigationItemBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public TeamExplorerNavigationItemBase(ISimpleApiClientFactory apiFactory, ITeamE
2929
VSColorTheme.ThemeChanged += _ =>
3030
{
3131
OnThemeChanged();
32+
Invalidate();
3233
};
3334

3435
holder.Subscribe(this, UpdateRepo);

src/GitHub.VisualStudio/TeamExplorer/Connect/GitHubInvitationSection.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ public GitHubInvitationSection(IConnectionManager cm, Lazy<IVisualStudioBrowser>
3232
Name = "GitHub";
3333
Provider = "GitHub, Inc.";
3434
Description = Resources.BlurbText;
35-
Icon = GetDrawingForIcon(GetBrushForIcon());
35+
OnThemeChanged();
36+
VSColorTheme.ThemeChanged += _ =>
37+
{
38+
OnThemeChanged();
39+
};
3640

3741
IsVisible = cm.Connections.Count == 0;
3842

3943
cm.Connections.CollectionChanged += (s, e) => IsVisible = cm.Connections.Count == 0;
40-
VSColorTheme.ThemeChanged += OnThemeChanged;
4144
}
4245

4346
public override void Connect()
@@ -57,22 +60,20 @@ void StartFlow(UIControllerFlow controllerFlow)
5760
uiProvider.RunUI(controllerFlow, null);
5861
}
5962

60-
void OnThemeChanged(ThemeChangedEventArgs e)
63+
void OnThemeChanged()
6164
{
62-
Icon = GetDrawingForIcon(GetBrushForIcon());
63-
}
65+
try
66+
{
67+
var color = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey);
68+
var brightness = color.GetBrightness();
69+
var dark = brightness > 0.5f;
6470

65-
static Brush GetBrushForIcon()
66-
{
67-
var brush = Application.Current.TryFindResource(HeaderColors.DefaultTextBrushKey) as Brush;
68-
if (brush == null)
69-
brush = Brushes.Black;
70-
return brush;
71-
}
72-
73-
static DrawingBrush GetDrawingForIcon(Brush color)
74-
{
75-
return SharedResources.GetDrawingForIcon(Octicon.mark_github, color);
71+
Icon = SharedResources.GetDrawingForIcon(Octicon.mark_github, dark ? Helpers.Colors.DarkThemeNavigationItem : Helpers.Colors.LightThemeNavigationItem, dark ? "dark" : "light");
72+
}
73+
catch (ArgumentNullException)
74+
{
75+
// This throws in the unit test runner.
76+
}
7677
}
7778
}
7879
}

0 commit comments

Comments
 (0)