package com.gh.common.provider

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.viewbinding.ViewBinding
import com.therouter.router.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.core.provider.IConcernGiftPackUtilsProvider
import com.gh.gamecenter.databinding.RecyclerGiftPackBinding

@com.therouter.inject.ServiceProvider
class ConcernGiftPackUtilsProviderImpl : IConcernGiftPackUtilsProvider {
    override fun createBinding(parent: ViewGroup): ViewBinding {
        val inflater = LayoutInflater.from(parent.context)
        return RecyclerGiftPackBinding.inflate(inflater, parent, false)
            .also {
                it.gCode.goneIf(true)
            }
    }

    override fun initStyle(viewBinding: ViewBinding) {
        with(viewBinding as RecyclerGiftPackBinding) {
            val context = root.context
            tvGameName.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
            tvTime.setTextColor(com.gh.gamecenter.common.R.color.text_tertiary.toColor(context))
            tvGiftPackName.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
            tvGiftPackContent.setTextColor(com.gh.gamecenter.common.R.color.text_secondary.toColor(context))
        }
    }

    override fun getIvGameIcon(viewBinding: ViewBinding) =
        (viewBinding as RecyclerGiftPackBinding).ivIcon

    override fun getTvGameName(viewBinding: ViewBinding) =
        (viewBinding as RecyclerGiftPackBinding).tvGameName

    override fun getTvTime(viewBinding: ViewBinding) =
        (viewBinding as RecyclerGiftPackBinding).tvTime

    override fun getTvGiftPackName(viewBinding: ViewBinding) =
        (viewBinding as RecyclerGiftPackBinding).tvGiftPackName

    override fun getTvGiftPackContent(viewBinding: ViewBinding) =
        (viewBinding as RecyclerGiftPackBinding).tvGiftPackContent

}
