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

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

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

    val items = mutableListOf<GetCanUseStatusResponseItem>()

    inner class ViewHolder(
        private val binding: ItemCanUseStatusBinding
    ) : RecyclerView.ViewHolder(binding.root) {
        fun bind(item: GetCanUseStatusResponseItem) {
            binding.tvTitle.text = item.title
            binding.tvDate.text = item.date
            binding.tvCan.text = "${item.can}"
        }
    }

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

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

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