package com.adealink.weparty.room.member.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.frame.util.onClick
import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
import com.adealink.weparty.room.databinding.LayoutRoomMemberPlaymateCategoryItemBinding
import com.adealink.weparty.room.member.data.MemberPlaymateCategoryItemData

class RoomMemberCategoryItemBinder(
    private val onClick: (item: MemberPlaymateCategoryItemData) -> Unit
) : ItemViewBinder<MemberPlaymateCategoryItemData, BindingViewHolder<LayoutRoomMemberPlaymateCategoryItemBinding>>() {
    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): BindingViewHolder<LayoutRoomMemberPlaymateCategoryItemBinding> {
        return BindingViewHolder(
            LayoutRoomMemberPlaymateCategoryItemBinding.inflate(inflater, parent, false)
        )
    }

    override fun onBindViewHolder(holder: BindingViewHolder<LayoutRoomMemberPlaymateCategoryItemBinding>, item: MemberPlaymateCategoryItemData) {
        holder.binding.root.onClick {
            onClick.invoke(item)
        }
        holder.binding.ivIcon.setImageUrl(item.skill.icon)
        holder.binding.tvName.text = item.skill.name
        holder.binding.vPrice.setPrice(item.skill.price, item.skill.unit)
    }
}