package com.datarecovery.master.dialog;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.StringRes;

import com.datarecovery.master.R;
import com.datarecovery.master.data.consts.EventId;
import com.datarecovery.master.databinding.DialogCommonSureBinding;
import com.datarecovery.master.handler.EventHelper;

@BaseDialog.FullScreen(height = false)
public class CommonSureDialog extends BaseDialog<DialogCommonSureBinding> {


    private OnDialogClickListener onDialogClickListener;

    public CommonSureDialog(@NonNull Context context) {
        super(context, R.style.Theme_Common_Dialog);
        setCancelable(false);
        binding.setOnClickSure(v -> {
            if (onDialogClickListener != null) {
                onDialogClickListener.onClickSure();
            }
            dismiss();
            EventHelper.report(EventId.EVENT_3000201);
        });
        binding.setOnClickCancel(v -> {
            dismiss();
            EventHelper.report(EventId.EVENT_3000202);
        });
    }

    public void setOnDialogClickListener(OnDialogClickListener onDialogClickListener) {
        this.onDialogClickListener = onDialogClickListener;
    }

    public CommonSureDialog setDialogTitle(@StringRes int tips) {
        binding.tvDialogTitle.setText(tips);
        return this;
    }

    public CommonSureDialog setDialogTitle(String tips) {
        binding.tvDialogTitle.setText(tips);
        return this;
    }

    public CommonSureDialog setTitleGravity(int gravity) {
        binding.tvDialogTitle.setGravity(gravity);
        return this;
    }

    public CommonSureDialog setDialogContent(@StringRes int content) {
        binding.tvContent.setText(content);
        return this;
    }

    public CommonSureDialog setDialogContent(String content) {
        binding.tvContent.setText(content);
        return this;
    }

    public CommonSureDialog setContentGravity(int gravity) {
        binding.tvContent.setGravity(gravity);
        return this;
    }

    public CommonSureDialog setSureText(@StringRes int sureText) {
        binding.tvSure.setText(sureText);
        return this;
    }

    public CommonSureDialog setCancelText(@StringRes int cancelText) {
        binding.tvCancel.setText(cancelText);
        return this;
    }

    public void setOnCancelClick(View.OnClickListener onClickListener) {
        binding.setOnClickCancel(onClickListener);
    }

    public interface OnDialogClickListener {
        void onClickSure();
    }

}
