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

import { Page1 } from '../pages/page1/page1';
import { Page2 } from '../pages/page2/page2';
import { LoginPage } from "../pages/login/login";
import { HomePage } from "../pages/home/home";
import { CustomersPage } from "../pages/customers/customers";
import { ProductsPage } from "../pages/products/products";
import { OrdersPage } from "../pages/orders/orders";
import { ToolsPage } from "../pages/tools/tools";
import { AboutPage } from "../pages/about/about";

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
    @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 }> }>;

    pages: Array<{title: string, component: any}>;

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

        this.entries = [
            {
                visible: true,
                title: "Ventas",
                pages: [
                    {
                        visible: true,
                        title: "Clientes",
                        icon: "people",
                        component: CustomersPage
                    },
                    {
                        visible: true,
                        title: "Presupuestos",
                        icon: "basket",
                        component: OrdersPage 
                    },
                    {
                        visible: true,
                        title: 'Productos',
                        icon: "cube",
                        component: ProductsPage
                    },
                ]
            },
            {
                visible: true,
                title: "Herramientas",
                pages: [
                    {
                        visible: true,
                        title: 'Herramientas',
                        icon: "build",
                        component: ToolsPage
                    },
                    {
                        visible: true,
                        title: "Acerca",
                        icon: "information-circle",
                        component: AboutPage
                    }
                ]
            }
        ];
    }

    initializeApp() {
        this.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.
            StatusBar.styleDefault();
            Splashscreen.hide();
        });
    }

    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);
    }
}
