12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { Component, ViewChild } from '@angular/core';
- import { Nav, Platform } from 'ionic-angular';
- import { StatusBar } from '@ionic-native/status-bar';
- import { SplashScreen } from '@ionic-native/splash-screen';
- import { AuthProvider } from '../providers/auth/auth';
- import { HomePage } from '../pages/home/home';
- import { SearchPage } from '../pages/search/search';
- import { SettingsPage } from '../pages/settings/settings';
- import { LoginPage } from '../pages/login/login';
- @Component({
- templateUrl: 'app.html'
- })
- export class MyApp {
- @ViewChild(Nav) nav: Nav;
- rootPage: any;
- pages: Array<{ title: string, icon: string, component: any }>;
- constructor(
- platform: Platform,
- statusBar: StatusBar,
- splashScreen: SplashScreen,
- private authProvider: AuthProvider
- ) {
- platform.ready().then(() => {
- // Okay, so the platform is ready and our plugins are available.
- // Here you can do any higher level native things you might need.
- //this.setHomepage();
- statusBar.styleDefault();
- splashScreen.hide();
- authProvider.isLoggedIn().then(isLoggedIn => {
- this.rootPage = isLoggedIn ? HomePage : LoginPage;
- })
- });
- this.pages = [
- { title: 'Home', icon: 'home', component: HomePage },
- { title: 'Search', icon: 'search', component: SearchPage },
- { title: 'Settings', icon: 'settings', component: SettingsPage }
- ];
- }
- 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.setRoot(page.component);
- }
- logout() {
- this.authProvider.logout();
- }
- }
|