Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/firebird-ng/src/app/components/dark-theme/dark-theme.component.ts is written in an unsupported language. File is not indexed.

0001 import { Component, type OnInit } from '@angular/core';
0002 import {EventDisplayService} from "phoenix-ui-components";
0003 import {MenuToggleComponent} from "../menu-toggle/menu-toggle.component";
0004 import * as THREE from 'three';
0005 
0006 @Component({
0007   selector: 'app-custom-dark-theme',
0008   templateUrl: './dark-theme.component.html',
0009   styleUrls: ['./dark-theme.component.scss'],
0010   imports: [
0011     MenuToggleComponent
0012   ],
0013   standalone: true
0014 })
0015 export class DarkThemeComponent implements OnInit {
0016   darkTheme = false;
0017   threeDarkBackground = new THREE.Color( 0x3F3F3F );
0018   threeLightBackground = new THREE.Color( 0xF3F3F3 );
0019 
0020   constructor(private eventDisplay: EventDisplayService) { }
0021 
0022   ngOnInit(): void {
0023     this.darkTheme = this.eventDisplay.getUIManager().getDarkTheme();
0024   }
0025 
0026   setDarkTheme() {
0027     this.darkTheme = !this.darkTheme;
0028     const scene = this.eventDisplay.getThreeManager().getSceneManager().getScene();
0029 
0030     this.eventDisplay.getUIManager().setDarkTheme(this.darkTheme);
0031 
0032     // Switch three.js background
0033     if(scene && this.darkTheme) {
0034       scene.background = this.threeDarkBackground;
0035     } else {
0036       scene.background = this.threeLightBackground;
0037     }
0038 
0039     const theme = this.darkTheme ? 'dark' : 'light';
0040     document.documentElement.setAttribute('data-theme', theme);
0041   }
0042 }