package com.dahe.gldriver.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.dahe.gldriver.R
import com.dahe.gldriver.bean.DriverBean
import com.dahe.glex.bean.WayBillBean
import com.dahe.mylibrary.utils.ImageLoader

/**
 * @ClassName WaybillAdapter
 * @Author 用户
 * @Date 2024/1/23 16:27
 * @Description TODO
 */
class DriversAdapter(var isInvite : Boolean = false) :
    BaseQuickAdapter<DriverBean, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: DriverBean?) {
        item?.let {
            holder.run {
                setText(R.id.tvName,it.idcardName)
                setText(R.id.tvPhone,if (isInvite) it.contactPhone else it.driverPhone)
                setText(R.id.tvDays,"""加入${it.diffDay}天""")
                ImageLoader.getInstance()
                    .loadRoundImage(context, it.driverAvatar, 6, getView<ImageView>(R.id.ivHead))


                setVisible(R.id.tvStatu,it.level=="2")
                setVisible(R.id.tvInvite,isInvite)
                setVisible(R.id.vLine,!isInvite)
                setVisible(R.id.tvDays,!isInvite)


            }
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        // 返回一个 ViewHolder
        return QuickViewHolder(R.layout.item_driver, parent)
    }
}