package com.abbidot.tracker.adapter

import android.content.Context
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.MenuTxtBean

/**
 *Created  by .yzq on 2024/9/9/009.
 * @link
 * @description:
 */
class SureSubscribeSummaryAdapter(
    ctx: Context, list: MutableList<MenuTxtBean>?
) : BaseRecyclerAdapter<MenuTxtBean>(ctx, list) {
    override fun getEmptyLayoutId(viewType: Int) = 0

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: MenuTxtBean) {
        holder?.apply {
            setText(R.id.tv_subscribe_summary_item_name, item.menuName)
            getTextView(R.id.tv_subscribe_summary_item_money).let {
                val string =
                    String.format(mContext.getString(R.string.txt_money_unit), item.menuValue)
                it.text = if (item.isSwitch) "-$string"
                else string
                it.setTextColor(ContextCompat.getColor(mContext, item.colorRedId))
            }
        }
    }
}