Start application in the right theme

Summary:
Changelog: Improved dark mode support!

This diff makes sure that the dark mode preference is written to the Flipper config, and applied during startup, so that the ugly light/dark flash when starting Flipper in dark mode disappears

Reviewed By: passy

Differential Revision: D29436059

fbshipit-source-id: 0f762149848298512026fbd216d9a9e0bf4276db
This commit is contained in:
Michel Weststrate
2021-06-29 08:38:33 -07:00
committed by Facebook GitHub Bot
parent 617f8a928c
commit 014e571f74
5 changed files with 32 additions and 4 deletions

View File

@@ -108,6 +108,9 @@ if (argv['disable-gpu'] || process.env.FLIPPER_DISABLE_GPU === '1') {
}
process.env.CONFIG = JSON.stringify(config);
if (config.darkMode) {
nativeTheme.themeSource = 'dark';
}
// possible reference to main app window
let win: BrowserWindow;
@@ -270,7 +273,6 @@ ipcMain.on('getLaunchTime', (event) => {
});
ipcMain.on('setTheme', (_e, mode: 'light' | 'dark') => {
console.log('Switching to theme ' + mode);
nativeTheme.themeSource = mode;
});
@@ -362,6 +364,7 @@ function createWindow() {
configPath,
JSON.stringify({
...config,
darkMode: nativeTheme.themeSource === 'dark',
lastWindowPosition: {
x,
y,