package com.gh.gamecenter.game.commoncollection.detail

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.updateStatusBarColor

class CommonCollectionDetailActivity : ToolBarActivity() {

    override fun provideNormalIntent(): Intent {
        return getTargetIntent(
            this,
            CommonCollectionDetailActivity::class.java,
            CommonCollectionDetailFragment::class.java
        )
    }

    override fun isAutoResetViewBackgroundEnabled(): Boolean = true

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(R.color.background_white, R.color.background_white)
    }

    override fun getBusinessId(): Pair<String, String> {
        val fragment = targetFragment as CommonCollectionDetailFragment
        return if (fragment.arguments != null) {
            Pair(
                fragment.requireArguments().getString(EntranceConsts.KEY_COLLECTION_ID) ?: "",
                fragment.requireArguments().getString(EntranceConsts.KEY_BLOCK_ID) ?: ""
            )
        } else {
            super.getBusinessId()
        }
    }

    companion object {

        fun getIntent(
            context: Context,
            collectionId: String,
            blockId: String = "",
            blockName: String = "",
            entrance: String = ""
        ): Intent {
            val bundle = Bundle()
            bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
            bundle.putString(EntranceConsts.KEY_BLOCK_ID, blockId)
            bundle.putString(EntranceConsts.KEY_BLOCK_NAME, blockName)
            bundle.putString(EntranceConsts.KEY_COLLECTION_ID, collectionId)
            return getTargetIntent(
                context,
                CommonCollectionDetailActivity::class.java,
                CommonCollectionDetailFragment::class.java,
                bundle
            )
        }
    }
}