Files
doneit-web/src/app/shared/headers/header-no-search/header-no-search.page.ts
T
2021-08-06 12:19:38 +01:00

88 lines
2.3 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { AnimationController, ModalController } from '@ionic/angular';
import { SearchPage } from 'src/app/pages/search/search.page';
import { MenuController } from '@ionic/angular';
import { ProfileComponent } from './profile/profile.page';
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import { User } from 'src/app/models/user.model';
import { ProfilePage } from 'src/app/modals/profile/profile.page';
@Component({
selector: 'app-header-no-search',
templateUrl: './header-no-search.page.html',
styleUrls: ['./header-no-search.page.scss'],
})
export class HeaderNoSearchPage implements OnInit {
loggeduser: User;
constructor(private modalController: ModalController,
private menu: MenuController,
private animationController: AnimationController,
private router: Router,
authService: AuthService) {
this.loggeduser = authService.ValidatedUser;
}
ngOnInit() {
}
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: ProfilePage,
cssClass: 'model profile-modal',
componentProps: {
}
});
return await modal.present();
}
changeRoute(path){
this.router.navigateByUrl(path)
}
locationPathname(): string {
return window.location.pathname
}
profileLabel(text) {
if (text == 'MDGPR') {
return 'MD'
} else if (text=='PR') {
return text
} else {
return 'UN'
}
}
}