package kr.co.vividnext.sodalive.mypage.can.status.charge

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.databinding.ItemCanChargeStatusBinding

class CanChargeStatusAdapter : RecyclerView.Adapter<CanChargeStatusAdapter.ViewHolder>() {

    val items = mutableListOf<GetCanChargeStatusResponseItem>()

    inner class ViewHolder(
        private val binding: ItemCanChargeStatusBinding
    ) : RecyclerView.ViewHolder(binding.root) {
        fun bind(item: GetCanChargeStatusResponseItem) {
            binding.tvTitle.text = item.canTitle
            binding.tvDate.text = item.date
            binding.tvChargeMethod.text = item.chargeMethod
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            ItemCanChargeStatusBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: CanChargeStatusAdapter.ViewHolder, position: Int) {
        holder.bind(items[position])
    }

    override fun getItemCount() = items.count()
}
