package xyz.thastertyn.UserInterface.Content;

import java.io.IOException;
import java.util.ArrayList;

import com.googlecode.lanterna.TextColor.ANSI;
import com.googlecode.lanterna.gui2.Direction;
import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton;

import xyz.thastertyn.UserInterface.Listeners.UpdateListener;

public class Reports extends JecnaContent {
	
	private xyz.thastertyn.Scrape.Reports reports = new xyz.thastertyn.Scrape.Reports();
	
	public Reports(UpdateListener listener)
	{
		super(listener);
		this.mainPanel = new Panel(new GridLayout(1)
			.setLeftMarginSize(1)
			.setRightMarginSize(1));
		this.borderLabel = new Label("Sdeleni R.");
		super.scraper = this.reports;
	}

	@Override
	protected void setGUI()
	{
		mainPanel.removeAllComponents();

		ArrayList<xyz.thastertyn.Types.Reports> reportsList = reports.getSdeleni();

		for(xyz.thastertyn.Types.Reports reports : reportsList)
		{
			Panel row = new Panel(new LinearLayout(Direction.HORIZONTAL));
			
			Label checkmark = new Label("");
			Label text = new Label(reports.getText());

			if(reports.isPositive())
			{
				checkmark.setForegroundColor(ANSI.GREEN);
				checkmark.setText("✓");
			}else{
				checkmark.setForegroundColor(ANSI.RED);
				checkmark.setText("✗");
			}

			row.addComponent(checkmark)
				.addComponent(text)
				.addTo(mainPanel);
		}
	}

	@Override
	public void showOptions(WindowBasedTextGUI textGUI) throws IOException {

		MessageDialog.showMessageDialog(textGUI, "Zadny vyber", "Zde neni co vybirat",  MessageDialogButton.OK);
	}
}
