AltitudeWeb/frontend/src/app/theme/theme.component.ts
Teriuihi a993c1cc3e Standardize coding style and formatting across the project
Updated codebase to follow consistent styling for spacing, braces, and indentation. Changes improve readability and align with standardized conventions throughout SCSS, TypeScript, and HTML files.
2025-04-05 18:19:10 +02:00

37 lines
907 B
TypeScript

import {Component, OnDestroy, OnInit} from '@angular/core';
import {Subscription} from 'rxjs';
import {ThemeService} from './theme.service';
import {THEME_MODE} from '../constant';
@Component({
standalone: false,
selector: 'app-theme',
templateUrl: './theme.component.html',
styleUrl: './theme.component.scss'
})
export class ThemeComponent implements OnInit, OnDestroy {
isDarkMode: boolean = false;
private themeSubscription: Subscription | null = null;
constructor(private themeService: ThemeService) {
}
ngOnInit(): void {
this.themeSubscription = this.themeService.theme$.subscribe(theme => {
this.isDarkMode = theme === THEME_MODE.DARK;
});
}
toggleTheme(): void {
this.isDarkMode = this.themeService.toggleTheme() === THEME_MODE.DARK;
}
ngOnDestroy(): void {
if (this.themeSubscription) {
this.themeSubscription.unsubscribe();
}
}
}