2018-05-18 13:47:22 +02:00
|
|
|
import {
|
|
|
|
ConfigurationChangeEvent
|
|
|
|
} from 'vscode';
|
2018-08-20 22:19:10 +02:00
|
|
|
import {isMaterialThemeIcons, isMaterialTheme, getAccent} from './settings';
|
2018-05-18 13:47:22 +02:00
|
|
|
import {getCurrentThemeIconsID, getCurrentThemeID} from './vscode';
|
2018-08-12 19:09:36 +02:00
|
|
|
import handleAutoapply from './handle-autoapply';
|
2018-08-20 22:19:10 +02:00
|
|
|
import {accentsSetter} from '../commands';
|
2018-05-18 13:47:22 +02:00
|
|
|
|
|
|
|
const onIconsChanged = () => {
|
|
|
|
const currentIconsTheme = getCurrentThemeIconsID();
|
2018-08-12 19:09:36 +02:00
|
|
|
return handleAutoapply(isMaterialThemeIcons(currentIconsTheme));
|
2018-05-18 13:47:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const onThemeChanged = () => {
|
|
|
|
const currentTheme = getCurrentThemeID();
|
2018-08-12 19:09:36 +02:00
|
|
|
return handleAutoapply(isMaterialTheme(currentTheme));
|
2018-05-18 13:47:22 +02:00
|
|
|
};
|
|
|
|
|
2018-08-20 22:19:10 +02:00
|
|
|
const onAccentChanged = () => {
|
|
|
|
const currentTheme = getCurrentThemeID();
|
|
|
|
const currentIconsTheme = getCurrentThemeIconsID();
|
|
|
|
const currentAccent = getAccent();
|
|
|
|
return accentsSetter(currentAccent)
|
|
|
|
.then(() =>
|
|
|
|
handleAutoapply(
|
|
|
|
isMaterialTheme(currentTheme) && isMaterialThemeIcons(currentIconsTheme)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-05-18 13:47:22 +02:00
|
|
|
export const onChangeConfiguration = (event: ConfigurationChangeEvent) => {
|
|
|
|
const isColorTheme = event.affectsConfiguration('workbench.colorTheme');
|
|
|
|
const isIconTheme = event.affectsConfiguration('workbench.iconTheme');
|
2018-08-20 22:19:10 +02:00
|
|
|
const isAccent = event.affectsConfiguration('materialTheme.accent');
|
2018-05-18 13:47:22 +02:00
|
|
|
|
2018-08-12 19:09:36 +02:00
|
|
|
return isIconTheme ? onIconsChanged() :
|
2018-08-20 22:19:10 +02:00
|
|
|
isColorTheme ? onThemeChanged() :
|
|
|
|
isAccent ? onAccentChanged() : null;
|
2018-05-18 13:47:22 +02:00
|
|
|
};
|