Skip to content

Commit d1a5cc8

Browse files
committed
Add theme mode api functions
1 parent d7d17a9 commit d1a5cc8

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,5 +595,16 @@ public interface IPublicAPI
595595
/// </summary>
596596
/// <returns>The time taken to execute the method in milliseconds</returns>
597597
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
598+
599+
/// <summary>
600+
/// Representing whether the application is using a dark theme
601+
/// </summary>
602+
/// <returns></returns>
603+
bool IsApplicationDarkTheme();
604+
605+
/// <summary>
606+
/// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off.
607+
/// </summary>
608+
event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged;
598609
}
599610
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
using System.Windows.Media;
1515
using CommunityToolkit.Mvvm.DependencyInjection;
1616
using Flow.Launcher.Core;
17+
using Flow.Launcher.Core.ExternalPlugins;
1718
using Flow.Launcher.Core.Plugin;
1819
using Flow.Launcher.Core.Resource;
19-
using Flow.Launcher.Core.ExternalPlugins;
2020
using Flow.Launcher.Core.Storage;
2121
using Flow.Launcher.Helper;
2222
using Flow.Launcher.Infrastructure;
23-
using Flow.Launcher.Infrastructure.Http;
2423
using Flow.Launcher.Infrastructure.Hotkey;
24+
using Flow.Launcher.Infrastructure.Http;
2525
using Flow.Launcher.Infrastructure.Image;
2626
using Flow.Launcher.Infrastructure.Logger;
2727
using Flow.Launcher.Infrastructure.Storage;
2828
using Flow.Launcher.Infrastructure.UserSettings;
2929
using Flow.Launcher.Plugin;
30-
using Flow.Launcher.Plugin.SharedModels;
3130
using Flow.Launcher.Plugin.SharedCommands;
31+
using Flow.Launcher.Plugin.SharedModels;
3232
using Flow.Launcher.ViewModel;
3333
using JetBrains.Annotations;
34+
using ModernWpf;
3435
using Squirrel;
3536
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
3637

@@ -587,6 +588,17 @@ public long StopwatchLogInfo(string className, string message, Action action, [C
587588
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
588589
Stopwatch.InfoAsync(className, message, action, methodName);
589590

591+
public bool IsApplicationDarkTheme()
592+
{
593+
return ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark;
594+
}
595+
596+
public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged
597+
{
598+
add => _mainVM.ActualApplicationThemeChanged += value;
599+
remove => _mainVM.ActualApplicationThemeChanged -= value;
600+
}
601+
590602
#endregion
591603

592604
#region Private Methods

0 commit comments

Comments
 (0)