From 7b1c34a0bb5dfa6fbd19a067ec5f1a3331791f71 Mon Sep 17 00:00:00 2001 From: David Simpson <45690499+davegarthsimpson@users.noreply.github.com> Date: Thu, 21 Jul 2022 18:36:37 +0200 Subject: [PATCH 1/4] use theme service on settings load --- .../src/browser/dialogs/settings/settings.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts index ca8c4e219..e1df1c158 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts @@ -122,7 +122,6 @@ export class SettingsService { languages, currentLanguage, editorFontSize, - themeId, autoSave, quickSuggestions, autoScaleInterface, @@ -137,10 +136,6 @@ export class SettingsService { ['en', ...(await this.localizationProvider.getAvailableLanguages())], this.localizationProvider.getCurrentLanguage(), this.preferenceService.get(FONT_SIZE_SETTING, 12), - this.preferenceService.get( - 'workbench.colorTheme', - 'arduino-theme' - ), this.preferenceService.get( AUTO_SAVE_SETTING, Settings.AutoSave.DEFAULT_ON @@ -165,7 +160,7 @@ export class SettingsService { const sketchbookPath = await this.fileService.fsPath(new URI(sketchDirUri)); return { editorFontSize, - themeId, + themeId: ThemeService.get().getCurrentTheme().id, languages, currentLanguage, autoSave, From f46d053b857545438c26f997e1fa17e37d006ef9 Mon Sep 17 00:00:00 2001 From: Dave Simpson <45690499+davegarthsimpson@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:35:52 +0200 Subject: [PATCH 2/4] use window.matchMedia in loadSettings --- .../src/browser/dialogs/settings/settings.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts index e1df1c158..6dbf1f61e 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts @@ -122,6 +122,7 @@ export class SettingsService { languages, currentLanguage, editorFontSize, + themeId, autoSave, quickSuggestions, autoScaleInterface, @@ -136,6 +137,13 @@ export class SettingsService { ['en', ...(await this.localizationProvider.getAvailableLanguages())], this.localizationProvider.getCurrentLanguage(), this.preferenceService.get(FONT_SIZE_SETTING, 12), + this.preferenceService.get( + 'workbench.colorTheme', + window.matchMedia && + window.matchMedia('(prefers-color-scheme: dark)').matches + ? 'arduino-theme-dark' + : 'arduino-theme' + ), this.preferenceService.get( AUTO_SAVE_SETTING, Settings.AutoSave.DEFAULT_ON From e9c261348ee2280cf73a322985d9fe7383161b95 Mon Sep 17 00:00:00 2001 From: Dave Simpson <45690499+davegarthsimpson@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:56:46 +0200 Subject: [PATCH 3/4] typo fix --- arduino-ide-extension/src/browser/dialogs/settings/settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts index 6dbf1f61e..3bd5f13c8 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts @@ -168,7 +168,7 @@ export class SettingsService { const sketchbookPath = await this.fileService.fsPath(new URI(sketchDirUri)); return { editorFontSize, - themeId: ThemeService.get().getCurrentTheme().id, + themeId, languages, currentLanguage, autoSave, From 387e52b4c49704e5435a0decbe36f939a054d84c Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Mon, 25 Jul 2022 15:51:55 +0200 Subject: [PATCH 4/4] Patched app config to dispatch on OS' theme. Signed-off-by: Akos Kitta --- electron/build/patch/frontend/index.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/electron/build/patch/frontend/index.js b/electron/build/patch/frontend/index.js index 1d6a9ff32..8908654be 100644 --- a/electron/build/patch/frontend/index.js +++ b/electron/build/patch/frontend/index.js @@ -13,6 +13,9 @@ const { const { ApplicationProps, } = require('@theia/application-package/lib/application-props'); +const { + FrontendApplicationConfigProvider, +} = require('@theia/core/lib/browser/frontend-application-config-provider'); const lightTheme = 'arduino-theme'; const darkTheme = 'arduino-theme-dark'; @@ -21,13 +24,19 @@ const defaultTheme = ? darkTheme : lightTheme; +const originalGet = FrontendApplicationConfigProvider.get; +FrontendApplicationConfigProvider.get = function () { + const originalProps = originalGet.bind(FrontendApplicationConfigProvider)(); + return { ...originalProps, defaultTheme }; +}.bind(FrontendApplicationConfigProvider); + const arduinoDarkTheme = { id: 'arduino-theme-dark', type: 'dark', label: 'Dark (Arduino)', editorTheme: 'arduino-theme-dark', - activate() { }, - deactivate() { } + activate() {}, + deactivate() {}, }; const arduinoLightTheme = { @@ -35,8 +44,8 @@ const arduinoLightTheme = { type: 'light', label: 'Light (Arduino)', editorTheme: 'arduino-theme', - activate() { }, - deactivate() { } + activate() {}, + deactivate() {}, }; if (!window[ThemeServiceSymbol]) { @@ -49,7 +58,11 @@ if (!window[ThemeServiceSymbol]) { ); }, }); - themeService.register(...BuiltinThemeProvider.themes, arduinoDarkTheme, arduinoLightTheme); + themeService.register( + ...BuiltinThemeProvider.themes, + arduinoDarkTheme, + arduinoLightTheme + ); themeService.startupTheme(); themeService.setCurrentTheme(defaultTheme); window[ThemeServiceSymbol] = themeService;