import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, MenuController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Subject } from 'rxjs/Subject';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
userType : any = 'teacher';
rootPage: any = 'WalkthroughPage';
activePage = new Subject();
pages: Array<{ title: string, component: any, active: boolean, icon: string }>;
rightMenuItems: Array<{ icon: string, active: boolean }>;
state: any;
placeholder = 'assets/img/avatar/girl-avatar.png';
chosenPicture: any;
constructor(
public platform: Platform,
public statusBar: StatusBar,
public splashscreen: SplashScreen,
public menuCtrl: MenuController
) {
this.initializeApp();
this.rightMenuItems = [
{ icon: 'home', active: true },
{ icon: 'alarm', active: false },
{ icon: 'analytics', active: false },
{ icon: 'archive', active: false },
{ icon: 'basket', active: false },
{ icon: 'body', active: false },
{ icon: 'bookmarks', active: false },
{ icon: 'camera', active: false },
{ icon: 'beer', active: false },
{ icon: 'power', active: false },
];
//here we will show sidemenu via userType wise....
this.pages = [
{ title: 'Class Time Table', component: 'HomePage', active: true, icon: 'home' },
{ title: 'My Time Table', component: 'AccordionListPage', active: false, icon: 'map' },
{ title: 'Birthday',
component: 'BirthdayPage', active: false, icon: 'ionic' },
{ title: 'Health Record', component: 'HealthRecordPage', active: false, icon: 'ionic' },
{ title: 'Curret Syllabus', component: 'SyllabusPage', active: false, icon: 'archive' },
{ title: 'About the School', component: 'ListPage', active: false, icon: 'body' },
{ title: 'Tearms & codition', component: 'ThemingPage', active: false, icon: 'power' },
{ title: 'Switch User', component: 'ThemingPage', active: false, icon: 'power' }
]
}
this.activePage.subscribe((selectedPage: any) => {
this.pages.map(page => {
page.active = page.title === selectedPage.title;
});
});
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashscreen.hide();
this.menuCtrl.enable(false, 'right');
});
}
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.push(page.component);
this.activePage.next(page);
}
rightMenuClick(item) {
this.rightMenuItems.map(menuItem => menuItem.active = false);
item.active = true;
}
}