package interfazGrafica;

import servicios.GestorParqueo;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JOptionPane;

public class PanelHome extends JPanel {

    public PanelHome(VentanaPrincipal ventana) {
        setLayout(new BorderLayout(10, 10));

        JLabel titulo = new JLabel("Bienvenido", JLabel.CENTER);
        titulo.setFont(new Font("Arial", Font.BOLD, 42));

        Font btnFont = new Font("Arial", Font.BOLD, 18);

        JButton btnRegistro = new JButton("Registrar ingreso");
        JButton btnSalida = new JButton("Registrar salida");
        JButton btnEspDisp = new JButton("Espacios disponibles");
        JButton btnReportes = new JButton("Reportes del dia");
        JButton btnSalir = new JButton("Salir");

        btnSalir.setBackground(Color.RED);
        btnSalir.setForeground(Color.WHITE);

        btnRegistro.setFont(btnFont);
        btnSalida.setFont(btnFont);
        btnEspDisp.setFont(btnFont);
        btnReportes.setFont(btnFont);
        btnSalir.setFont(btnFont);

        JPanel gridPanel = new JPanel(new GridLayout(2, 2, 5, 5));
        gridPanel.setPreferredSize(new Dimension(320, 320));
        gridPanel.add(btnRegistro);
        gridPanel.add(btnSalida);
        gridPanel.add(btnEspDisp);
        gridPanel.add(btnReportes);

        btnRegistro.addActionListener(e -> ventana.mostrarPanel(new PanelRegistro(ventana)));
        btnReportes.addActionListener(e -> ventana.mostrarPanel(new PanelReportes(ventana)));//lambda
btnSalida.addActionListener();
        btnEspDisp.addActionListener(e -> JOptionPane.showMessageDialog(null, "Espacios disponibles: " + ventana.getGestor().espaciosDisponibles()));
        btnSalir.addActionListener(e
                -> System.exit(0));

        JPanel southPanel = new JPanel();

        southPanel.add(btnSalir);

        add(titulo, BorderLayout.NORTH);

        add(gridPanel, BorderLayout.CENTER);

        add(southPanel, BorderLayout.SOUTH);
    }

}
