package com.gh.gamecenter.game.columncollection.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.catalog.CatalogActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.updateStatusBarColor

class ColumnCollectionDetailActivity : ToolBarActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        updateStatusBarColor(R.color.background_white, R.color.background_white)
    }

    override fun provideNormalIntent(): Intent {
        return getTargetIntent(
            this,
            ColumnCollectionDetailActivity::class.java,
            ColumnCollectionDetailFragment::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 ColumnCollectionDetailFragment
        return if (fragment.arguments != null) {
            Pair(fragment.requireArguments().getString(EntranceConsts.KEY_COLLECTION_ID) ?: "", "")
        } else {
            super.getBusinessId()
        }
    }

    companion object {
        /**
         * [position] 当专题合集是排行榜(多专题)类型时的起始位置
         */
        fun getIntent(
            context: Context,
            collectionId: String,
            position: Int = -1,
            entrance: String = "",
            columnName: String = ""
        ): Intent {
            val bundle = Bundle()
            bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
            bundle.putString(EntranceConsts.KEY_COLLECTION_ID, collectionId)
            bundle.putInt(EntranceConsts.KEY_POSITION, position)
            bundle.putString(EntranceConsts.KEY_COLUMNNAME, columnName)
            return getTargetIntent(
                context,
                CatalogActivity::class.java,
                ColumnCollectionDetailFragment::class.java,
                bundle
            )
        }
    }

}