Back to home page

EIC code displayed by LXR

 
 

    


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

0001 import { Component, computed } from '@angular/core';
0002 import { ThemeService, Theme } from '../../services/theme.service';
0003 import { MatMenuModule } from '@angular/material/menu';
0004 import { MatIconModule } from '@angular/material/icon';
0005 import { MatButtonModule } from '@angular/material/button';
0006 
0007 @Component({
0008   selector: 'app-theme-switcher',
0009   templateUrl: './theme-switcher.component.html',
0010   styleUrls: ['./theme-switcher.component.scss'],
0011   standalone: true,
0012   imports: [MatMenuModule, MatIconModule, MatButtonModule]
0013 })
0014 export class ThemeSwitcherComponent {
0015   /**
0016    * A computed signal that returns the appropriate Material icon name
0017    * based on the current theme stored in ThemeService.
0018    */
0019   public currentIcon = computed(() => {
0020     const theme = this.themeService.currentTheme();
0021     // Return the corresponding icon name based on the theme value.
0022 
0023     if(theme === 'system') {
0024       return 'settings_brightness';
0025     }
0026     return theme === "dark" ? 'dark_mode' : 'light_mode';
0027   });
0028 
0029   public systemIcon = computed(()=>
0030     this.themeService.getSystemTheme()=== "dark" ? 'dark_mode' : 'light_mode');
0031 
0032   /**
0033    * Creates an instance of ThemeSwitcherComponent.
0034    * @param themeService The ThemeService managing theme state via signals.
0035    */
0036   constructor(public themeService: ThemeService) {}
0037 
0038   /**
0039    * Handles user selection of a new theme from the menu.
0040    * This updates the global theme using ThemeService.
0041    * @param theme The new theme selected by the user.
0042    */
0043   selectTheme(theme: Theme): void {
0044     this.themeService.setTheme(theme);
0045   }
0046 }