package cz.muni.sutralog.ui.list

import android.content.res.ColorStateList
import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.card.MaterialCardView
import cz.muni.sutralog.data.RockPresentableListItem
import cz.muni.sutralog.databinding.RockItemListBinding


class RockViewHolder(private val binding: RockItemListBinding)
    : RecyclerView.ViewHolder(binding.root) {

    fun bind(listItem: RockPresentableListItem,
             onItemClick: (RockPresentableListItem) -> Unit,
             onItemLongClick: (RockPresentableListItem) -> Boolean) {
        binding.rockName.text = listItem.name
        binding.rockId.text = listItem.id.toString()
        binding.rockLocation.text = listItem.locality
        binding.rockWhere.text = listItem.where
        binding.rockColor.setBackgroundColor(listItem.color)

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

    }
}