mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
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'
|
|
})
|
|
export class ThemeService {
|
|
|
|
themes = [
|
|
'gov',
|
|
'default',
|
|
'tribunal'
|
|
]
|
|
|
|
currentTheme: 'gov' | 'default' | 'tribunal' = 'gov'
|
|
keyName: string
|
|
|
|
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') {
|
|
|
|
if(this.themes.includes(theme)) {
|
|
document.body.classList.remove("gov");
|
|
document.body.classList.remove("default");
|
|
document.body.classList.remove("tribunal");
|
|
|
|
document.body.classList.add(theme);
|
|
this.currentTheme = theme;
|
|
|
|
localstoreService.set(this.keyName, {
|
|
theme: theme
|
|
})
|
|
}
|
|
|
|
|
|
}
|
|
|
|
saveTheme() {
|
|
|
|
}
|
|
|
|
} |