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

import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.frame.aab.util.getCompatString
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.LayoutRoomPlaymateCategoryFilterItemBinding
import com.adealink.weparty.room.member.data.PlaymateCategoryAllItemData
import com.adealink.weparty.R as APP_R

class RoomPlaymateAllCategoryItemBinder(
    private val onClick: () -> Unit
) : ItemViewBinder<PlaymateCategoryAllItemData, BindingViewHolder<LayoutRoomPlaymateCategoryFilterItemBinding>>() {
    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): BindingViewHolder<LayoutRoomPlaymateCategoryFilterItemBinding> {
        return BindingViewHolder(
            LayoutRoomPlaymateCategoryFilterItemBinding.inflate(inflater, parent, false)
        )
    }

    override fun onBindViewHolder(holder: BindingViewHolder<LayoutRoomPlaymateCategoryFilterItemBinding>, item: PlaymateCategoryAllItemData) {
        holder.binding.root.onClick {
            onClick.invoke()
        }
        holder.binding.tvTitle.text = getCompatString(APP_R.string.common_all)
        if (item.selected) {
            holder.binding.ivSelected.setImageResource(APP_R.drawable.common_check_selected_ic)
        } else {
            holder.binding.ivSelected.setImageResource(APP_R.drawable.common_check_unselected_ic)
        }
    }
}