import { Component,OnInit, Injectable } from ‘@angular/core’;
import { MenuController,NavController } from ‘@ionic/angular’;
import { Platform } from ‘@ionic/angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen/ngx’;
import { StatusBar } from ‘@ionic-native/status-bar/ngx’;
import { AngularFireAuth } from ‘@angular/fire/auth’;
import { ScreenOrientation } from ‘@ionic-native/screen-orientation/ngx’;
@Injectable()
@Component({
selector: ‘app-root’,
templateUrl: ‘app.component.html’,
styleUrls: [‘app.component.scss’]
})
export class AppComponent implements OnInit {
userEmail: string;
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
public menu: MenuController,
private afAuth: AngularFireAuth,
private navCtrl:NavController,
private screenOrientation:ScreenOrientation,
) {
this.initializeApp();
}
ngOnInit() {
this.afAuth.user.subscribe(res => {
console.log('res', res);
if (res !== null) {
this.userEmail = res.email;
}
}, err => {
console.log('err', err);
})
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);
}
logout() {
this.afAuth.signOut()
.then(res => {
console.log(res);
this.navCtrl.navigateBack('/thanks');
})
.catch(error => {
console.log(error);
})
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
enableAuthenticatedMenu() {
this.menu.enable(true, 'authenticated');
this.menu.enable(false, 'unauthenticated');
}
}