package com.develop.common.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.develop.base.ext.load
import com.develop.base.ext.updateText
import com.develop.common.R
import com.develop.common.databinding.ItemEntranceViewBinding

class EntranceItemView : ConstraintLayout {
    private val binding: ItemEntranceViewBinding

    constructor(context: Context) : super(context) {}
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context, attrs, defStyleAttr
    ) {
    }

    init {
        val root = View.inflate(context, R.layout.item_entrance_view, this)
        binding = ItemEntranceViewBinding.bind(root)
    }


    fun setEntranceData(data: EntranceData) {
        binding.apply {
            ivBg.load(data.bgResId)
            icIcon.load(data.iconResId)
            tvTitle.updateText(resources.getString(data.titleStrId))
        }
    }
}

data class EntranceData(
    var bgResId: Int,
    var iconResId: Int,
    var titleStrId: Int,
    var title2StrId: Int,
    var type: EntranceType
)

enum class EntranceType {
    automatic_recipes,
    automatic_programmes,
    manual_cooking,
    download_new_recipes
}