Add theme mode api functions

This commit is contained in:
Jack251970 2025-07-05 13:35:28 +08:00
parent d7d17a93cd
commit d1a5cc8e84
2 changed files with 26 additions and 3 deletions

View file

@ -595,5 +595,16 @@ namespace Flow.Launcher.Plugin
/// </summary>
/// <returns>The time taken to execute the method in milliseconds</returns>
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
/// <summary>
/// Representing whether the application is using a dark theme
/// </summary>
/// <returns></returns>
bool IsApplicationDarkTheme();
/// <summary>
/// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off.
/// </summary>
event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged;
}
}

View file

@ -14,23 +14,24 @@ using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Core;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Storage;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher.ViewModel;
using JetBrains.Annotations;
using ModernWpf;
using Squirrel;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
@ -587,6 +588,17 @@ namespace Flow.Launcher
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
Stopwatch.InfoAsync(className, message, action, methodName);
public bool IsApplicationDarkTheme()
{
return ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark;
}
public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged
{
add => _mainVM.ActualApplicationThemeChanged += value;
remove => _mainVM.ActualApplicationThemeChanged -= value;
}
#endregion
#region Private Methods