diff --git a/extensions/interfaces/igeneric-object.ts b/extensions/interfaces/igeneric-object.ts new file mode 100644 index 0000000..7631326 --- /dev/null +++ b/extensions/interfaces/igeneric-object.ts @@ -0,0 +1,3 @@ +export interface IGenericObject { + [index: string]: TValue; +} \ No newline at end of file diff --git a/extensions/material.theme.config.ts b/extensions/material.theme.config.ts new file mode 100644 index 0000000..4e53126 --- /dev/null +++ b/extensions/material.theme.config.ts @@ -0,0 +1,33 @@ +import * as vscode from 'vscode'; + +import { COMMAND_THEME_SETTER } from "./theme-setter/index"; +import { IGenericObject } from "./interfaces/igeneric-object"; + +enum Commands { + ACCENTS, + COLOR_THEME +} + +const OPTIONS: IGenericObject = { + 'Change accents': Commands.ACCENTS, + 'Change color scheme': Commands.COLOR_THEME +} + +export function activate(context: vscode.ExtensionContext) { + // registering the command + let command = vscode.commands.registerCommand('material.theme.config', () => { + // the user is going to choose what aspect of theme to config + vscode.window.showQuickPick(Object.keys(OPTIONS)).then(response => { + // switching selected option + switch(OPTIONS[response]) { + // case Commands.ACCENTS: + + // break; + case Commands.COLOR_THEME: + COMMAND_THEME_SETTER(); + break; + } + }); + }); + context.subscriptions.push(command); +} diff --git a/extensions/theme-setter/index.ts b/extensions/theme-setter/index.ts new file mode 100644 index 0000000..c576b55 --- /dev/null +++ b/extensions/theme-setter/index.ts @@ -0,0 +1,18 @@ +import * as vscode from 'vscode'; + +import { THEMES } from './themes'; + +export const COMMAND_THEME_SETTER = () => { + vscode.window.showQuickPick(Object.keys(THEMES)).then(themeSelected => { + + vscode.workspace.getConfiguration().update('workbench.colorTheme', THEMES[themeSelected], true).then(() => { + if (themeSelected === undefined) return; + + vscode.window.showInformationMessage(`${ themeSelected } theme set.`); + }, () => { + if (themeSelected === undefined) return; + + vscode.window.showErrorMessage(`Cannot set theme ${ themeSelected }, please report this bug to the Material theme devs.`); + }); + }); +}; \ No newline at end of file diff --git a/extensions/theme-setter/themes.ts b/extensions/theme-setter/themes.ts new file mode 100644 index 0000000..2813753 --- /dev/null +++ b/extensions/theme-setter/themes.ts @@ -0,0 +1,8 @@ +import { IGenericObject } from "../interfaces/igeneric-object"; + +export const THEMES: IGenericObject = { + Default: 'Material Theme', + Darker: 'Material Theme Darker', + Lighter: 'Material Theme Lighter', + 'Pale night': 'Material Theme Palenight' +} \ No newline at end of file diff --git a/package.json b/package.json index a80ec69..51fe770 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "build-icons": "npm run remove-icons && npm run minimize-icons && gulp build:icons && npm run minimize-json", "build-themes": "gulp build:themes", "release": "npm run bump && npm run changelog", + "postinstall": "node ./node_modules/vscode/bin/instal", "changelog": "gulp changelog", "bump": "gulp bump" }, @@ -38,7 +39,18 @@ "Themes", "Other" ], + "activationEvents": [ + "onCommand:material.theme.config" + ], + "main": "./extensions/material.theme.config", "contributes": { + "commands": [ + { + "category": "Material theme", + "command": "material.theme.config", + "title": "Material theme settings" + } + ], "themes": [ { "label": "Material Theme", @@ -104,6 +116,7 @@ "run-sequence": "^1.2.2", "svgo": "^0.7.1", "typescript": "2.3.3", + "vscode": "^1.1.0", "yamljs": "^0.2.10", "yargs": "^7.1.0" }