diff options
-rw-r--r-- | client/src/app/core/theme/theme.service.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index d8e02e2e5..17d33b4e5 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | ||
2 | 3 | ||
3 | @Injectable() | 4 | @Injectable() |
4 | export class ThemeService { | 5 | export class ThemeService { |
5 | private theme = document.querySelector('body') | 6 | private theme = document.querySelector('body') |
7 | private darkTheme = false | ||
6 | private previousTheme = {} | 8 | private previousTheme = {} |
7 | 9 | ||
8 | constructor () { | 10 | constructor () { |
@@ -12,15 +14,24 @@ export class ThemeService { | |||
12 | this.previousTheme['submenuColor'] = 'rgb(32,32,32)' | 14 | this.previousTheme['submenuColor'] = 'rgb(32,32,32)' |
13 | this.previousTheme['inputColor'] = 'gray' | 15 | this.previousTheme['inputColor'] = 'gray' |
14 | this.previousTheme['inputPlaceholderColor'] = '#fff' | 16 | this.previousTheme['inputPlaceholderColor'] = '#fff' |
17 | |||
18 | this.darkTheme = (peertubeLocalStorage.getItem('theme') === 'dark') | ||
19 | console.log(this.darkTheme) | ||
20 | if (this.darkTheme) this.toggleDarkTheme(false) | ||
15 | } | 21 | } |
16 | 22 | ||
17 | toggleDarkTheme () { | 23 | toggleDarkTheme (setLocalStorage = true) { |
18 | // switch properties | 24 | // switch properties |
19 | this.switchProperty('mainBackgroundColor') | 25 | this.switchProperty('mainBackgroundColor') |
20 | this.switchProperty('mainForegroundColor') | 26 | this.switchProperty('mainForegroundColor') |
21 | this.switchProperty('submenuColor') | 27 | this.switchProperty('submenuColor') |
22 | this.switchProperty('inputColor') | 28 | this.switchProperty('inputColor') |
23 | this.switchProperty('inputPlaceholderColor') | 29 | this.switchProperty('inputPlaceholderColor') |
30 | |||
31 | if (setLocalStorage) { | ||
32 | this.darkTheme = !this.darkTheme | ||
33 | peertubeLocalStorage.setItem('theme', (this.darkTheme) ? 'dark' : 'default') | ||
34 | } | ||
24 | } | 35 | } |
25 | 36 | ||
26 | private switchProperty (property, newValue?) { | 37 | private switchProperty (property, newValue?) { |