82cfb4587b
* chore: small cleanup helper * chore: adding interfaces for icon variants * feat: You can now switch between Material Theme icons * chore: helpers small fix * chore(helpers): small fix helpers * refactor: refactoring fixIcons command, ready for new prop autoFix * refactor: accentsSetter command, ready for autoFix prop * chore: added new exports file for all commands * refactor: main theme file, ready for autoFix prop * chore: added listener also when changing iconTheme * feat: autoApplyIcons added as option and toggleApplyIcons as command * chore: added check for autoApplyIcons flag. Removed listen icon change * feat: Notification shows up when the window needs reload * chore: Update CTA's * chore: Make consistent indent guides and add support to editorIndentGuide.activeBackground Close #188 * chore: fix check on CTA ok * chore: split up configurationChange and changelog (added to commands) * chore: small change settings method * feat: Now the theme will auto fix if needed on change icons theme
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import * as vscode from 'vscode';
|
|
|
|
import {IDefaults} from './../interfaces/idefaults';
|
|
import {IThemeCustomProperties} from './../interfaces/itheme-custom-properties';
|
|
import {getPackageJSON} from './fs';
|
|
|
|
/**
|
|
* Gets saved accent
|
|
*/
|
|
export function getAccent(): string | undefined {
|
|
return getCustomSettings().accent;
|
|
}
|
|
|
|
/**
|
|
* Gets custom settings
|
|
*/
|
|
export function getCustomSettings(): IThemeCustomProperties {
|
|
return vscode.workspace.getConfiguration().get<IThemeCustomProperties>('materialTheme', {});
|
|
}
|
|
|
|
/**
|
|
* Get autoApplyIcons
|
|
*/
|
|
export function isAutoApplyEnable(): boolean {
|
|
return vscode.workspace.getConfiguration().get<boolean>('materialTheme.autoApplyIcons', true);
|
|
}
|
|
|
|
/**
|
|
* Checks if a given string could be an accent
|
|
*/
|
|
export function isAccent(accentName: string, defaults: IDefaults): boolean {
|
|
return Boolean(Object.keys(defaults.accents).find(name => name === accentName));
|
|
}
|
|
|
|
/**
|
|
* Determines if the passing theme label is a material theme
|
|
*/
|
|
export function isMaterialTheme(themeName: string): boolean {
|
|
const packageJSON = getPackageJSON();
|
|
return Boolean(packageJSON.contributes.themes.find(contrib => contrib.label === themeName));
|
|
}
|
|
|
|
/**
|
|
* Determines if the passing icons theme is a material theme
|
|
*/
|
|
export function isMaterialThemeIcons(themeIconsName: string): boolean {
|
|
const packageJSON = getPackageJSON();
|
|
return Boolean(packageJSON.contributes.iconThemes.find(contribute => contribute.id === themeIconsName));
|
|
}
|
|
|
|
/**
|
|
* Sets a custom property in custom settings
|
|
*/
|
|
export function setCustomSetting(settingName: string, value: any): Thenable<string> {
|
|
return vscode.workspace.getConfiguration().update(`materialTheme.${settingName}`, value, true).then(() => settingName);
|
|
}
|
|
|
|
/**
|
|
* Updates accent name
|
|
*/
|
|
export function updateAccent(accentName: string): Thenable<string> {
|
|
const prevAccent = getAccent();
|
|
return setCustomSetting('accentPrevious', prevAccent)
|
|
.then(() => setCustomSetting('accent', accentName));
|
|
}
|