import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';

import { LoginPage } from '../pages/login/login';

import { CustomerListPage } from '../pages/customer-list/customer-list';
import { ProductListPage } from '../pages/product-list/product-list';
import { LeadListPage } from '../pages/lead-list/lead-list';
import { OpportunityListPage } from '../pages/opportunity-list/opportunity-list';
import { CallListPage } from '../pages/call-list/call-list';

import { ProjectListPage } from '../pages/project-list/project-list';
import { TaskListPage } from '../pages/task-list/task-list';

import { SettingsPage } from '../pages/settings/settings';
import { AboutPage } from '../pages/about/about'

@Component({
    templateUrl: 'app.html'
})
export class MyApp {
    @ViewChild(Nav) nav: Nav;

    rootPage: any = LoginPage;
    entries: Array<{ title: string, pages: Array<{ icon: string, title: string, component: any }> }>;

    constructor(public platform: Platform) {
        this.initializeApp();

        this.entries = [
            { title: 'Ventas', pages: [
                { icon: "people", title: 'Clientes', component: CustomerListPage },
                { icon: "cube", title: 'Productos', component: ProductListPage },
                { icon: "bulb", title: 'Iniciativas', component: LeadListPage },
                { icon: "ribbon", title: 'Oportunidades', component: OpportunityListPage },
                { icon: "call", title: 'Llamadas', component: CallListPage }
            ]},
            { title: 'Proyectos', pages: [
                { icon: "briefcase", title: 'Proyectos', component: ProjectListPage },
                { icon: "calendar", title: 'Tareas', component: TaskListPage }
            ]},
            { title: 'Herramientas', pages: [
                { icon: "settings", title: 'Preferencias', component: SettingsPage },
                { icon: "information-circle", title: 'Acerca', component: AboutPage }
            ]}
        ];
    }

    initializeApp() {
        this.platform.ready().then(() => {
            StatusBar.styleDefault();
        });
    }

    // Open the page
    openPage(page): void {
        this.nav.setRoot(page.component);
    }
}
