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.CategoryType
import com.develop.food.base.data.model.CategoryModel
import com.develop.food.base.widgets.CategoryTabViewLayout
import com.develop.main.R
import com.develop.main.init.ui.adapter.RecipesMainAdapter

class CategoryTabProvider : BaseItemProvider<Any>() {
    override val itemViewType: Int
        get() = RecipesMainAdapter.CATEGORY_TAB_TAG
    override val layoutId: Int
        get() = R.layout.home_category_tab_provider
    var selectedListener: OnCategoryTabSelectedListener? = null
    override fun convert(helper: BaseViewHolder, item: Any) {
        item as CategoryModel
        helper.getView<CategoryTabViewLayout>(R.id.category_tab_view).apply {
            onCategoryTabSelectedListener =
                object : CategoryTabViewLayout.OnCategoryTabSelectedListener {
                    override fun onCurrentSelected(categoryType: CategoryType) {
                        selectedListener?.onCurrentSelected(categoryType)
                    }

                }

            updateCategorySize(item.allSize, item.recipesSize, item.ingredientSize)
        }

    }

    interface OnCategoryTabSelectedListener {
        fun onCurrentSelected(categoryType: CategoryType)
    }
}