Files
doneit-web/src/app/shared/header/header.page.ts
T
2021-03-02 18:53:37 +01:00

81 lines
2.1 KiB
TypeScript

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';
constructor(
private router: Router,private modalController: ModalController,
private animationController: AnimationController,) {
window['header'] = (profile:string) => {
this.profile = profile;
}
}
ngOnInit() {
}
async openSearch() {
const modal = await this.modalController.create({
component: SearchPage,
cssClass: 'group-messages modal-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();
}
}