package com.abbidot.tracker.dialog

import android.content.Context
import android.text.TextUtils
import android.view.View
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.databinding.DialogPackageUpgradeBinding

/**
 *Created  by .yzq on 2022/1/7/007.
 * @link
 * @description:通用弹窗,没有标题的
 */
class CommonDialog2(
    context: Context,
    content: String = "",
    okString: String = "",
    okClickListener: OnDialogOkListener? = null,
    cancelListener: OnDialogCancelListener? = null
) : BaseDialog<DialogPackageUpgradeBinding>(DialogPackageUpgradeBinding::inflate, context) {

    private val mContent = content
    private val mOkString = okString
    private val mOkClickListener = okClickListener
    private val mCancelListener = cancelListener

    override fun initView() {
        setCanceledOnTouchOutside(false)
        mViewBinding.apply {
            if (!TextUtils.isEmpty(mContent)) {
                tvCommonDialog2Title.text = mContent
            }
            if (!TextUtils.isEmpty(mOkString)) {
                btnDialogPackageUpgradeNow.text = mOkString
            }
            setOnClickListenerViews(btnDialogPackageUpgradeNow, tvDialogPackageUpgradeLaterBtn)
        }
    }


    override fun onClick(v: View) {
        dismiss()
        mViewBinding.apply {
            when (v) {
                btnDialogPackageUpgradeNow -> mOkClickListener?.onOkClick(this@CommonDialog2)
                tvDialogPackageUpgradeLaterBtn -> mCancelListener?.onCancelClick(this@CommonDialog2)
            }
        }
    }
}