package com.cheng.bole.ui.fragment.mine.account

import android.widget.ImageView
import coil.load
import coil.transform.CircleCropTransformation
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cheng.bole.R
import com.cheng.bole.manager.UserConfigManager

class AccountAdapter:BaseQuickAdapter<com.cheng.bole.bean.AccountEntity, BaseViewHolder>(R.layout.listitem_account) {

    override fun convert(holder: BaseViewHolder, item: com.cheng.bole.bean.AccountEntity) {
        holder.getView<ImageView>(R.id.iv_avatar).load(item.avater) {
            transformations(CircleCropTransformation())
            placeholder(R.mipmap.ic_default_avatar)
            error(R.mipmap.ic_default_avatar)
        }
        if (item.vip_type == "1") {
            holder.setGone(R.id.tv_vip_tag, true)
        } else if (item.vip_type == "2" || item.vip_type == "3") {
            holder.setText(R.id.tv_vip_tag, if (item.vip_type == "2") item.vip_name else "终生会员")
            holder.setGone(R.id.tv_vip_tag, false)
        }
        holder.setVisible(R.id.tv_current_account, item.user_id == UserConfigManager.userInfo?.user_id)
        holder.setVisible(R.id.tv_change_account, item.user_id != UserConfigManager.userInfo?.user_id)

        holder.setText(R.id.tv_username, item.name)
        holder.setText(R.id.tv_user_id, "ID：${item.user_id}")
        holder.setGone(R.id.iv_bind_wx, !item.bind.contains("weixin"))
        holder.setGone(R.id.iv_bind_phone, !item.bind.contains("phone"))
    }
}