// import { Component, ViewChild } from '@angular/core';
// import { IonicPage, NavController, NavParams, Nav } from 'ionic-angular';
// import { HomePage } from '../home/home';

// /**
//  * Generated class for the MenuPage page.
//  *
//  * See https://ionicframework.com/docs/components/#navigation for more info on
//  * Ionic pages and navigation.
//  */

// export interface PageInterface {
//   title: string;
//   pageName: string;
//   tabComponent?: any;
//   index?: number;
//   icon: string;
// }

// @IonicPage()
// @Component({
//   selector: 'page-menu',
//   templateUrl: 'menu.html',
// })
// export class MenuPage {
//   //basic root for our 
//   rootPage = 'HomePage';

//   @ViewChild(Nav) nav: Nav;

//   pages: PageInterface[] = [
//     { title: 'My Vault', pageName: 'HomePage', index: 0, icon: 'home'  }
//   ];

//   constructor(public navCtrl: NavController, public navParams: NavParams) {
//   }

//   openPage(page: PageInterface) {
//     let params = {};

//     if (this.nav.getActiveChildNav() && page.index != undefined) {
//       this.nav.getActiveChildNav().select(page.index);
//     }
//     else {
//       this.nav.setRoot(page.pageName, params);
//     }
//   }

//   isActive(page: PageInterface) {
//     if (this.nav.getActive() && this.nav.getActive().name === page.pageName) {
//       return 'primary';
//     }
//     return;
//   }

//   ionViewDidLoad() {
//     console.log('ionViewDidLoad MenuPage');
//   }

// }

import { Component, ViewChild } from '@angular/core';
import { IonicPage, Nav, NavController } from 'ionic-angular';

interface PageItem {
  title: string
  component: any
}
type PageList = PageItem[]

@IonicPage()
@Component({
  selector: 'page-menu',
  templateUrl: 'menu.html'
})
export class MenuPage {
  // A reference to the ion-nav in our component
  @ViewChild(Nav) nav: Nav;

  rootPage: any = 'ContentPage';

  pages: PageList;

  constructor(public navCtrl: NavController) {
    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Sign in', component: 'LoginPage' },
      { title: 'Signup', component: 'SignupPage' }
    ];
  }

  ionViewDidLoad() {
    console.log('Hello MenuPage Page');
  }

  openPage(page: PageItem) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
}