vsc-material-theme/extensions/helpers/settings.ts
Alessio Occhipinti d9ea7c2ea6 Feat/release note webview (#248)
* chore(deps): update dependencies

* chore: renamed custom-settings interface

* WIP: added new Webview handler main class

* WIP: added support for Settings webview

* WIP (webview): added gulp command for copying ui files

* WIP (preview): scripts for building updated

* chore: gitignore

* chore: switched to babel-preset-env and added browserify for bundling

* chore: small changes to webviews (added external interfaces file)

* chore: added new task on task explorer and small fix copy ui task

* WIP: webview HTML, JS and CSS added and ready to be developed

* chore: Test native elements

* chore(release): 2.3.0

* chore: init added release notes webview

* chore: Removed unused import

* chore: fixed build release-notes

* chore: Add release notes template

* chore: Update release notes

* chore: Update release notes template

* chore: Update release notes style

* Create stale.yml

* chore: Update release notes

* chore: Removed show-changelog command
2018-08-29 21:30:40 +02:00

70 lines
2 KiB
TypeScript

import * as vscode from 'vscode';
import {IDefaults} from './../interfaces/idefaults';
import {IThemeCustomSettings} 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(): IThemeCustomSettings {
return vscode.workspace.getConfiguration().get<IThemeCustomSettings>('materialTheme', {});
}
/**
* Get autoApplyIcons
*/
export function isAutoApplyEnable(): boolean {
return vscode.workspace.getConfiguration().get<boolean>('materialTheme.autoApplyIcons');
}
/**
* Get showReloadNotification
*/
export function isReloadNotificationEnable(): boolean {
return vscode.workspace.getConfiguration().get<boolean>('materialTheme.showReloadNotification');
}
/**
* 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> {
return setCustomSetting('accent', accentName);
}