11/* eslint-disable max-len */
2- import { AfterViewInit , ChangeDetectorRef , Component , ComponentFactoryResolver , ElementRef , HostBinding , OnDestroy , OnInit , TemplateRef , ViewChild , ViewContainerRef , ViewEncapsulation } from '@angular/core' ;
2+ import { AfterViewInit , ChangeDetectorRef , Component , ComponentFactoryResolver , ElementRef , Renderer2 , OnDestroy , OnInit , DoCheck , TemplateRef , ViewChild , ViewContainerRef , ViewEncapsulation } from '@angular/core' ;
33import { AbsoluteScrollStrategy , ConnectedPositioningStrategy , DefaultSortingStrategy , IgxColumnComponent , IgxGridComponent , IgxOverlayOutletDirective , IgxSelectComponent , OverlaySettings , SortingDirection } from 'igniteui-angular' ;
44import { IgcDockManagerLayout , IgcDockManagerPaneType , IgcSplitPane , IgcSplitPaneOrientation } from 'igniteui-dockmanager' ;
55import { Subject } from 'rxjs' ;
@@ -14,7 +14,7 @@ import { DockSlotComponent, GridHostDirective } from './dock-slot.component';
1414 templateUrl : './grid-finjs-dock-manager.component.html' ,
1515 styleUrls : [ './grid-finjs-dock-manager.component.scss' ]
1616} )
17- export class GridFinJSDockManagerComponent implements OnInit , OnDestroy , AfterViewInit {
17+ export class GridFinJSDockManagerComponent implements OnInit , OnDestroy , AfterViewInit , DoCheck {
1818 @ViewChild ( 'grid1' , { static : true } ) public grid1 : IgxGridComponent ;
1919 @ViewChild ( 'grid2' , { static : true } ) public grid2 : IgxGridComponent ;
2020 @ViewChild ( GridHostDirective ) public host : GridHostDirective ;
@@ -25,8 +25,7 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
2525 @ViewChild ( 'freq' , { read : IgxSelectComponent } ) public selectFrequency : IgxSelectComponent ;
2626 @ViewChild ( IgxOverlayOutletDirective ) outlet : IgxOverlayOutletDirective ;
2727
28- @HostBinding ( 'class' )
29- public theme = 'dark-theme' ;
28+ public isDarkTheme = true ;
3029
3130 public frequencyItems : number [ ] = [ 300 , 600 , 900 ] ;
3231 public frequency = this . frequencyItems [ 1 ] ;
@@ -143,7 +142,7 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
143142
144143 private destroy$ = new Subject < any > ( ) ;
145144
146- constructor ( public dataService : SignalRService , private paneService : FloatingPanesService , private cdr : ChangeDetectorRef , private componentFactoryResolver : ComponentFactoryResolver ) { }
145+ constructor ( public dataService : SignalRService , private paneService : FloatingPanesService , private cdr : ChangeDetectorRef , private componentFactoryResolver : ComponentFactoryResolver , private elementRef : ElementRef , private renderer : Renderer2 ) { }
147146
148147 public ngOnInit ( ) {
149148 this . dataService . startConnection ( this . frequency , this . dataVolume , true , false ) ;
@@ -161,6 +160,17 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
161160 this . destroy$ . complete ( ) ;
162161 }
163162
163+ public ngDoCheck ( ) {
164+ if ( this . isDarkTheme ) {
165+ this . renderer . removeClass ( this . elementRef . nativeElement , 'light-theme' ) ;
166+ this . renderer . addClass ( this . elementRef . nativeElement , 'dark-theme' ) ;
167+ }
168+ else {
169+ this . renderer . removeClass ( this . elementRef . nativeElement , 'dark-theme' ) ;
170+ this . renderer . addClass ( this . elementRef . nativeElement , 'light-theme' ) ;
171+ }
172+ }
173+
164174 public ngAfterViewInit ( ) {
165175 // This 500ms timeout is used as a workaround for StackBlitz ExpressionChangedAfterItHasBeenChecked Error
166176 setTimeout ( ( ) => {
0 commit comments