import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AssetPreloaderService } from '../../assetPreloaderService';

@Component({
	selector: 'app-splash',
	templateUrl: './splash.component.html',
	styleUrls: ['./splash.component.css'],
})
export class SplashComponent {
	static assetPreloader: AssetPreloaderService = new AssetPreloaderService();
	show: boolean = true;
	progress: number = 0;

	constructor(private router: Router) {
		SplashComponent.assetPreloader.progress$.subscribe(
			(p) => (this.progress = p)
		);
		SplashComponent.assetPreloader
			.preload()
			.then(() => this.router.navigate(['/menu']));
	}
}
