package es.verdnatura.presentation.view.feature.shelvingparking.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemShelvingparkingRowBinding
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO

class ShelvingParkingAdapter (
    private val items: List<ItemShelvingParkingVO>
): RecyclerView.Adapter<ShelvingParkingAdapter.ItemHolder> () {


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

    override fun getItemCount() =items.size

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

    inner class ItemHolder(
        val binding: ItemShelvingparkingRowBinding
    ) : RecyclerView.ViewHolder(binding.root){
        private val res = binding.root.context.resources
        fun bind(item: ItemShelvingParkingVO) {
            binding.apply {
                this.item = item

            }
        }
    }
}