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 DialogTipNew(
    context: Context,
    var title: String? = "温馨提示",
    var content:String,
    var confirmText: String? = "确定",
    var cancelText:String? = "取消",
    var isSingleBtn:Boolean = false,
    var confirm: () -> Unit,
    var cancel: () -> 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 = content
        binding.tvTitle.text = title
      //  binding.mTitle.text = content

        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.text = cancelText
            binding.mTvCancel.setOnClickListener {
                cancel.invoke()
                dismiss()
            }
            binding.mTvConfirm.setOnClickListener {
                confirm.invoke()
                dismiss()
            }
        }

    }

    fun setContentNew(content:String){
        binding.mTitle.text= content
    }

    fun setTitleNew(title:String){
        binding.tvTitle.text = title
    }
}