mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add ActualApplicationThemeChanged in MainViewModel
This commit is contained in:
parent
b440aaab37
commit
5b2b272f76
2 changed files with 34 additions and 1 deletions
|
|
@ -39,7 +39,14 @@ namespace Flow.Launcher.Plugin
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
public delegate void VisibilityChangedEventHandler(object sender, VisibilityChangedEventArgs args);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A delegate for when the actual application theme is changed
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
public delegate void ActualApplicationThemeChangedEventHandler(object sender, ActualApplicationThemeChangedEventArgs args);
|
||||
|
||||
/// <summary>
|
||||
/// The event args for <see cref="VisibilityChangedEventHandler"/>
|
||||
/// </summary>
|
||||
|
|
@ -77,4 +84,15 @@ namespace Flow.Launcher.Plugin
|
|||
/// </summary>
|
||||
public Query Query { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The event args for <see cref="ActualApplicationThemeChangedEventHandler"/>
|
||||
/// </summary>
|
||||
public class ActualApplicationThemeChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// <see langword="true"/> if the application has changed actual theme
|
||||
/// </summary>
|
||||
public bool IsDark { get; init; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ using Flow.Launcher.Plugin;
|
|||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using Flow.Launcher.Storage;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using ModernWpf;
|
||||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
|
|
@ -195,6 +196,18 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
RegisterViewUpdate();
|
||||
_ = RegisterClockAndDateUpdateAsync();
|
||||
|
||||
ThemeManager.Current.ActualApplicationThemeChanged += ThemeManager_ActualApplicationThemeChanged;
|
||||
}
|
||||
|
||||
private void ThemeManager_ActualApplicationThemeChanged(ThemeManager sender, object args)
|
||||
{
|
||||
ActualApplicationThemeChanged?.Invoke(
|
||||
Application.Current,
|
||||
new ActualApplicationThemeChangedEventArgs()
|
||||
{
|
||||
IsDark = sender.ActualApplicationTheme == ApplicationTheme.Dark
|
||||
});
|
||||
}
|
||||
|
||||
private void RegisterViewUpdate()
|
||||
|
|
@ -821,6 +834,7 @@ namespace Flow.Launcher.ViewModel
|
|||
public bool MainWindowVisibilityStatus { get; set; } = true;
|
||||
|
||||
public event VisibilityChangedEventHandler VisibilityChanged;
|
||||
public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged;
|
||||
|
||||
public Visibility ClockPanelVisibility { get; set; }
|
||||
public Visibility SearchIconVisibility { get; set; }
|
||||
|
|
@ -1975,6 +1989,7 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
_resultsViewUpdateTask.Dispose();
|
||||
}
|
||||
ThemeManager.Current.ActualApplicationThemeChanged -= ThemeManager_ActualApplicationThemeChanged;
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue