package com.abbidot.tracker.adapter

import android.content.Context
import android.widget.RelativeLayout
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.PackageTypeBean
import com.abbidot.tracker.constant.ConstantInt

/**
 *Created  by .yzq on 2024/3/19/019.
 * @link
 * @description:
 */
class SubscriptionPlanAdapter(
    ctx: Context, list: MutableList<PackageTypeBean>?
) : BaseRecyclerAdapter<PackageTypeBean>(ctx, list) {
    override fun getEmptyLayoutId(viewType: Int) = 0

    override fun getItemLayoutId(viewType: Int) = R.layout.item_subscription_plan_layout

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: PackageTypeBean) {
        val relativeLayout = holder!!.getView(R.id.rl_subscribe_plan_shade_item) as RelativeLayout
//        val popularCardView = holder.getView(R.id.cv_subscribe_plan_item_popular) as CardView
//        val subscription = holder.getTextView(R.id.tv_subscribe_plan_item_per_year)

        if (item.selected) {
            relativeLayout.setBackgroundResource(R.drawable.shape20_yellow_border_cyan_bg)
//            popularCardView.visibility = View.VISIBLE
        } else {
            relativeLayout.setBackgroundResource(0)
//            popularCardView.visibility = View.GONE
        }

        val packageName = when (item.nameCode) {
            ConstantInt.Type1 -> mContext.getString(R.string.txt_basic)
            ConstantInt.Type2 -> mContext.getString(R.string.txt_premium)
            else -> item.name
        }
        holder.setText(R.id.tv_subscribe_plan_item_name, packageName)
        holder.setText(
            R.id.tv_subscribe_plan_item_money,
            String.format(mContext.getString(R.string.txt_money_unit), "${item.price}")
        )
//        subscription.text =
//            String.format(mContext.getString(R.string.txt_per_year_money), item.subscriptionFee)
//        subscription.visibility = if (item.subscriptionFee == 0.0) View.INVISIBLE
//        else View.VISIBLE
    }
}