package interfaces;

import quick.Action;
import quick.View;
import quick.Color;

public class Index extends View {
    private boolean yes = false;

    public Boolean init() {
        return true;
    }

    public void draw() {
        terminal.print(Color.ANSI_CYAN + "Index View" + Color.ANSI_RESET);
        terminal.print("\n");
        terminal.print("This is the index view. Use commands to navigate.\n");
        terminal.print("\n");
        terminal.print("Available commands:\n");
        terminal.print(" - test: go test view\n");
        terminal.print(" - confirm: confirm\n");

        if (yes) {
            terminal.print(Color.ANSI_GREEN + "You have confirmed yes!" + Color.ANSI_RESET + "\n");
        } else {
            terminal.print(Color.ANSI_YELLOW + "You have not confirmed yes." + Color.ANSI_RESET + "\n");
        }
    }

    public Action onCommand(String command) {
        if (command.equals("confirm")) {
            yes = true;
        }
        if (command.equals("test")) {
            return actions.redirect(Login.class);
        }
        
        return actions.nop();
    }

    public Boolean onSelection(String userInputRaw) {
        return false;
    }
}
