package com.gh.gamecenter.tag

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.base.DownloadToolbarActivity
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.SearchActivity
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.EntranceConsts.KEY_EXPOSURE_SOURCE_LIST
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.updateStatusBarColor

/**
 * 标签详情
 */
class TagsActivity : DownloadToolbarActivity() {

    companion object {

        const val TAG = "tag"
        const val FROM = "from"
        const val SOURCE = "source"

        @JvmStatic
        fun getIntent(
            context: Context,
            tag: String,
            source: String?,
            entrance: String,
            path: String,
            exposureSourceList: List<ExposureSource>? = null
        ): Intent {
            val bundle = Bundle()
            bundle.putString(TAG, tag)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
            bundle.putString(SOURCE, source ?: "")
            if (exposureSourceList != null) bundle.putParcelableArrayList(
                KEY_EXPOSURE_SOURCE_LIST,
                ArrayList(exposureSourceList)
            )

            when (context) {
                is GameDetailActivity -> bundle.putString(FROM, From.GAME_DETAIL.value)
                is SearchActivity -> bundle.putString(FROM, From.SEARCH.value)
                else -> bundle.putString(FROM, From.OTHERS.value)
            }
            return getTargetIntent(context, TagsActivity::class.java, TagsListFragment::class.java, bundle)
        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
    }

    override fun showDownloadMenu(): Boolean {
        return true
    }

    override fun getActivityNameInChinese(): String {
        return "游戏标签详情"
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
    }

    enum class From(val value: String) {
        GAME_DETAIL("game_detail"),

        SEARCH("search"),

        OTHERS("others")
    }

}