import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams,MenuController } from 'ionic-angular';
import { TranslateService } from "@ngx-translate/core";
import { Storage } from '@ionic/storage'

@IonicPage()
@Component({
  selector: 'page-landing',
  templateUrl: 'landing.html',
})
export class LandingPage {
  lang: string = 'en';

  constructor(public navCtrl: NavController, public navParams: NavParams, public storage: Storage, private translate: TranslateService, private menu:MenuController) {
  }

  open_page(page){
    this.navCtrl.push(page);
  }

  ionViewDidEnter() {
    this.menu.swipeEnable(false)
    this.langTrans()
  }

  langTrans() {
    this.storage.get('lang').then(lang => {
      if (lang != null) {
        this.translate.use(lang)
        this.lang = lang;
      }
      else {
        this.translate.use('en')
      }
    })
  }

  ionViewWillLeave(){
    this.menu.swipeEnable(true)
  }

}
