package com.zj365.health.adapter.binddevice

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.BodyFatBean


class BodyFatDetailAdapter : BaseAdapter<BodyFatBean.Label>(R.layout.item_body_fat_detail) {
    override fun convert(holder: BaseViewHolder, item: BodyFatBean.Label) {

        holder.setText(R.id.tvBmi, item.label)
        holder.setText(R.id.tvStatus, item.labelLevelName)

        val value = holder.getView<TextView>(R.id.tvBmiValue)
        if (item.label == "身体年龄"||item.label == "基础代谢量"){
            holder.setText(R.id.tvBmiValue, "${item.labelValue.toInt()}")
        }else{
            holder.setText(R.id.tvBmiValue, "${item.labelValue}")
        }
        holder.setText(R.id.tvBmiUnit,"${item.labelUnit}")

        when (item.labelLevelName) {

            "偏低","偏高" -> {
//                holder.setVisible(R.id.ivLabel,false)
                holder.setTextColor(R.id.tvStatus, ContextCompat.getColor(context, R.color.col_360))
            }
            "标准","理想","年轻"-> {
//                holder.setVisible(R.id.ivLabel,true)
                holder.setTextColor(R.id.tvStatus, ContextCompat.getColor(context, R.color.col_9Bd))
//                holder.setImageResource(R.id.ivLabel,R.mipmap.ic_arrow_green_up)
            }
        }
    }
}