Skip to content

Commit 2a6417c

Browse files
committed
feat: add dynamic icon switching based on application theme (v1.1.0)
1 parent 3c5336e commit 2a6417c

8 files changed

Lines changed: 64 additions & 27 deletions

File tree

.github/workflows/release-package.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Publish Release
2-
32
on:
43
push:
54
branches: [ main ]
@@ -15,7 +14,6 @@ permissions:
1514
jobs:
1615
publish:
1716
runs-on: windows-latest
18-
1917
steps:
2018
- name: Checkout repo
2119
uses: actions/checkout@v4
@@ -37,7 +35,6 @@ jobs:
3735
run: |
3836
$new = '${{ steps.version.outputs.prop }}'
3937
$old = '${{ steps.latest.outputs.latest_version }}'.TrimStart('v')
40-
4138
if ($new -ne $old) {
4239
"required=true" >> $env:GITHUB_OUTPUT
4340
} else {
@@ -72,28 +69,35 @@ jobs:
7269
$pluginName = "Flow.Launcher.Plugin.SpeedTest"
7370
$rootFolder = "Speed Test-$env:VERSION"
7471
$zipFile = "$pluginName-$env:VERSION.zip"
75-
7672
# Create root folder
7773
New-Item -ItemType Directory $rootFolder | Out-Null
78-
7974
# Copy plugin files into root folder
8075
Copy-Item ".\bin\Release\Flow.Launcher.Plugin.SpeedTest.dll" $rootFolder -Force
8176
Copy-Item ".\plugin.json" $rootFolder -Force
82-
Copy-Item ".\icon.png" $rootFolder -Force
83-
77+
# Copy icon files (both light and dark versions)
78+
Copy-Item ".\icon-light.png" $rootFolder -Force
79+
Copy-Item ".\icon-dark.png" $rootFolder -Force
8480
# Compress the root folder itself (preserves folder inside zip)
8581
Compress-Archive -Path $rootFolder -DestinationPath $zipFile -Force
86-
8782
# Clean up temporary folder
8883
Remove-Item $rootFolder -Recurse -Force
89-
9084
Write-Host "Package created: $zipFile"
9185
86+
- name: Prepare release notes
87+
if: steps.check.outputs.required == 'true'
88+
id: release_body
89+
shell: pwsh
90+
run: |
91+
$body = Get-Content -Raw -Path "CHANGELOG.md"
92+
echo "body<<EOH`n$body`nEOH" >> $GITHUB_OUTPUT
93+
9294
- name: Publish GitHub Release
9395
if: steps.check.outputs.required == 'true'
9496
uses: softprops/action-gh-release@v2
9597
with:
9698
tag_name: v${{ steps.version.outputs.prop }}
99+
name: "Speed Test v${{ steps.version.outputs.prop }}"
100+
body: ${{ steps.release_body.outputs.body }}
97101
files: Flow.Launcher.Plugin.SpeedTest-${{ steps.version.outputs.prop }}.zip
98102
env:
99103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added dynamic icon switching based on Flow Launcher theme

Flow.Launcher.Plugin.SpeedTest.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Flow.Launcher.Plugin" Version="2.1.0" />
14+
<PackageReference Include="Flow.Launcher.Plugin" Version="5.1.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
1818
<Content Include="plugin.json">
1919
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2020
</Content>
21-
<Content Include="icon.png">
21+
<Content Include="icon*.png">
2222
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2323
</Content>
2424
</ItemGroup>

build.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ if ($LASTEXITCODE -ne 0) {
3131

3232
Write-Host "Build ok" -ForegroundColor Green
3333

34-
# create release package
3534
if ($Package) {
3635
$temp = ".\package"
3736
$rootName = "Speed Test-$Version"
@@ -45,9 +44,11 @@ if ($Package) {
4544
$packageRoot = Join-Path $temp $rootName
4645
New-Item -ItemType Directory -Path $packageRoot | Out-Null
4746

48-
Copy-Item ".\bin\Release\*.dll" $packageRoot -Force
47+
$dllPath = Get-ChildItem ".\bin\Release" -Recurse -Filter "Flow.Launcher.Plugin.SpeedTest.dll" | Select-Object -First 1
48+
Copy-Item $dllPath.FullName $packageRoot -Force
4949
Copy-Item ".\plugin.json" $packageRoot -Force
50-
Copy-Item ".\icon.png" $packageRoot -Force
50+
Copy-Item ".\icon-light.png" $packageRoot -Force
51+
Copy-Item ".\icon-dark.png" $packageRoot -Force
5152

5253
if (Test-Path $zip) { Remove-Item $zip -Force }
5354
Compress-Archive -Path "$temp\*" -DestinationPath $zip -Force
@@ -70,9 +71,11 @@ elseif ($Install) {
7071
}
7172
New-Item -ItemType Directory -Path $installPath -Force | Out-Null
7273

73-
Copy-Item ".\bin\Release\*.dll" $installPath -Force
74+
$dllPath = Get-ChildItem ".\bin\Release" -Recurse -Filter "Flow.Launcher.Plugin.SpeedTest.dll" | Select-Object -First 1
75+
Copy-Item $dllPath.FullName $installPath -Force
7476
Copy-Item ".\plugin.json" $installPath -Force
75-
Copy-Item ".\icon.png" $installPath -Force
77+
Copy-Item ".\icon-light.png" $installPath -Force
78+
Copy-Item ".\icon-dark.png" $installPath -Force
7679

7780
Write-Host "Installed to $installPath" -ForegroundColor Green
7881
Write-Host "Restart Flow Launcher" -ForegroundColor Cyan

icon-dark.png

36.7 KB
Loading
File renamed without changes.

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"Name": "Speed Test",
55
"Description": "Test your internet connection speed",
66
"Author": "swopnil7",
7-
"Version": "1.0.0",
7+
"Version": "1.1.0",
88
"Language": "csharp",
99
"Website": "https://github.com/swopnil7/Flow.Launcher.Plugin.SpeedTest",
10-
"IcoPath": "icon.png",
10+
"IcoPath": "icon-dark.png",
1111
"ExecuteFileName": "Flow.Launcher.Plugin.SpeedTest.dll"
1212
}

src/Main.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Diagnostics;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using System.Windows;
78

89
namespace Flow.Launcher.Plugin.SpeedTest
910
{
@@ -22,14 +23,41 @@ public class Main : IAsyncPlugin, IPluginI18n
2223
private Timer? _updateTimer;
2324
private string? _lastError;
2425
private DateTime _lastQueryTime;
26+
private bool _isDarkTheme;
2527

2628
public Task InitAsync(PluginInitContext context)
2729
{
2830
_context = context;
2931
_settings = context.API.LoadSettingJsonStorage<Settings>();
32+
33+
var dispatcher = Application.Current?.Dispatcher;
34+
if (dispatcher != null)
35+
{
36+
if (dispatcher.CheckAccess())
37+
_isDarkTheme = context.API.IsApplicationDarkTheme();
38+
else
39+
dispatcher.Invoke(() => _isDarkTheme = context.API.IsApplicationDarkTheme());
40+
}
41+
42+
context.API.ActualApplicationThemeChanged += (_, __) =>
43+
{
44+
var disp = Application.Current?.Dispatcher;
45+
if (disp != null)
46+
{
47+
if (disp.CheckAccess())
48+
_isDarkTheme = _context.API.IsApplicationDarkTheme();
49+
else
50+
disp.Invoke(() => _isDarkTheme = _context.API.IsApplicationDarkTheme());
51+
52+
_context?.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true);
53+
}
54+
};
55+
3056
return Task.CompletedTask;
3157
}
3258

59+
private string GetIcon() => _isDarkTheme ? "icon-dark.png" : "icon-light.png";
60+
3361
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
3462
{
3563
var results = new List<Result>();
@@ -51,8 +79,9 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5179
{
5280
Title = "Testing your internet speed...",
5381
SubTitle = "Connecting to nearest server...",
54-
IcoPath = "icon.png"
82+
IcoPath = GetIcon()
5583
});
84+
5685
return results;
5786
}
5887

@@ -62,7 +91,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
6291
{
6392
Title = _currentStatus ?? "Connecting to server...",
6493
SubTitle = BuildProgressText(),
65-
IcoPath = "icon.png"
94+
IcoPath = GetIcon()
6695
});
6796
}
6897
else if (_lastResult != null)
@@ -76,7 +105,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
76105
{
77106
Title = $"↓ {_lastResult.DownloadSpeed:F1} Mbps ↑ {_lastResult.UploadSpeed:F1} Mbps",
78107
SubTitle = $"Ping: {_lastResult.Ping:F0} ms • {_lastResult.ServerName}{timeStr} • Enter to retest",
79-
IcoPath = "icon.png",
108+
IcoPath = GetIcon(),
80109
Action = _ =>
81110
{
82111
_lastResult = null;
@@ -90,21 +119,21 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
90119
{
91120
Title = $"↓ Download: {_lastResult.DownloadSpeed:F2} Mbps",
92121
SubTitle = $"Jitter: {_lastResult.DownloadJitter:F1} ms • Latency: {_lastResult.DownloadLatency:F1} ms",
93-
IcoPath = "icon.png"
122+
IcoPath = GetIcon()
94123
});
95124

96125
results.Add(new Result
97126
{
98127
Title = $"↑ Upload: {_lastResult.UploadSpeed:F2} Mbps",
99128
SubTitle = $"Jitter: {_lastResult.UploadJitter:F1} ms • Latency: {_lastResult.UploadLatency:F1} ms",
100-
IcoPath = "icon.png"
129+
IcoPath = GetIcon()
101130
});
102131

103132
results.Add(new Result
104133
{
105134
Title = $"📍 {_lastResult.ServerName}",
106135
SubTitle = $"{_lastResult.ServerLocation} • ISP: {_lastResult.ISP}",
107-
IcoPath = "icon.png"
136+
IcoPath = GetIcon()
108137
});
109138

110139
if (!string.IsNullOrEmpty(_lastResult.ResultUrl))
@@ -113,7 +142,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
113142
{
114143
Title = "View detailed results online",
115144
SubTitle = _lastResult.ResultUrl,
116-
IcoPath = "icon.png",
145+
IcoPath = GetIcon(),
117146
Action = _ =>
118147
{
119148
Process.Start(new ProcessStartInfo(_lastResult.ResultUrl) { UseShellExecute = true });
@@ -128,7 +157,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
128157
{
129158
Title = "⚠️ Speed test failed",
130159
SubTitle = _lastError + " • Enter to retry",
131-
IcoPath = "icon.png",
160+
IcoPath = GetIcon(),
132161
Action = _ =>
133162
{
134163
_lastError = null;
@@ -231,4 +260,4 @@ private void RunTest()
231260
}
232261

233262
public class Settings { }
234-
}
263+
}

0 commit comments

Comments
 (0)