package com.lukouguoji.gjj.holder

import android.view.View
import com.lukouguoji.gjj.databinding.ItemIntImpManifestBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjjManifest

/**
 * 国际进港舱单 ViewHolder
 */
class IntImpManifestViewHolder(view: View) :
    BaseViewHolder<GjjManifest, ItemIntImpManifestBinding>(view) {

    override fun onBind(item: Any?, position: Int) {
        val bean = getItemBean(item) ?: return
        binding.bean = bean
        binding.position = position
        binding.executePendingBindings()

        // 选中图标点击 - 切换选择状态
        binding.ivIcon.setOnClickListener {
            bean.checked.set(!bean.checked.get())
            binding.executePendingBindings()
        }

        // 编辑按钮点击
        binding.btnEdit.setOnClickListener {
            clickListener?.onItemClick(position, 101)  // 101=编辑
        }

        // 删除按钮点击
        binding.btnDelete.setOnClickListener {
            clickListener?.onItemClick(position, 102)  // 102=删除
        }
    }
}
