package com.lukouguoji.gjc.holder

import android.view.View
import com.lukouguoji.gjc.activity.IntExpArriveSubOrderActivity
import com.lukouguoji.gjc.databinding.ItemIntExpArriveSubOrderBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjcHaWb

/**
 * 国际出港运抵-分单明细列表 ViewHolder（5.5寸手机版专属页面）
 *
 * 选中状态变化只影响本页自身的 ViewModel（不复用全局 FlowBus.EVENT_CHECK_CHANGED，
 * 避免与主列表页共享同一事件、产生跨页面的无意义联动）。
 */
class IntExpArriveSubOrderViewHolder(view: View) :
    BaseViewHolder<GjcHaWb, ItemIntExpArriveSubOrderBinding>(view) {

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

        // 整卡点击切换选择状态
        binding.ll.setOnClickListener {
            bean.checked.set(!bean.checked.get())
            activity?.onItemCheckChanged()
            binding.executePendingBindings()
        }
    }
}
