package com.gh.gamecenter.category2

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

/**
 * 新分类2.0
 */
class CategoryV2Activity : DownloadToolbarActivity() {

    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 provideNormalIntent(): Intent {
        return getTargetIntent(this, CategoryV2Activity::class.java, CategoryV2Fragment::class.java)
    }

    override fun isAutoResetViewBackgroundEnabled() = true

    override fun getBusinessId(): Pair<String, String> {
        val categoryId = intent.extras?.getString(EntranceConsts.KEY_CATEGORY_ID, "") ?: ""
        return Pair(categoryId, "")
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
        getMenuItem(R.id.menu_search).setIcon(R.drawable.ic_column_search)
    }

    companion object {
        fun getIntent(context: Context, catalogId: String, catalogTitle: String, entrance: String): Intent {
            val bundle = Bundle()
            bundle.putString(EntranceConsts.KEY_PAGE_ID, catalogId)
            bundle.putString(EntranceConsts.KEY_PAGE_NAME, catalogTitle)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
            return getTargetIntent(context, CategoryV2Activity::class.java, CategoryV2Fragment::class.java, bundle)
        }
    }
}