diff --git a/src/app/core/shell/toolbar/theme-picker/theme-picker.component.ts b/src/app/core/shell/toolbar/theme-picker/theme-picker.component.ts index b3ff56013..5a27abf43 100644 --- a/src/app/core/shell/toolbar/theme-picker/theme-picker.component.ts +++ b/src/app/core/shell/toolbar/theme-picker/theme-picker.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { Theme } from './theme.model'; -import { ThemeManagerService } from './theme-manager.service'; import { ThemeStorageService } from './theme-storage.service'; @Component({ @@ -13,21 +12,33 @@ import { ThemeStorageService } from './theme-storage.service'; export class ThemePickerComponent implements OnInit { currentTheme: Theme = { - href: 'indigo-pink.css', - primary: '#3F51B5', - accent: '#E91E63', + href: 'denim-yellowgreen.css', + primary: '#1074B9', + accent: '#B4D575', isDark: false, isDefault: true }; themes = [ this.currentTheme, + { + href: 'pictonblue-yellowgreen.css', + primary: '#1DAEEC', + accent: '#B4D575', + isDark: false + }, + { + href: 'indigo-pink.css', + primary: '#3F51B5', + accent: '#E91E63', + isDark: false, + }, { href: 'deeppurple-amber.css', primary: '#673AB7', accent: '#FFC107', isDark: false }, - { + { // TODO: Remove Dark Themes href: 'pink-bluegrey.css', primary: '#E91E63', accent: '#607D8B', @@ -38,41 +49,21 @@ export class ThemePickerComponent implements OnInit { primary: '#9C27B0', accent: '#4CAF50', isDark: true - }, - { - href: 'denim-yellowgreen.css', - primary: '#1074B9', - accent: '#B4D575', - isDark: false - }, - { - href: 'pictonblue-yellowgreen.css', - primary: '#1DAEEC', - accent: '#B4D575', - isDark: false } ]; - constructor(public themeManagerService: ThemeManagerService, - private themeStorageService: ThemeStorageService) { + constructor(public themeStorageService: ThemeStorageService) { } + + ngOnInit() { const theme = this.themeStorageService.getTheme(); - if (theme) { - this.installTheme(theme); - } - } - - ngOnInit() { } - - installTheme(theme: Theme) { if (theme) { this.currentTheme = theme; } - if (this.currentTheme.isDefault) { - this.themeManagerService.removeTheme(); - } else { - this.themeManagerService.setTheme(`theme/${this.currentTheme.href}`); - } - this.themeStorageService.storeTheme(this.currentTheme); + } + + installTheme(theme: Theme) { + this.currentTheme = theme; + this.themeStorageService.installTheme(theme); } } diff --git a/src/app/core/shell/toolbar/theme-picker/theme-storage.service.ts b/src/app/core/shell/toolbar/theme-picker/theme-storage.service.ts index 08fe1c605..00df4eee9 100644 --- a/src/app/core/shell/toolbar/theme-picker/theme-storage.service.ts +++ b/src/app/core/shell/toolbar/theme-picker/theme-storage.service.ts @@ -1,6 +1,7 @@ import {Injectable, EventEmitter} from '@angular/core'; import { Theme } from './theme.model'; +import { ThemeManagerService } from './theme-manager.service'; @Injectable({ providedIn: 'root' @@ -10,7 +11,7 @@ export class ThemeStorageService { private themeStorageKey = 'mifosXTheme'; onThemeUpdate: EventEmitter; - constructor() { + constructor(public themeManagerService: ThemeManagerService) { this.onThemeUpdate = new EventEmitter(); } @@ -27,4 +28,13 @@ export class ThemeStorageService { localStorage.removeItem(this.themeStorageKey); } + installTheme(theme: Theme) { + if (theme.isDefault) { + this.themeManagerService.removeTheme(); + } else { + this.themeManagerService.setTheme(`theme/${theme.href}`); + } + this.storeTheme(theme); + } + } diff --git a/src/app/web-app.component.ts b/src/app/web-app.component.ts index e7b44157b..098f5bdba 100644 --- a/src/app/web-app.component.ts +++ b/src/app/web-app.component.ts @@ -9,6 +9,7 @@ import { filter, map, mergeMap } from 'rxjs/operators'; import { environment } from '../environments/environment'; import { Logger, I18nService } from './core'; +import { ThemeStorageService } from './core/shell/toolbar/theme-picker/theme-storage.service'; import { AlertService } from './core/alert.service'; const log = new Logger('MifosX'); @@ -25,6 +26,7 @@ export class WebAppComponent implements OnInit { private titleService: Title, private translateService: TranslateService, private i18nService: I18nService, + private themeStorageService: ThemeStorageService, public snackBar: MatSnackBar, private alertService: AlertService) { } @@ -61,6 +63,11 @@ export class WebAppComponent implements OnInit { } }); + const theme = this.themeStorageService.getTheme(); + if (theme) { + this.themeStorageService.installTheme(theme); + } + this.alertService.alertEvent.subscribe((alertEvent: any) => { this.snackBar.open(`${alertEvent.message}`, 'Close', { duration: 2000, diff --git a/src/main.scss b/src/main.scss index d582f114e..611942c96 100644 --- a/src/main.scss +++ b/src/main.scss @@ -4,7 +4,7 @@ */ // Import Default Theme for MifosX -@import "~@angular/material/prebuilt-themes/indigo-pink.css"; +@import "theme/custom/denim-yellowgreen"; // 3rd party libraries