package com.sixin.module_p.model

import android.content.Context
import android.view.View
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.bean.GjcWaybillBean
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.refresh
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.util.CheckUtil
import com.sixin.module_p.R
import com.sixin.module_p.databinding.DialogPdaZzSelectBinding
import com.sixin.module_p.holder.PdaZzSelectViewHolder

class PdaZzSelectDialogModel(
    val list: List<GjcWaybillBean>,
    private val callBack: (GjcWaybillBean) -> Unit
) : BaseDialogModel<DialogPdaZzSelectBinding>(DIALOG_TYPE_CENTER) {

    val itemId = R.layout.item_pda_zz_select
    val itemHolder = PdaZzSelectViewHolder::class.java

    override fun layoutId(): Int {
        return R.layout.dialog_pda_zz_select
    }

    override fun onDialogCreated(context: Context) {
        binding.model = this
        binding.rv.refresh(list)

        binding.rv.addOnItemClickListener(object : IOnItemClickListener {
            override fun onItemClick(position: Int, type: Int) {
                callBack.invoke(list[position])
                dismiss()
            }
        })
    }

}