package com.adealink.weparty.module.widget.form.field.picture.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.databinding.WidgetPictureAddPictureItemBinding
import com.adealink.weparty.module.widget.form.field.picture.AddPictureItemData


class AddPictureItemViewBinder(
    val onItemClick: () -> Unit,
) :
    ItemViewBinder<AddPictureItemData, BindingViewHolder<WidgetPictureAddPictureItemBinding>>() {

    override fun onBindViewHolder(
        holder: BindingViewHolder<WidgetPictureAddPictureItemBinding>,
        item: AddPictureItemData,
    ) {
        holder.binding.root.onClick {
            onItemClick.invoke()
        }
    }

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