package com.zj365.health.weight

import android.content.Context
import android.view.View
import androidx.core.content.ContextCompat
import com.xty.base.dialog.BaseDialog
import com.xty.common.SizeUtil
import com.zj365.health.R
import com.zj365.health.databinding.DialogTipToastBinding

class DialogTip(
    context: Context,
    var title: String,
    var confirmText: String? = "确定",
    var isSingleBtn: Boolean = false,
    var confirm: () -> Unit
) : BaseDialog(context) {
    val binding by lazy { DialogTipToastBinding.inflate(layoutInflater) }
    override fun setLayout() = binding.root
    override fun initView() {
        super.initView()
        setDialogPadding(SizeUtil.dp2px(context, 40f), 0, SizeUtil.dp2px(context, 40f), 0)
        binding.mTitle.text = title

        if (isSingleBtn) {
            binding.clTwoBtnLayout.visibility = View.GONE
            binding.mTitle.setTextColor(ContextCompat.getColor(context, R.color.col_7c7))
            binding.tvSingle.visibility = View.VISIBLE
            binding.tvSingle.text = confirmText
            binding.tvSingle.setOnClickListener {
                dismiss()
            }
        } else {
            binding.mTvConfirm.text = confirmText
            binding.mTvCancel.setOnClickListener {
                dismiss()
            }
            binding.mTvConfirm.setOnClickListener {
                confirm.invoke()
                dismiss()
            }
        }

    }
}