package com.example.chemical.ui.adapter

import android.content.Context
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.chemical.R
import com.rc.core.log.RcLog
import com.rc.httpcore.bean.ReturnDetailsBean
import com.rc.httpcore.bean.ReturningList
import com.rc.httpcore.bean.WasteChemicalsListBean

//化学品废弃列表
class WasteChemicalsAdapter(private val ct: Context) :
//    BaseQuickAdapter<WasteChemicalsListBean, BaseViewHolder>(R.layout.item_use_list) {
    BaseQuickAdapter<ReturnDetailsBean, BaseViewHolder>(R.layout.item_use_list) {

    override fun convert(holder: BaseViewHolder, item: ReturnDetailsBean) {
        if (item.isType) {
            holder.setBackgroundResource(R.id.cont, R.color.purple_ff54a2ea)
            holder.setTextColor(R.id.chemicalName, ContextCompat.getColor(ct, R.color.white))
            holder.setTextColor(R.id.chemicalPurity, ContextCompat.getColor(ct, R.color.white))
            holder.setTextColor(R.id.surplus, ContextCompat.getColor(ct, R.color.white))
            holder.setTextColor(R.id.chemicalNumber, ContextCompat.getColor(ct, R.color.white))
            holder.setTextColor(R.id.cabinetName_doorName, ContextCompat.getColor(ct, R.color.white))
        } else {
            holder.setBackgroundResource(R.id.cont, R.color.white)
            holder.setTextColor(R.id.chemicalName, ContextCompat.getColor(ct, R.color.black))
            holder.setTextColor(R.id.chemicalPurity, ContextCompat.getColor(ct, R.color.black))
            holder.setTextColor(R.id.surplus, ContextCompat.getColor(ct, R.color.black))
            holder.setTextColor(R.id.chemicalNumber, ContextCompat.getColor(ct, R.color.black))
            holder.setTextColor(R.id.cabinetName_doorName, ContextCompat.getColor(ct, R.color.black))
        }

        holder.setText(R.id.chemicalName, "${item.chemicalName}")
        //编码
        holder.setText(R.id.chemicalPurity, "${item.tagCode}")

//        holder.setText(R.id.surplus, "${item.specNum}${item.specUnit}/${item.packUnit}")
        holder.setText(R.id.surplus, "${item.surplus}${item.specUnit}/${item.packUnit}")

        holder.setText(R.id.chemicalNumber, "${item.belongName}")

        if (item.expireTime != null) {
            when (item.expireStatus) {
                1 -> {
                    //已过期
                    holder.setText(R.id.cabinetName_doorName, "${item.expireTime}已过期")
                    holder.setTextColor(
                        R.id.cabinetName_doorName,
                        ContextCompat.getColor(ct, R.color.purple_ffff7919)
                    )
                }
                2 -> {
                    //即将过期
                    holder.setTextColor(
                        R.id.cabinetName_doorName,
                        ContextCompat.getColor(ct, R.color.purple_ffff7919)
                    )
                    holder.setText(R.id.cabinetName_doorName, "${item.expireTime}即将过期")
                }
                else -> {
                    holder.setText(R.id.cabinetName_doorName, "${item.expireTime}")
                    holder.setTextColor(
                        R.id.cabinetName_doorName,
                        ContextCompat.getColor(ct, R.color.black)
                    )
                }
            }
        }




    }
}