package com.sixin.module_p.model

import android.content.Context
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.bean.GjcWaybillBean
import com.lukouguoji.module_base.bean.GjjHandoverRecordBean
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.refresh
import com.sixin.module_p.R
import com.sixin.module_p.databinding.DialogPdaLhSelectBinding
import com.sixin.module_p.holder.PdaLhSelectViewHolder

class PdaLhSelectDialogModel(
    val list: List<GjjHandoverRecordBean>,
    private val callBack: (GjjHandoverRecordBean) -> Unit
) : BaseDialogModel<DialogPdaLhSelectBinding>(DIALOG_TYPE_CENTER) {

    val itemId = R.layout.item_pda_lh_select
    val itemHolder = PdaLhSelectViewHolder::class.java

    override fun layoutId(): Int {
        return R.layout.dialog_pda_lh_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()
            }
        })
    }

}