1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00: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

View File

@@ -62,6 +62,13 @@
</div>
<small class="help-block">{{'gaDesc' | i18n}}</small>
</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">
<label for="locale">{{'language' | i18n}}</label>
<select id="locale" name="Locale" [(ngModel)]="locale" (change)="saveLocale()">

View File

@@ -33,6 +33,8 @@ export class SettingsComponent implements OnInit {
locale: string;
lockOptions: any[];
localeOptions: any[];
theme: string;
themeOptions: any[];
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
@@ -57,6 +59,12 @@ export class SettingsComponent implements OnInit {
i18nService.supportedTranslationLocales.forEach((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() {
@@ -66,6 +74,7 @@ export class SettingsComponent implements OnInit {
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey);
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 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 });
}
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) {
const status = enabled ? 'Enabled' : 'Disabled';
this.analytics.eventTrack.next({ action: `${status} ${name}` });