package com.zj365.health.weight

import android.content.Context
import com.xty.base.dialog.BaseDialog
import com.xty.common.util.CommonToastUtils
import com.zj365.health.databinding.DialogRemarkPostBinding

class RemarkDialog(
    context: Context,
    var name: String,
    var confirm: (remark: String) -> Unit
) : BaseDialog(context) {

    val binding by lazy { DialogRemarkPostBinding.inflate(layoutInflater) }
    override fun setLayout() = binding.root
    override fun initView() {
        super.initView()
        setDialogPadding(40, 0, 40, 0)
        binding.mUserName.text = name
        binding.mTvConfirm.setOnClickListener {
            val text = binding.etRemark.text.toString()
            if (text.isNullOrEmpty()) {
                CommonToastUtils.showToast("备注名不能为空")
                return@setOnClickListener
            }
            confirm.invoke(text)
            dismiss()
        }
        binding.mTvCancel.setOnClickListener {
            dismiss()
        }
    }
}