package com.vii.ciclo.untrm.navigationdrawerejemplo.actividades.primarias.actividades_items;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.vii.ciclo.untrm.navigationdrawerejemplo.R;

public class Ventas extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ventas_navigation_drawer);
        this.setTitle(R.string.nav_ventas);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_ventas);
        setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.ventas_drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.ventas_nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        navigationView.setCheckedItem(R.id.nav_ventas);

    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();
        Intent i = null;

        switch (item.getItemId()){
            case R.id.nav_inicio:
                i = new Intent(this, Inicio.class);
                break;
            /*case R.id.nav_ventas:
                i = new Intent(this, Ventas.class);
                break;*/
            case R.id.nav_compras:
                i = new Intent(this, Compras.class);
                break;
            case R.id.nav_inventario:
                i = new Intent(this, Inventario.class);
                break;
            case R.id.nav_usuarios:
                i = new Intent(this, Usuarios.class);
                break;
            case R.id.nav_reportes:
                i = new Intent(this, Reportes.class);
                break;
            case R.id.nav_ajustes:
                i = new Intent(this, Ajustes.class);
                break;
            default:
        }
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.ventas_drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        //si no se ha seleccionado ningun item, esta activity no debe finalizar
        if(i != null){
            startActivity(i);
            finish();
        }
        return true;
    }
}