package it.integry.integrywmsnative.gest.accettazione_ordine_inevaso.views;

import android.content.Context;
import com.google.android.material.textfield.TextInputEditText;
import androidx.appcompat.app.AlertDialog;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.utility.UtilityDimension;

public class NoteAggiuntiveNuovaULDialog {

    public interface Callback {
        void onSuccess(String noteString);
        void onAbort();
    }


    public static void show(Context mContext, final Callback callback){

        RelativeLayout relativeLayout = new RelativeLayout(mContext);

        relativeLayout.setLayoutParams(
                new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.MATCH_PARENT,
                        RelativeLayout.LayoutParams.MATCH_PARENT));

        relativeLayout.setPadding(UtilityDimension.convertSizeToDP(mContext, 22),
                UtilityDimension.convertSizeToDP(mContext, 8),
                UtilityDimension.convertSizeToDP(mContext, 24),
                0);

        final TextInputEditText mTextInputEditText = new TextInputEditText(mContext);
        mTextInputEditText.setHint(R.string.hint_additional_notes);

        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);

        mTextInputEditText.setLayoutParams(layoutParams);

        relativeLayout.addView(mTextInputEditText);

        AlertDialog dialog = new AlertDialog.Builder(mContext)
                .setTitle(mContext.getText(R.string.action_create_ul))
                .setMessage(R.string.dialog_message_additional_notes)

                .setCancelable(false)

                .setView(relativeLayout)

                .setPositiveButton(R.string.confirm, (dialog1, which) -> callback.onSuccess(mTextInputEditText.getText().toString()))
                .setNegativeButton(R.string.abort, (dialogInterface, i) -> callback.onAbort())
                .create();
        dialog.show();
    }

}
