package com.cheng.blzb.ui.fragment.search

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cheng.blzb.R
import com.cheng.blzb.bean.BidTypeEntity
import com.cheng.blzb.widget.CommonShapeView
import com.example.base.extensions.getColor

class HotTypeAdapter: BaseQuickAdapter<BidTypeEntity, BaseViewHolder>(R.layout.listitem_search_hot_type) {
    override fun convert(holder: BaseViewHolder, item: BidTypeEntity) {
        holder.setText(R.id.tv_name, item.name)
        val tvTag = holder.getView<CommonShapeView>(R.id.tv_tag)
        tvTag.text = "${holder.layoutPosition + 1}"
        when(holder.layoutPosition) {
            0 -> {
                tvTag.setStartColor(Color.parseColor("#FFB505"))
                tvTag.setEndColor(Color.parseColor("#FFCD1B"))
                tvTag.setTextColor(Color.WHITE)
            }
            1 -> {
                tvTag.setStartColor(Color.parseColor("#8AB7EE"))
                tvTag.setEndColor(Color.parseColor("#A7C3EA"))
                tvTag.setTextColor(Color.WHITE)
            }
            2 -> {
                tvTag.setStartColor(Color.parseColor("#F77D48"))
                tvTag.setEndColor(Color.parseColor("#F2976F"))
                tvTag.setTextColor(Color.WHITE)
            }
            else -> {
                tvTag.setStartColor(Color.TRANSPARENT)
                tvTag.setEndColor(Color.TRANSPARENT)
                tvTag.setTextColor(getColor(R.color.color_999999))
            }
        }
    }
}