package com.yidian.shenghuoquan.bmanagercenter.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.cardview.widget.CardView
import com.yidian.shenghuoquan.bmanagercenter.R
import com.yidian.shenghuoquan.bmanagercenter.databinding.ViewLifeAccountAuthCardBinding

/**
 * author: yinjiacheng
 * date: 5/26/21 2:53 PM
 * description: 生活号认证卡片
 */
class LifeAccountAuthCardView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyle: Int = 0
) : CardView(context, attrs, defStyle) {

    private val viewBinding: ViewLifeAccountAuthCardBinding = ViewLifeAccountAuthCardBinding.bind(
        View.inflate(getContext(), R.layout.view_life_account_auth_card, this)
    )

    /**
     * 数据填充
     * @param name 认证类型
     * @param condition 条件
     * @param description 描述
     * @param isAuthenticated 是否已认证
     */
    fun setData(
        name: String,
        condition: String,
        description: String,
        isAuthenticated: Boolean
    ) {
        viewBinding.tvName.text = name
        viewBinding.tvCondition.text = condition
        viewBinding.tvDescription.text = description
        viewBinding.ivAuthenticated.visibility = if (isAuthenticated) View.VISIBLE else View.GONE
    }
}
