package com.atmob.keyboard_android.component.item

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.atmob.keyboard_android.R
import com.atmob.keyboard_android.ext.click
import com.atmob.keyboard_android.model.AddCharacterModel
import me.drakeet.multitype.ItemViewBinder

/**
 * 添加人设按键条目
 */
class AddCharacterViewBinder(
    private val onItemClick: (item: AddCharacterModel) -> Unit
) :
    ItemViewBinder<AddCharacterModel, AddCharacterViewBinder.InnerViewHolder>() {
    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): InnerViewHolder {
        return InnerViewHolder(inflater.inflate(R.layout.item_add_character, parent, false))
    }

    override fun onBindViewHolder(
        holder: InnerViewHolder,
        item: AddCharacterModel
    ) {
        holder.vAddLayout.click {
            onItemClick.invoke(item)
        }
    }

    inner class InnerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val vAddLayout: View = itemView.findViewById(R.id.add_layout)
    }
}