package xyz.thastertyn.ContentDisplay.Content;


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

import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;

import xyz.thastertyn.Tuples.Pair;

public class Sdeleni extends JecnaContent {
	
	private Panel sdeleniPanel = new Panel();
	private Label borderLabel = new Label("Sdeleni R.");

	private xyz.thastertyn.JecnaParse.Sdeleni sdeleni = new xyz.thastertyn.JecnaParse.Sdeleni();

	private boolean hasStarted = false;


	@Override
	public void download()
	{
		if(!hasStarted)
		{
			try{

				sdeleniPanel.setLayoutManager(new GridLayout(1)
					.setLeftMarginSize(1)
					.setRightMarginSize(1));

				sdeleni.downloadSdeleni();

				ArrayList<Pair<String, Boolean>> sdeleniList = sdeleni.getSdeleni();

				for(Pair<String, Boolean> p : sdeleniList)
				{
					String label = "";

					if(p.getValue1())
					{
						label += "✅";
					}else{
						label += "❌";
					}

					label += " " + p.getValue0();

					sdeleniPanel.addComponent(new Label(label));
				}
				hasStarted = true;
			}catch(UnknownHostException e)
			{

			}catch(IOException e)
			{

			}
		}
	}

	@Override
	public Label getLabel() {
		return borderLabel;
	}

	@Override
	public Panel getPanel() {
		return sdeleniPanel;
	}

	@Override
	public boolean hasStarted() {
		return hasStarted;
	}

	@Override
	public void specify(int y, int hy) {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException("Unimplemented method 'specify'");
	}

	@Override
	public void getOptions(WindowBasedTextGUI textGUI) {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
	}
}
