package com.datarecovery.master.dialog;

import android.content.Context;

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

import com.datarecovery.master.dialog.BaseDialog;
import com.datarecovery.master.R;
import com.datarecovery.master.databinding.DialogCommonSureBinding;

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


    private OnDialogClickListener onDialogClickListener;

    public PermissionDialog(@NonNull Context context) {
        super(context, R.style.Theme_Common_Dialog);
        setCancelable(false);
        binding.setOnClickSure(v -> {
            if (onDialogClickListener != null) {
                onDialogClickListener.onClickSure();
            }
        });
        binding.setOnClickCancel(v -> {
            dismiss();
            if (onDialogClickListener != null)
                onDialogClickListener.onClickCancel();
        });
    }

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

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

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

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

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

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

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

    public interface OnDialogClickListener {
        void onClickSure();

        void onClickCancel();
    }
}
