package com.gh.gamecenter.gamedetail.detail.viewholder

import androidx.lifecycle.LifecycleOwner
import com.gh.gamecenter.databinding.ItemGameDetailContentCardDoubleBinding
import com.gh.gamecenter.feature.view.DownloadButton
import com.gh.gamecenter.gamedetail.GameDetailViewModel
import com.gh.gamecenter.gamedetail.entity.GameDetailData

class GameDetailContentCardDoubleItemViewHolder(
    val binding: ItemGameDetailContentCardDoubleBinding,
    downloadBtn: DownloadButton?,
    viewModel: GameDetailViewModel,
    private val lifecycleOwner: LifecycleOwner
) :
    BaseGameDetailItemViewHolder(binding.root, downloadBtn, viewModel) {
    override fun bindView(data: GameDetailData) {
        super.bindView(data)
        data.linkContentCard?.let {
            val getGameStatus = { gameStatus }
            GameDetailContentCardSingleItemViewHolder.bindContentCard(
                lifecycleOwner,
                viewModel,
                it.first(),
                data.cardBackground,
                binding.firstCardContainer,
                baseTrackData.apply { supSequence = 0 },
                getGameStatus
            )
            GameDetailContentCardSingleItemViewHolder.bindContentCard(
                lifecycleOwner,
                viewModel,
                it[1],
                null,
                binding.secondCardContainer,
                baseTrackData.apply { supSequence = 1 },
                getGameStatus
            )
        }
    }
}