package cz.muni.sutralog.ui.list

import androidx.recyclerview.widget.RecyclerView
import cz.muni.sutralog.data.CategoryPresentableListItem
import cz.muni.sutralog.databinding.CategoryItemListBinding

class CategoryViewHolder(private val binding: CategoryItemListBinding)
    : RecyclerView.ViewHolder(binding.root) {

    fun bind(listItem: CategoryPresentableListItem,
             onItemClick: (CategoryPresentableListItem) -> Unit,
             onItemLongClick: (CategoryPresentableListItem) -> Boolean) {
        binding.categoryName.text = listItem.name
        binding.categoryColor.setBackgroundColor(listItem.color)

        binding.cardContainer.setOnLongClickListener {
            onItemLongClick(listItem)
        }
        binding.cardContainer.setOnClickListener {
            onItemClick(listItem)
        }
    }
}
