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

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.SearchOptionEntity
import com.example.base.extensions.getColor
import com.example.base.utils.DensityUtils

class SearchOptionChildAdapter(private val hasParent: Boolean) :
    BaseQuickAdapter<SearchOptionEntity.OptionItem, BaseViewHolder>(R.layout.listitem_search_option_child) {
    override fun convert(holder: BaseViewHolder, item: SearchOptionEntity.OptionItem) {
        holder.setText(R.id.tv_name, item.name)
        holder.setTextColor(R.id.tv_name, if (item.isChecked) getColor(R.color.color_125ffe) else getColor(R.color.color_1a1a1a))
        holder.setVisible(R.id.iv_check, item.isChecked)
        if (hasParent) {
            holder.itemView.layoutParams.height = DensityUtils.dp2px(40f)
            holder.itemView.setPadding(DensityUtils.dp2px(30f), 0, DensityUtils.dp2px(25f), 0)
        } else {
            holder.itemView.layoutParams.height = DensityUtils.dp2px(44f)
            holder.itemView.setPadding(DensityUtils.dp2px(16f), 0, DensityUtils.dp2px(16f), 0)
        }
    }
}