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.
37 lines
907 B
TypeScript
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();
|
|
}
|
|
}
|
|
|
|
|
|
}
|