mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
More tweaking
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { setWindowTheme } from "@yaakapp-internal/mac-window";
|
||||
import {
|
||||
applyThemeToDocument,
|
||||
@@ -10,23 +9,22 @@ import {
|
||||
subscribeToPreferredAppearance,
|
||||
type Appearance,
|
||||
} from "@yaakapp-internal/theme";
|
||||
import { showWindow } from "./tauri";
|
||||
|
||||
export function initTheme() {
|
||||
setPlatformOnDocument(platformFromUserAgent(navigator.userAgent));
|
||||
setPlatformOnDocument(platformFromUserAgent(navigator.userAgent));
|
||||
|
||||
// Apply a quick initial theme based on CSS media query
|
||||
let preferredAppearance: Appearance = getCSSAppearance();
|
||||
// Apply a quick initial theme based on CSS media query
|
||||
let preferredAppearance: Appearance = getCSSAppearance();
|
||||
applyTheme(preferredAppearance);
|
||||
|
||||
// Then subscribe to accurate OS appearance detection and changes
|
||||
subscribeToPreferredAppearance((a) => {
|
||||
preferredAppearance = a;
|
||||
applyTheme(preferredAppearance);
|
||||
});
|
||||
|
||||
// Then subscribe to accurate OS appearance detection and changes
|
||||
subscribeToPreferredAppearance((a) => {
|
||||
preferredAppearance = a;
|
||||
applyTheme(preferredAppearance);
|
||||
});
|
||||
|
||||
// Show window after initial theme is applied (window starts hidden to prevent flash)
|
||||
getCurrentWebviewWindow().show().catch(console.error);
|
||||
}
|
||||
// Show window after initial theme is applied (window starts hidden to prevent flash)
|
||||
showWindow().catch(console.error);
|
||||
|
||||
function applyTheme(appearance: Appearance) {
|
||||
const theme = appearance === "dark" ? defaultDarkTheme : defaultLightTheme;
|
||||
|
||||
Reference in New Issue
Block a user