package com.zj365.health.weight

import android.content.Context
import android.view.Gravity
import android.view.View
import com.xty.base.dialog.BaseDialog
import com.zj365.health.databinding.DialogTipToastBinding

class HealthDialog(
    context: Context,
    var isShowCancel: Boolean = false,
    var title: String,
    var isCenter: 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(40, 0, 40, 0)
        binding.mTitle.text = title

        binding.mTvConfirm.setOnClickListener {
            confirm.invoke()
            dismiss()
        }

        binding.tvSingle.setOnClickListener {
            confirm.invoke()
            dismiss()
        }
        if (!isCenter) {
            binding.mTitle.gravity = Gravity.LEFT
        }
        if (isShowCancel) {
            binding.mTvCancel.visibility = View.GONE
        }
        binding.mTvCancel.setOnClickListener {
            dismiss()
        }
    }

    fun setContent(content: String) {
        binding.mTitle.text = content
        binding.clTwoBtnLayout.visibility = View.GONE
        binding.tvSingle.text = "我知道了"
        binding.tvSingle.visibility = View.VISIBLE
    }

    fun setHintContent(content: String) {
        binding.mTitle.text = content
        binding.clTwoBtnLayout.visibility = View.VISIBLE
        binding.tvSingle.visibility = View.GONE
    }
}