forked from trezor/trezor-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.ts
29 lines (20 loc) · 836 Bytes
/
theme.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { nativeTheme } from 'electron';
import { SuiteThemeVariant } from '@trezor/suite-desktop-api';
import { getThemeSettings, setThemeSettings } from '../libs/store';
import { ipcMain } from '../typed-electron';
import type { Module } from './index';
const setThemeManually = (theme: SuiteThemeVariant) => {
const { logger } = global;
logger.info('theme', `Manually setting app window UI to ${theme} theme.`);
nativeTheme.themeSource = theme;
setThemeSettings(theme);
};
export const init: Module = () => {
const { logger } = global;
const theme = getThemeSettings();
if (theme !== 'system') {
logger.info('theme', `Setting app window UI theme to ${theme}.`);
nativeTheme.themeSource = theme;
}
ipcMain.on('theme/change', (_, newTheme) => setThemeManually(newTheme));
};