package com.adealink.weparty.profile.ui.about

import android.annotation.SuppressLint
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.module.profile.data.UserPlayMateSkill
import com.adealink.weparty.profile.databinding.LayoutProfileSkillItemBinding

data class SkillItemData(
    val data: UserPlayMateSkill
)

class SKillViewBinder(
    val order: (item: UserPlayMateSkill) -> Unit
) :
    ItemViewBinder<SkillItemData, BindingViewHolder<LayoutProfileSkillItemBinding>>() {

    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): BindingViewHolder<LayoutProfileSkillItemBinding> {
        return BindingViewHolder(LayoutProfileSkillItemBinding.inflate(inflater, parent, false))
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(
        holder: BindingViewHolder<LayoutProfileSkillItemBinding>,
        item: SkillItemData
    ) {
        holder.binding.ivBg.setImageUrl(item.data.cover)
        holder.binding.ivIcon.setImageUrl(item.data.icon)
        holder.binding.tvTitle.text = item.data.name
        holder.binding.tvDesc.text = "${item.data.price}/${item.data.unit}"
        holder.binding.btnOrder.onClick {
            order.invoke(item.data)
        }
    }

}