Skip to content

Commit

Permalink
Refactor GetIconByTheme()
Browse files Browse the repository at this point in the history
  • Loading branch information
lauren-ciha committed Oct 23, 2024
1 parent 7225b3a commit 180d8f0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tools/SetupFlow/DevHome.SetupFlow/ViewModels/PackageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using DevHome.Services.WindowsPackageManager.Contracts;
using DevHome.SetupFlow.Models;
using DevHome.SetupFlow.Services;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media.Imaging;
using Windows.Storage.Streams;
using Windows.System;
Expand Down Expand Up @@ -96,7 +97,7 @@ public PackageViewModel(

public IWinGetPackage Package => _package;

public BitmapImage Icon => _themeSelector.IsDarkTheme() ? _packageDarkThemeIcon.Value : _packageLightThemeIcon.Value;
public BitmapImage Icon => GetIconByTheme();

public string Name => _package.Name;

Expand Down Expand Up @@ -202,14 +203,13 @@ private void ToggleSelection()
_screenReaderService.Announce(announcementText);
}

public BitmapImage GetLightThemeIcon()
private BitmapImage GetIconByTheme()
{
return _package.LightThemeIcon == null ? DefaultLightPackageIconSource : CreateBitmapImage(_package.LightThemeIcon);
}

public BitmapImage GetDarkThemeIcon()
{
return _package.DarkThemeIcon == null ? DefaultDarkPackageIconSource : CreateBitmapImage(_package.DarkThemeIcon);
return _themeSelector.GetActualTheme() switch
{
ElementTheme.Dark => _package.DarkThemeIcon == null ? DefaultDarkPackageIconSource : CreateBitmapImage(_package.DarkThemeIcon),
_ => _package.LightThemeIcon == null ? DefaultLightPackageIconSource : CreateBitmapImage(_package.LightThemeIcon),
};
}

private BitmapImage CreateBitmapImage(IRandomAccessStream stream)
Expand Down

0 comments on commit 180d8f0

Please sign in to comment.