package VistaControlador;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ControladorPanelInterfaz implements ActionListener{
	VistaPanelInterfaz vista;
	Menu menu;
	public ControladorPanelInterfaz(VistaPanelInterfaz vista, Menu menu) {
		this.menu = menu;
		this.vista = vista;
		this.aniadirListener();
	}
	
	private void aniadirListener() {
		this.vista.aplicarCambios.addActionListener(this);
		this.vista.aplicarCambios.setActionCommand("Aplicar cambios");
	}
	

	public void actionPerformed(ActionEvent arg0) {
		switch(arg0.getActionCommand()) {
		case "Aplicar cambios":{
			if(this.vista.aplicarBarra.isSelected()) {
				if(this.vista.temaClaro.isSelected()) {
					this.menu.barra.setBackground(Color.WHITE);
				} else if(this.vista.temaOscuro.isSelected()) {
					this.menu.barra.setBackground(Color.GRAY);
				} else if(this.vista.temaRosa.isSelected()) {
					this.menu.barra.setBackground(Color.PINK);
				}
			}
			if(this.vista.temaClaro.isSelected()) {
				this.menu.setTheme(0);
			} else if(this.vista.temaOscuro.isSelected()) {
				this.menu.setTheme(2);
			} else if(this.vista.temaRosa.isSelected()) {
				this.menu.setTheme(1);
			}
		}
		}
		
	}
}
