package com.example.generator;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class EventsActivity extends AppCompatActivity {
    public static Data Data = new Data();
    private EditText eventn1;
    private EditText eventn2;
    private EditText eventn3;
    private EditText eventn4;


    private EditText eventa1;
    private EditText eventa2;
    private EditText eventa3;
    private EditText eventa4;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_events);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        EditText eventn1 = (EditText) findViewById(R.id.event1name);
        EditText eventn2 = (EditText) findViewById(R.id.event2name);
        EditText eventn3 = (EditText) findViewById(R.id.event3name);
        EditText eventn4 = (EditText) findViewById(R.id.event4name);

        EditText eventa1 = (EditText) findViewById(R.id.event1API);
        EditText eventa2 = (EditText) findViewById(R.id.event2API);
        EditText eventa3 = (EditText) findViewById(R.id.event3API);
        EditText eventa4 = (EditText) findViewById(R.id.event4API);



        Button backButton = (Button) findViewById(R.id.backButton);
        Button nextButton = (Button) findViewById(R.id.nextButton);
        backButton.setOnClickListener((v) -> {
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
        });
        nextButton.setOnClickListener((v) -> {
            String Eventn1 = eventn1.getText().toString();
            String Eventn2 = eventn2.getText().toString();
            String Eventn3 = eventn3.getText().toString();
            String Eventn4 = eventn4.getText().toString();

            String Eventa1 = eventa1.getText().toString();
            String Eventa2 = eventa2.getText().toString();
            String Eventa3 = eventa3.getText().toString();
            String Eventa4 = eventa4.getText().toString();
                if (Eventn1.matches("") ||
                    Eventn2.matches("") ||
                    Eventa1.matches("") ||
                    Eventa2.matches("")) {
                Toast.makeText(this, "fill at least events 1 and 2", Toast.LENGTH_LONG).show();
            } else {
                    Data.setEventn1(Eventn1);
                    Data.setEventn2(Eventn2);
                    Data.setEventn3(Eventn3);
                    Data.setEventn4(Eventn4);

                    Data.setEventa1(Eventa1);
                    Data.setEventa2(Eventa2);
                    Data.setEventa3(Eventa3);
                    Data.setEventa4(Eventa4);

                    Intent intent = new Intent(this, ColorActivity.class);
                    startActivity(intent); }
        });
    }
}