1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-30 12:54:31 +01:00

theme settings

This commit is contained in:
Kyle Spearrin 2018-05-29 23:28:58 -04:00
parent 689e7a4999
commit 957e460a43
5 changed files with 40 additions and 1 deletions

2
jslib

@ -1 +1 @@
Subproject commit f99b34d0622873b49f1cd9b8c586da563172cda1 Subproject commit 49dece79834e9d93be923dbc2fa8f9edc26f9adf

View File

@ -62,6 +62,13 @@
</div> </div>
<small class="help-block">{{'gaDesc' | i18n}}</small> <small class="help-block">{{'gaDesc' | i18n}}</small>
</div> </div>
<div class="form-group">
<label for="theme">{{'theme' | i18n}}</label>
<select id="theme" name="Theme" [(ngModel)]="theme" (change)="saveTheme()">
<option *ngFor="let o of themeOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
<small class="help-block">{{'themeDesc' | i18n}}</small>
</div>
<div class="form-group"> <div class="form-group">
<label for="locale">{{'language' | i18n}}</label> <label for="locale">{{'language' | i18n}}</label>
<select id="locale" name="Locale" [(ngModel)]="locale" (change)="saveLocale()"> <select id="locale" name="Locale" [(ngModel)]="locale" (change)="saveLocale()">

View File

@ -33,6 +33,8 @@ export class SettingsComponent implements OnInit {
locale: string; locale: string;
lockOptions: any[]; lockOptions: any[];
localeOptions: any[]; localeOptions: any[];
theme: string;
themeOptions: any[];
constructor(private analytics: Angulartics2, private toasterService: ToasterService, constructor(private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
@ -57,6 +59,12 @@ export class SettingsComponent implements OnInit {
i18nService.supportedTranslationLocales.forEach((locale) => { i18nService.supportedTranslationLocales.forEach((locale) => {
this.localeOptions.push({ name: locale, value: locale }); this.localeOptions.push({ name: locale, value: locale });
}); });
this.themeOptions = [
{ name: i18nService.t('default'), value: null },
{ name: i18nService.t('light'), value: 'light' },
{ name: i18nService.t('dark'), value: 'dark' },
];
} }
async ngOnInit() { async ngOnInit() {
@ -66,6 +74,7 @@ export class SettingsComponent implements OnInit {
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey); this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey); this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey);
this.locale = await this.storageService.get<string>(ConstantsService.localeKey); this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
const disableGa = await this.storageService.get<boolean>(ConstantsService.disableGaKey); const disableGa = await this.storageService.get<boolean>(ConstantsService.disableGaKey);
const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore(); const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore();
@ -109,6 +118,11 @@ export class SettingsComponent implements OnInit {
this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale }); this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale });
} }
async saveTheme() {
await this.storageService.save(ConstantsService.themeKey, this.theme);
this.analytics.eventTrack.next({ action: 'Set Theme ' + this.theme });
}
private callAnalytics(name: string, enabled: boolean) { private callAnalytics(name: string, enabled: boolean) {
const status = enabled ? 'Enabled' : 'Disabled'; const status = enabled ? 'Enabled' : 'Disabled';
this.analytics.eventTrack.next({ action: `${status} ${name}` }); this.analytics.eventTrack.next({ action: `${status} ${name}` });

View File

@ -119,6 +119,10 @@ export function initFactory(): Function {
const htmlEl = window.document.documentElement; const htmlEl = window.document.documentElement;
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString()); htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());
htmlEl.classList.add('locale_' + i18nService.translationLocale); htmlEl.classList.add('locale_' + i18nService.translationLocale);
const theme = await storageService.get<string>(ConstantsService.themeKey);
if (theme != null) {
htmlEl.classList.add('theme_' + theme);
}
stateService.save(ConstantsService.disableFaviconKey, stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey)); await storageService.get<boolean>(ConstantsService.disableFaviconKey));

View File

@ -788,6 +788,20 @@
"languageDesc": { "languageDesc": {
"message": "Change the language used by the application. Restart is required." "message": "Change the language used by the application. Restart is required."
}, },
"theme": {
"message": "Theme"
},
"themeDesc": {
"message": "Change the application's color theme. Restart is required."
},
"dark": {
"message": "Dark",
"description": "Dark color"
},
"light": {
"message": "Light",
"description": "Light color"
},
"copy": { "copy": {
"message": "Copy", "message": "Copy",
"description": "Copy to clipboard" "description": "Copy to clipboard"