package com.develop.main.init.ui.provider

import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.develop.food.base.data.model.CommonSearchModel
import com.develop.food.base.widgets.CommonSearchLayout
import com.develop.main.R
import com.develop.main.init.ui.adapter.RecipesMainAdapter

class CommonSearchProvider : BaseItemProvider<Any>() {
    override val itemViewType: Int
        get() = RecipesMainAdapter.SEARCH_TAG
    override val layoutId: Int
        get() = R.layout.home_common_search_provider

    var hotWordsSelectedListener: OnHotWordsSelectedListener? = null
    override fun convert(helper: BaseViewHolder, item: Any) {
        item as CommonSearchModel
        helper.getView<CommonSearchLayout>(R.id.common_search_view).apply {
            updateData(item)
            onHotWordsSelectedListener = object : CommonSearchLayout.OnHotWordsSelectedListener {
                override fun onHotWordsSelected(hotWord: String) {
                    hotWordsSelectedListener?.onHotWordsSelected(hotWord)
                }

            }
        }
    }



    interface OnHotWordsSelectedListener {
        fun onHotWordsSelected(hotWord: String)
    }
}