package com.lukouguoji.gnc.page.inspection

import android.graphics.Color
import android.view.View
import com.lukouguoji.gnc.databinding.ItemGncInspectionBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GncInspectionBean

/**
 * 国内出港收运检查列表 ViewHolder
 */
class GncInspectionViewHolder(view: View) :
    BaseViewHolder<GncInspectionBean, ItemGncInspectionBinding>(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())
        }

        // 根据审核状态设置颜色
        when (bean.auditStatusName) {
            "已通过" -> binding.tvStatus.setTextColor(Color.parseColor("#4CAF50")) // 绿色
            "退回" -> binding.tvStatus.setTextColor(Color.parseColor("#F44336"))   // 红色
            else -> binding.tvStatus.setTextColor(Color.parseColor("#9E9E9E"))     // 灰色
        }
    }
}
