package com.abbidot.tracker.adapter

import android.content.Context
import androidx.appcompat.widget.AppCompatCheckBox
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.PackageBenefitsBean
import com.abbidot.tracker.constant.ConstantInt

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

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: PackageBenefitsBean) {
        val checkBox = holder!!.getView(R.id.cb_subscribe_plan_detail_item) as AppCompatCheckBox
        checkBox.setOnClickListener {
            checkBox.isChecked = !checkBox.isChecked
        }
        val titleName = when (item.titleCode) {
            ConstantInt.Type1 -> mContext.getString(R.string.txt_real_time_tracking)
            ConstantInt.Type2 -> mContext.getString(R.string.txt_activity_logs)
            ConstantInt.Type3 -> mContext.getString(R.string.txt_notifications_emergencies)
            ConstantInt.Type4 -> mContext.getString(R.string.txt_customized_led)
            5 -> mContext.getString(R.string.txt_bluetooth_radar)
            6 -> mContext.getString(R.string.txt_geofencing)
            7 -> mContext.getString(R.string.txt_route_records)
            8 -> mContext.getString(R.string.txt_family_sharing)
            9 -> mContext.getString(R.string.txt_customer_support)
            else -> item.title
        }
        holder.setText(R.id.tv_subscribe_plan_detail_name, titleName)
        checkBox.isChecked = item.status == ConstantInt.Open
    }
}