import { Component, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { RouterExtensions } from '@nativescript/angular';
import { transitionOptions } from '~/constants/shared.constants';

@Component({
    selector: 'SearchPage',
    moduleId: module.id,
    templateUrl: './search-page.component.html',
    styleUrls: ['./_search-page.component.scss']
})
export class SearchPageComponent implements OnInit {
    pageLoading: boolean;
    constructor(
        private routerExtensions: RouterExtensions,
        private router: Router,
    ) {
        this.router.events.subscribe((val) => {
            if (val instanceof NavigationEnd) {
                if (this.router.url === '/home/search') {
                    this.pageLoading = false;
                }
            }
        });
    }
    ngOnInit(): void {
        this.pageLoading = false;
    }
    onNavTap(navRoute: string): void {
        this.pageLoading = true;
        setTimeout(() => {
            this.routerExtensions.navigate([navRoute], { transition: transitionOptions });
        }, 10);
    }

}
