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

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

import { CustomerListPage } from '../pages/customer-list/customer-list';
import { BudgetListPage } from '../pages/budget-list/budget-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 { ToolsPage } from '../pages/tools/tools';
import { SettingsPage } from '../pages/settings/settings';
import { AboutPage } from '../pages/about/about';

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

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

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

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

    initializeApp() {
        this.platform.ready().then(() => {
            // StatusBar.styleDefault();
            StatusBar.backgroundColorByHexString("#364499");
        });
    }

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