Skip to content
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 @@ -15,6 +15,13 @@ public static partial class UIElementExtensions

public static void ChangeAccentColor(this FrameworkElement element, Color baseColor)
{
if (Application.Current.Resources.TryGetValue("AccentColor", out object? existing) &&
existing is SolidColorBrush existingBrush &&
existingBrush.Color.Equals(baseColor))
{
return;
}

Color accentColorMask = baseColor;
Color accentColorTransparent = baseColor;

Expand Down Expand Up @@ -55,30 +62,28 @@ public static void ChangeAccentColor(this FrameworkElement element, Color baseCo

internal static void ReloadPageTheme(this FrameworkElement page)
{
ElementTheme theme = InnerLauncherConfig.CurrentAppTheme switch
ElementTheme target = InnerLauncherConfig.CurrentAppTheme switch
{
AppThemeMode.Dark => ElementTheme.Dark,
AppThemeMode.Light => ElementTheme.Light,
_ => ElementTheme.Default
};

// Force the opposite theme first to ensure ThemeResource re-evaluation.
ElementTheme opposite = target switch
{
ElementTheme.Dark => ElementTheme.Light,
ElementTheme.Light => ElementTheme.Dark,
_ => ElementTheme.Light
};

bool isComplete = false;
while (!isComplete)
{
try
{
page.RequestedTheme = page.RequestedTheme switch
{
ElementTheme.Dark => ElementTheme.Light,
ElementTheme.Light => ElementTheme.Default,
ElementTheme.Default => ElementTheme.Dark,
_ => page.RequestedTheme
};

if (page.RequestedTheme != theme)
{
ReloadPageTheme(page);
}
page.RequestedTheme = opposite;
page.RequestedTheme = target;

isComplete = true;
}
Expand Down
3 changes: 0 additions & 3 deletions CollapseLauncher/Classes/Extension/UIElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,6 @@ internal static ref TReturnType GetApplicationResourceRef<TReturnType>(string re

internal static void SetApplicationResource(string resourceKey, object value)
{
if (!CurrentResourceDictionary.ContainsKey(resourceKey))
throw new KeyNotFoundException($"Application resource with key: {resourceKey} does not exist!");

CurrentResourceDictionary[resourceKey] = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Play(bool isUserRequest = true)
bool hasStaticImage = !string.IsNullOrEmpty(context?.BackgroundImageStaticPath);
if (isUserRequest && hasStaticImage && context != null)
{
LoadImageAtIndex(CurrentSelectedBackgroundIndex, false, CancellationToken.None);
LoadImageAtIndex(CurrentSelectedBackgroundIndex, false, CancellationToken.None, true);
}

// Force to restore autoplay status to true.
Expand All @@ -81,7 +81,7 @@ public void Pause(bool isUserRequest = true)
bool hasStaticImage = !string.IsNullOrEmpty(context?.BackgroundImageStaticPath);
if (isUserRequest && hasStaticImage && context != null)
{
LoadImageAtIndex(CurrentSelectedBackgroundIndex, true, CancellationToken.None);
LoadImageAtIndex(CurrentSelectedBackgroundIndex, true, CancellationToken.None, true);
return;
}

Expand Down
Loading
Loading