From 3e53b99bded8c871d6062b7541ea92b537235aeb Mon Sep 17 00:00:00 2001 From: Gannicus Date: Wed, 20 Dec 2023 19:58:24 -0500 Subject: [PATCH] Update our main app component --- src/app/app.component.html | 15 ++++++++++- src/app/app.component.ts | 55 ++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 0680b43..ea98b0d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1,14 @@ - + + +
+ + + + + + + +
+ + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a953acb..9ba6245 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,17 +1,35 @@ -import { Component } from '@angular/core'; -import { ElectronService } from './core/services'; +import { AfterViewChecked, Component, OnInit } from '@angular/core'; +import { + NavigationCancel, + NavigationEnd, + NavigationError, + NavigationStart, + Router, +} from '@angular/router'; + import { TranslateService } from '@ngx-translate/core'; +import { LoadingBarService } from '@ngx-loading-bar/core'; +import { register } from 'swiper/element/bundle'; + import { APP_CONFIG } from '../environments/environment'; +import { AppSettings, ElectronService, JarallaxService } from './core'; + @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + styleUrls: ['./app.component.scss'], }) -export class AppComponent { +export class AppComponent implements OnInit, AfterViewChecked { + AppSettings = AppSettings; + constructor( + private router: Router, + + private lb: LoadingBarService, + private translate: TranslateService, private electronService: ElectronService, - private translate: TranslateService + private jarallaxService: JarallaxService ) { this.translate.setDefaultLang('en'); console.log('APP_CONFIG', APP_CONFIG); @@ -25,4 +43,31 @@ export class AppComponent { console.log('Run in browser'); } } + + ngOnInit(): void { + // Get the state of our loading bar + const state = this.lb.useRef('router'); + + // Wait for routing updates + this.router.events.subscribe({ + next: (r) => { + if (r instanceof NavigationStart) { + state.start(); + } else if ( + r instanceof NavigationCancel || + r instanceof NavigationError || + r instanceof NavigationEnd + ) { + setTimeout(() => { + state.complete(); + }, 250); + } + }, + }); + } + + ngAfterViewChecked(): void { + this.jarallaxService.jarallaxAll(); + register(); + } }