|
@ -13,6 +13,7 @@ import { |
|
|
} from '@ghostfolio/common/config'; |
|
|
} from '@ghostfolio/common/config'; |
|
|
import { InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
|
import { InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
|
|
import { Appearance } from '@ghostfolio/common/types'; |
|
|
import { MaterialCssVarsService } from 'angular-material-css-vars'; |
|
|
import { MaterialCssVarsService } from 'angular-material-css-vars'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { Subject } from 'rxjs'; |
|
@ -77,6 +78,8 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
permissions.createUserAccount |
|
|
permissions.createUserAccount |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.initializeTheme(this.user?.settings.appearance); |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -97,10 +100,12 @@ export class AppComponent implements OnDestroy, OnInit { |
|
|
this.unsubscribeSubject.complete(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private initializeTheme() { |
|
|
private initializeTheme(userPreferredAppearance?: Appearance) { |
|
|
this.materialCssVarsService.setDarkTheme( |
|
|
const isDarkTheme = userPreferredAppearance |
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches |
|
|
? userPreferredAppearance === 'DARK' |
|
|
); |
|
|
: window.matchMedia('(prefers-color-scheme: dark)').matches; |
|
|
|
|
|
|
|
|
|
|
|
this.materialCssVarsService.setDarkTheme(isDarkTheme); |
|
|
|
|
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').addListener((event) => { |
|
|
window.matchMedia('(prefers-color-scheme: dark)').addListener((event) => { |
|
|
this.materialCssVarsService.setDarkTheme(event.matches); |
|
|
this.materialCssVarsService.setDarkTheme(event.matches); |
|
|