diff --git a/src/UniGetUI.Avalonia/Infrastructure/TrayService.cs b/src/UniGetUI.Avalonia/Infrastructure/TrayService.cs index f19d76fbb3..a42a4d1eaf 100644 --- a/src/UniGetUI.Avalonia/Infrastructure/TrayService.cs +++ b/src/UniGetUI.Avalonia/Infrastructure/TrayService.cs @@ -38,7 +38,18 @@ public TrayService(MainWindow owner) Menu = BuildMenu(owner, _restartComputerItem), }; + // macOS tints the menu bar from the wallpaper, not from the system appearance, so no theme + // check can pick the right glyph; a template icon is masked and tinted by macOS itself. + if (OperatingSystem.IsMacOS()) + { + MacOSProperties.SetIsTemplateIcon(_trayIcon, true); + } + PendingRebootStore.Changed += OnPendingRebootStoreChanged; + if (Application.Current?.PlatformSettings is { } platformSettings) + { + platformSettings.ColorValuesChanged += OnPlatformColorValuesChanged; + } _trayIcon.Clicked += (_, _) => Dispatcher.UIThread.Post(() => owner.ShowFromTray()); @@ -144,15 +155,30 @@ private static bool IsTaskbarLight() return false; } #else - // On Linux (and other platforms), mirror the app's active theme variant so - // the icon remains legible regardless of the desktop colour scheme. - return Application.Current?.ActualThemeVariant == ThemeVariant.Light; + // macOS: the icon is a template (see the constructor), only its alpha is used. + if (OperatingSystem.IsMacOS()) + { + return true; + } + + // The Linux panel follows the desktop appearance, not UniGetUI's own theme. + var app = Application.Current; + PlatformThemeVariant? osVariant = app?.PlatformSettings?.GetColorValues().ThemeVariant; + if (osVariant is not null) + { + return osVariant == PlatformThemeVariant.Light; + } + + return app?.ActualThemeVariant == ThemeVariant.Light; #endif } private void OnPendingRebootStoreChanged(object? sender, EventArgs e) => Dispatcher.UIThread.Post(UpdateStatus); + private void OnPlatformColorValuesChanged(object? sender, PlatformColorValues e) + => Dispatcher.UIThread.Post(UpdateStatus); + private static NativeMenu BuildMenu(MainWindow owner, NativeMenuItem restartComputerItem) { var menu = new NativeMenu(); @@ -194,6 +220,11 @@ public void Dispose() { PendingRebootStore.Changed -= OnPendingRebootStoreChanged; var app = Application.Current; + if (app?.PlatformSettings is { } platformSettings) + { + platformSettings.ColorValuesChanged -= OnPlatformColorValuesChanged; + } + if (app is not null) TrayIcon.GetIcons(app)?.Remove(_trayIcon); _trayIcon.Dispose();