mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-05 12:31:47 +02:00
Fix theme
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { linter } from '@codemirror/lint';
|
import { linter } from '@codemirror/lint';
|
||||||
import type { HttpRequest } from '@yaakapp-internal/models';
|
import type { HttpRequest } from '@yaakapp-internal/models';
|
||||||
import { patchModel } from '@yaakapp-internal/models';
|
import { patchModel } from '@yaakapp-internal/models';
|
||||||
|
import { Icon } from '@yaakapp-internal/ui';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useKeyValue } from '../hooks/useKeyValue';
|
import { useKeyValue } from '../hooks/useKeyValue';
|
||||||
import { textLikelyContainsJsonComments } from '../lib/jsonComments';
|
import { textLikelyContainsJsonComments } from '../lib/jsonComments';
|
||||||
@@ -10,7 +11,6 @@ import { Dropdown } from './core/Dropdown';
|
|||||||
import type { EditorProps } from './core/Editor/Editor';
|
import type { EditorProps } from './core/Editor/Editor';
|
||||||
import { jsonParseLinter } from './core/Editor/json-lint';
|
import { jsonParseLinter } from './core/Editor/json-lint';
|
||||||
import { Editor } from './core/Editor/LazyEditor';
|
import { Editor } from './core/Editor/LazyEditor';
|
||||||
import { Icon } from './core/Icon';
|
|
||||||
import { IconButton } from './core/IconButton';
|
import { IconButton } from './core/IconButton';
|
||||||
import { IconTooltip } from './core/IconTooltip';
|
import { IconTooltip } from './core/IconTooltip';
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,35 @@
|
|||||||
|
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
|
import { setWindowTheme } from "@yaakapp-internal/mac-window";
|
||||||
import {
|
import {
|
||||||
applyThemeToDocument,
|
applyThemeToDocument,
|
||||||
defaultDarkTheme,
|
defaultDarkTheme,
|
||||||
|
defaultLightTheme,
|
||||||
|
getCSSAppearance,
|
||||||
platformFromUserAgent,
|
platformFromUserAgent,
|
||||||
setPlatformOnDocument,
|
setPlatformOnDocument,
|
||||||
|
subscribeToPreferredAppearance,
|
||||||
|
type Appearance,
|
||||||
} from "@yaakapp-internal/theme";
|
} from "@yaakapp-internal/theme";
|
||||||
|
|
||||||
setPlatformOnDocument(platformFromUserAgent(navigator.userAgent));
|
setPlatformOnDocument(platformFromUserAgent(navigator.userAgent));
|
||||||
applyThemeToDocument(defaultDarkTheme);
|
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show window after initial theme is applied (window starts hidden to prevent flash)
|
||||||
|
getCurrentWebviewWindow().show().catch(console.error);
|
||||||
|
|
||||||
|
function applyTheme(appearance: Appearance) {
|
||||||
|
const theme = appearance === "dark" ? defaultDarkTheme : defaultLightTheme;
|
||||||
|
applyThemeToDocument(theme);
|
||||||
|
if (theme.base.surface != null) {
|
||||||
|
setWindowTheme(theme.base.surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"core:window:allow-is-maximized",
|
"core:window:allow-is-maximized",
|
||||||
"core:window:allow-maximize",
|
"core:window:allow-maximize",
|
||||||
"core:window:allow-minimize",
|
"core:window:allow-minimize",
|
||||||
|
"core:window:allow-show",
|
||||||
"core:window:allow-start-dragging",
|
"core:window:allow-start-dragging",
|
||||||
"core:window:allow-unmaximize",
|
"core:window:allow-unmaximize",
|
||||||
"yaak-mac-window:default"
|
"yaak-mac-window:default"
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub fn run() {
|
|||||||
label: "main_0",
|
label: "main_0",
|
||||||
title: "Yaak Proxy",
|
title: "Yaak Proxy",
|
||||||
inner_size: Some((1000.0, 700.0)),
|
inner_size: Some((1000.0, 700.0)),
|
||||||
visible: true,
|
visible: false,
|
||||||
hide_titlebar: true,
|
hide_titlebar: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user