Files
doneit-web/src/app/shared/header/header.page.ts
T

109 lines
2.7 KiB
TypeScript
Raw Normal View History

2020-12-10 11:22:06 +01:00
import { Component, OnInit } from '@angular/core';
2021-03-02 18:53:37 +01:00
import { AnimationController, ModalController } from '@ionic/angular';
2021-01-07 10:54:11 +01:00
import { SearchPage } from 'src/app/pages/search/search.page';
2021-03-01 15:45:30 +01:00
import { Router } from '@angular/router';
2021-03-02 18:53:37 +01:00
import { ProfileComponent } from '../headers/header-no-search/profile/profile.component';
2020-12-10 11:22:06 +01:00
@Component({
selector: 'app-header',
templateUrl: './header.page.html',
styleUrls: ['./header.page.scss'],
})
export class HeaderPage implements OnInit {
2021-02-01 17:00:01 +01:00
profile: string = 'mdgpr';
2021-03-05 14:54:10 +01:00
searchSubject: string = '';
showSearch:false;
2021-02-01 17:00:01 +01:00
2021-03-02 18:53:37 +01:00
constructor(
private router: Router,private modalController: ModalController,
private animationController: AnimationController,) {
2021-02-01 17:00:01 +01:00
window['header'] = (profile:string) => {
this.profile = profile;
}
}
2020-12-10 11:22:06 +01:00
ngOnInit() {
}
2021-03-02 14:46:38 +01:00
locationPathname(): string {
return window.location.pathname
}
2021-01-07 10:54:11 +01:00
async openSearch() {
const modal = await this.modalController.create({
component: SearchPage,
2021-03-05 14:54:10 +01:00
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
2021-01-07 10:54:11 +01:00
componentProps: {
}
});
return await modal.present();
}
2021-03-01 15:45:30 +01:00
changeRoute(path){
this.router.navigateByUrl(path)
}
2021-03-02 18:53:37 +01:00
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();
}
2021-03-02 19:00:55 +01:00
2021-03-05 14:54:10 +01:00
async dynamicSearch(){
console.log('dynamic')
window['dynamicSearch'](this.searchSubject)
}
2021-03-02 19:00:55 +01:00
2021-03-05 14:54:10 +01:00
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']()
}
}