package de.jg_cody.Teraplex;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

import androidx.fragment.app.DialogFragment;


public class AddButtonsDialogDouble extends DialogFragment {
    private AddButtonsDialogListener listener;

    private EditText name, command1, button1, command2, button2;

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        LayoutInflater inflater = getActivity().getLayoutInflater();
        View view = inflater.inflate(R.layout.addbuttonsdialog_double, null);

        builder.setView(view)
                .setTitle("ON/OFF BUTTON")
                .setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                })
                .setPositiveButton("ADD", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                });

        name = getActivity().findViewById(R.id.dialogDouble_editText_name);
        command1 = getActivity().findViewById(R.id.dialogDouble_editText_command1);
        command2 = getActivity().findViewById(R.id.dialogDouble_editText_command2);
        button1 = getActivity().findViewById(R.id.dialogDouble_editText_button1);
        button2 = getActivity().findViewById(R.id.dialogDouble_editText_button2);
        AlertDialog mDialog = builder.create();
        mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
        return mDialog;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        try {
            listener = (AddButtonsDialogListener) context;
        } catch (ClassCastException e) {

        }
    }

    public interface AddButtonsDialogListener {
        void applyTexts(String username, String password);
    }

    public String getName()
    {
        return name.getText().toString();
    }
    public String getCommand1()
    {
        return command1.getText().toString();
    }
    public String getButton1()
    {
        return button1.getText().toString();
    }
    public String getCommand2()
    {
        return command2.getText().toString();
    }
    public String getButton2()
    {
        return button2.getText().toString();
    }
}