package com.base.appzxhy.ui.concatAdapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.ViewGroup
import com.base.appzxhy.R
import com.base.appzxhy.bean.Benefits
import com.base.appzxhy.bean.BenefitsTask
import com.base.appzxhy.databinding.ItemBenefitsDailyBinding
import com.base.appzxhy.databinding.ItemBenefitsNewUserBinding
import com.base.appzxhy.databinding.ItemBenefitsTaskBinding
import com.base.appzxhy.ui.adapter.BaseBenefitsTaskAdapter
import com.base.appzxhy.ui.adapter.CommonViewHolder
import com.base.appzxhy.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter


/**
 * 日常奖励
 */
class DailyBenefitsTaskAdapter : BaseQuickAdapter<Benefits, CommonViewHolder>() {

    override fun onBindViewHolder(holder: CommonViewHolder, position: Int, item: Benefits?) {
        item ?: return
        val binding = ItemBenefitsDailyBinding.bind(holder.itemView)
        val adapter = TaskAdapter()
        binding.rv.adapter = adapter
        adapter.submitList(item.task)
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): CommonViewHolder {
        return CommonViewHolder(R.layout.item_benefits_daily.inflate(parent))
    }

    inner class TaskAdapter : BaseBenefitsTaskAdapter(R.layout.item_benefits_task) {

        @SuppressLint("SetTextI18n")
        override fun onBindViewHolder(holder: CommonViewHolder, position: Int, item: BenefitsTask?) {
            item ?: return
            val binding = ItemBenefitsTaskBinding.bind(holder.itemView)
            binding.tvName.text = item.taskName
            binding.tvCoin.text = "+" + item.coin.toString()
            binding.tvBtn.text = item.btnDesc
        }

    }
}