You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
|
import { Platform } from '@ionic/angular';
|
|
import { TranslatorService } from '../../services/translator/translator.service';
|
|
import { BackButtonEventDetail } from '@ionic/core';
|
|
|
|
|
|
@Component({
|
|
selector: 'nav-buttons',
|
|
templateUrl: './nav-buttons.component.html',
|
|
styleUrls: ['./nav-buttons.component.scss']
|
|
})
|
|
export class NavButtonsComponent implements OnInit {
|
|
|
|
@Input() enableBack = true;
|
|
@Input() enableMenu = false;
|
|
@Input() navigate = true;
|
|
@Output() backClick = new EventEmitter();
|
|
@Output() menuClick = new EventEmitter();
|
|
@Input() forwardLink: string;
|
|
@Input() backLink: string;
|
|
|
|
public direction: string;
|
|
public isIOS: boolean;
|
|
constructor(
|
|
public cs: CommonService,
|
|
public platform: Platform,
|
|
) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.platform.ready().then(() => {
|
|
this.isIOS = this.platform.is('ios');
|
|
this.direction = TranslatorService.getCurrentDirection();
|
|
|
|
this.platform.backButton.subscribeWithPriority(0 , () => {
|
|
this.backButtonClicked({});
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
public backButtonClicked(event) {
|
|
// tslint:disable-next-line:no-console
|
|
if (this.forwardLink) {
|
|
if (this.navigate) {
|
|
this.cs.navigateForward(this.forwardLink);
|
|
}
|
|
} else if (this.backLink) {
|
|
this.backClick.emit([event]);
|
|
if (this.navigate) {
|
|
this.cs.navigateBack(this.backLink);
|
|
}
|
|
} else {
|
|
this.backClick.emit([event]);
|
|
if (this.navigate) {
|
|
this.cs.back();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public onMenuClicked() {
|
|
this.menuClick.emit();
|
|
}
|
|
|
|
}
|