mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-27 05:06:42 +00:00
* use theme service on settings load * use window.matchMedia in loadSettings * typo fix * Patched app config to dispatch on OS' theme. Signed-off-by: Akos Kitta <a.kitta@arduino.cc> Co-authored-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
9373a0bcaf
commit
f22be3c587
@ -139,7 +139,10 @@ export class SettingsService {
|
|||||||
this.preferenceService.get<number>(FONT_SIZE_SETTING, 12),
|
this.preferenceService.get<number>(FONT_SIZE_SETTING, 12),
|
||||||
this.preferenceService.get<string>(
|
this.preferenceService.get<string>(
|
||||||
'workbench.colorTheme',
|
'workbench.colorTheme',
|
||||||
'arduino-theme'
|
window.matchMedia &&
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
|
? 'arduino-theme-dark'
|
||||||
|
: 'arduino-theme'
|
||||||
),
|
),
|
||||||
this.preferenceService.get<Settings.AutoSave>(
|
this.preferenceService.get<Settings.AutoSave>(
|
||||||
AUTO_SAVE_SETTING,
|
AUTO_SAVE_SETTING,
|
||||||
|
@ -13,6 +13,9 @@ const {
|
|||||||
const {
|
const {
|
||||||
ApplicationProps,
|
ApplicationProps,
|
||||||
} = require('@theia/application-package/lib/application-props');
|
} = require('@theia/application-package/lib/application-props');
|
||||||
|
const {
|
||||||
|
FrontendApplicationConfigProvider,
|
||||||
|
} = require('@theia/core/lib/browser/frontend-application-config-provider');
|
||||||
|
|
||||||
const lightTheme = 'arduino-theme';
|
const lightTheme = 'arduino-theme';
|
||||||
const darkTheme = 'arduino-theme-dark';
|
const darkTheme = 'arduino-theme-dark';
|
||||||
@ -21,13 +24,19 @@ const defaultTheme =
|
|||||||
? darkTheme
|
? darkTheme
|
||||||
: lightTheme;
|
: lightTheme;
|
||||||
|
|
||||||
|
const originalGet = FrontendApplicationConfigProvider.get;
|
||||||
|
FrontendApplicationConfigProvider.get = function () {
|
||||||
|
const originalProps = originalGet.bind(FrontendApplicationConfigProvider)();
|
||||||
|
return { ...originalProps, defaultTheme };
|
||||||
|
}.bind(FrontendApplicationConfigProvider);
|
||||||
|
|
||||||
const arduinoDarkTheme = {
|
const arduinoDarkTheme = {
|
||||||
id: 'arduino-theme-dark',
|
id: 'arduino-theme-dark',
|
||||||
type: 'dark',
|
type: 'dark',
|
||||||
label: 'Dark (Arduino)',
|
label: 'Dark (Arduino)',
|
||||||
editorTheme: 'arduino-theme-dark',
|
editorTheme: 'arduino-theme-dark',
|
||||||
activate() {},
|
activate() {},
|
||||||
deactivate() { }
|
deactivate() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const arduinoLightTheme = {
|
const arduinoLightTheme = {
|
||||||
@ -36,7 +45,7 @@ const arduinoLightTheme = {
|
|||||||
label: 'Light (Arduino)',
|
label: 'Light (Arduino)',
|
||||||
editorTheme: 'arduino-theme',
|
editorTheme: 'arduino-theme',
|
||||||
activate() {},
|
activate() {},
|
||||||
deactivate() { }
|
deactivate() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!window[ThemeServiceSymbol]) {
|
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.startupTheme();
|
||||||
themeService.setCurrentTheme(defaultTheme);
|
themeService.setCurrentTheme(defaultTheme);
|
||||||
window[ThemeServiceSymbol] = themeService;
|
window[ThemeServiceSymbol] = themeService;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user