package com.lukouguoji.gnj.page.yiku.list

import android.view.View
import com.lukouguoji.gnj.databinding.ItemGnjYikuListBinding
import com.lukouguoji.gnj.page.yiku.handover.GnjYiKuHandoverActivity
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GnjYiKuBean

/**
 * 国内进港移库列表 ViewHolder
 */
class GnjYiKuListViewHolder(view: View) :
    BaseViewHolder<GnjYiKuBean, ItemGnjYikuListBinding>(view) {

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

        // 点击 checkbox 切换选中状态
        binding.ivIcon.setOnClickListener {
            bean.checked.set(!bean.checked.get())
        }

        // 点击列表项进入移交详情
        binding.ll.setOnClickListener {
            GnjYiKuHandoverActivity.startForDetails(itemView.context, bean.id)
        }

        // 侧滑菜单 - 编辑按钮
        binding.btnEdit.setOnClickListener {
            binding.swipeMenu.quickClose()
            GnjYiKuHandoverActivity.startForEdit(itemView.context, bean.id)
        }
    }
}
