package com.lukouguoji.gjc.holder

import android.view.View
import com.lukouguoji.gjc.activity.GjcWeighingRecordDetailsActivity
import com.lukouguoji.gjc.databinding.ItemGjcCheckInRecordBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjcCheckInRecord

/**
 * 国际出港计重明细列表 ViewHolder
 */
class GjcCheckInRecordViewHolder(view: View) :
    BaseViewHolder<GjcCheckInRecord, ItemGjcCheckInRecordBinding>(view) {

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

        // 从Activity获取当前编辑模式
        val activity = itemView.context as? GjcWeighingRecordDetailsActivity
        val isEditMode = activity?.currentEditMode ?: false

        binding.record = record
        binding.isEditMode = isEditMode
        binding.position = position  // 传入位置用于显示序号
        binding.executePendingBindings()

        // 「修改」按钮（手机独有）：打开全屏修改覆层编辑本条记录
        binding.btnEdit?.setOnClickListener {
            activity?.openPhoneEdit(record)
        }
    }
}
