fixe theme changing

This commit is contained in:
Peter Maquiran
2022-10-11 17:07:51 +01:00
parent a2bdbb00fd
commit 5c22b278a3
7 changed files with 43 additions and 79 deletions
+27 -7
View File
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { StorageService } from 'src/app/services/storage.service';
import { localstoreService } from '../store/localstore.service';
import { AES, enc, SHA1 } from 'crypto-js'
@Injectable({
providedIn: 'root'
})
@@ -12,20 +13,39 @@ export class ThemeService {
'tribunal'
]
currentTheme = 'gov'
currentTheme: 'gov' | 'default' | 'tribunal' = 'gov'
keyName: string
constructor(private storageservice: StorageService) { }
constructor(
private storageservice: StorageService
) {
this.keyName = (SHA1(this.constructor.name)).toString()
let restore = localstoreService.get(this.keyName, {
theme: "gov"
})
this.setTheme(restore.theme)
}
setTheme(theme: 'gov' | 'default' | 'tribunal') {
document.body.classList.remove("gov");
document.body.classList.remove("default");
document.body.classList.remove("tribunal");
document.body.classList.add(theme);
this.currentTheme = theme
this.storageservice.store('theme',theme);
document.body.classList.add(theme);
this.currentTheme = theme;
localstoreService.set(this.keyName, {
theme: theme
})
}
}
saveTheme() {
}
}