package com.base.scanqrclear.luma

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.base.scanqrclear.databinding.ItemFunctionMoreBinding

class FunctionMoreAdapter(
    data: List<FunctionBean>
) : BaseAdapter<FunctionBean, ItemFunctionMoreBinding>(data) {

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup
    ): ItemFunctionMoreBinding {
        return ItemFunctionMoreBinding.inflate(layoutInflater, parent, false)
    }

    override fun bind(
        holder: BaseViewHolder<ItemFunctionMoreBinding>,
        position: Int,
        item: FunctionBean
    ) {
        holder.binding.ivIcon.setImageResource(item.icon)
        holder.binding.tvName.setText(item.name)
        holder.binding.viewLine.visibility = if (position + 1 == itemCount) View.INVISIBLE else View.VISIBLE
        holder.itemView.setOnClickListener { callback?.onClicked(it, position, item) }
    }
}