package com.cooleshow.base.widgets.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.cooleshow.base.R;

import androidx.annotation.NonNull;

/**
 * Author by pq, Date on 2022/6/17.
 */
public class CommonConfirmDialog extends Dialog {

    private TextView mTvContent;
    private TextView mTvCancel;
    private TextView mTvConfirm;

    public CommonConfirmDialog(@NonNull Context context) {
        super(context, R.style.BaseDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_common_confirm_layout);
        mTvContent = findViewById(R.id.tv_content);
        mTvCancel = findViewById(R.id.tv_cancel);
        mTvConfirm = findViewById(R.id.tv_confirm);
        mTvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    /**
     * 设置主文本
     *
     * @param text
     */
    public void setContent(String text) {
        if (mTvContent != null) {
            mTvContent.setText(text);
        }
    }

    /**
     * 设置取消按钮text
     *
     * @param text
     */
    public void setCancelText(String text) {
        if (mTvCancel != null) {
            mTvCancel.setText(text);
        }
    }

    /**
     * 设置确认按钮text
     *
     * @param text
     */
    public void setConfirmText(String text) {
        if (mTvConfirm != null) {
            mTvConfirm.setText(text);
        }
    }

    public void setOnConfirmClickListener(View.OnClickListener listener) {
        if (mTvConfirm != null) {
            mTvConfirm.setOnClickListener(listener);
        }
    }
}
