import { Component, OnInit } from '@angular/core'; import { AnimationController, ModalController } from '@ionic/angular'; import { SearchPage } from 'src/app/pages/search/search.page'; import { Router } from '@angular/router'; import { ProfileComponent } from '../headers/header-no-search/profile/profile.component'; @Component({ selector: 'app-header', templateUrl: './header.page.html', styleUrls: ['./header.page.scss'], }) export class HeaderPage implements OnInit { profile: string = 'mdgpr'; searchSubject: string = ''; showSearch:false; constructor( private router: Router,private modalController: ModalController, private animationController: AnimationController,) { window['header'] = (profile:string) => { this.profile = profile; } } ngOnInit() { } locationPathname(): string { return window.location.pathname } async openSearch() { const modal = await this.modalController.create({ component: SearchPage, cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop', componentProps: { } }); return await modal.present(); } changeRoute(path){ this.router.navigateByUrl(path) } async openProfile() { const enterAnimation = (baseEl: any) => { const backdropAnimation = this.animationController.create() .addElement(baseEl.querySelector('ion-backdrop')!) .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); const wrapperAnimation = this.animationController.create() .addElement(baseEl.querySelector('.modal-wrapper')!) .keyframes([ { offset: 0, opacity: '1', right: '-100%' }, { offset: 1, opacity: '1', right: '0px' } ]); return this.animationController.create() .addElement(baseEl) .easing('ease-out') .duration(500) .addAnimation([backdropAnimation, wrapperAnimation]); } const leaveAnimation = (baseEl: any) => { return enterAnimation(baseEl).direction('reverse'); } const modal = await this.modalController.create({ enterAnimation, leaveAnimation, component: ProfileComponent, cssClass: 'model profile-modal', componentProps: { } }); return await modal.present(); } async dynamicSearch(){ console.log('dynamic') window['dynamicSearch'](this.searchSubject) } async closeSearch(){ document.querySelectorAll('.search-modal').forEach((e)=>e.remove()) } /** * @description set empty value to searchSubject */ clearSearchInput(){ this.searchSubject = ""; window['dynamicSearch'](this.searchSubject) } async basicSearch(){ window['searchTriger']() } }