package com.zj365.health.adapter

import android.widget.TextView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.MedicBean

/**
 * isShow  是否仅作展示
 * isCheckNone 是否点了无
 */
class MedicalAdapter(
    var isShow: Boolean = false,
    var isCheckNone: Boolean = false,
    var isCheck: Boolean = true,
) : BaseAdapter<MedicBean>(R.layout.item_medical) {

    override fun convert(holder: BaseViewHolder, item: MedicBean) {
        holder.getView<TextView>(R.id.mTvName).isEnabled = isCheck
        holder.getView<TextView>(R.id.mInput).isEnabled = isCheck
        if (!isShow) {
            if (isCheckNone) {//如果选择无疾病，将所有疾病选择未选择
                data[holder.layoutPosition].isSelect = item.dictName == "无"
            } else {
                if (item.dictName == "无") {//如果选择有疾病，将无改为未选择
                    data[holder.layoutPosition].isSelect = false
                }
            }
        }

        holder.getView<TextView>(R.id.mTvName).isSelected = item.isSelect
        holder.setText(R.id.mTvName, item.dictName)

        when (item.dictName) {
            "肿瘤" -> {
                holder.setGone(R.id.mInput, false)
                    .setText(R.id.mInput, item.inputStr)
            }

            "其他" -> {
                holder.setGone(R.id.mInput, false)
                    .setText(R.id.mInput, item.inputStr)

            }

            else -> {
                holder.setGone(R.id.mInput, true)
            }
        }
    }
}