package com.gh.gamecenter.gamecollection.tag

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.utils.updateStatusBarColor
import com.gh.gamecenter.entity.TagInfoEntity

class GameCollectionTagSelectActivity : ToolBarActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        updateStatusBarColor(R.color.background_white, R.color.background_white)
        setNavigationTitle("选择标签")
        if (intent.getBundleExtra(NORMAL_FRAGMENT_BUNDLE)?.getBoolean(KEY_IS_SINGLE_CHOICE) == false) {
            setToolbarMenu(R.menu.menu_save)
        } else {
            setToolbarMenu(R.menu.menu_reset)
        }
    }

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

    companion object {
        const val KEY_IS_SINGLE_CHOICE = "single_choice"
        const val KEY_SINGLE_SELECTED_TAG = "single_selected_tag"
        const val KEY_MAX_SELECT_COUNT_TAG = "max_select_count_tag"
        const val KEY_SELECT_TAGS = "select_tags"

        @JvmStatic
        fun getIntent(
            context: Context,
            singleChoice: Boolean = false,
            singleSelectedTag: TagInfoEntity? = null
        ): Intent {
            val bundle = Bundle()
            bundle.putBoolean(KEY_IS_SINGLE_CHOICE, singleChoice)
            bundle.putParcelable(KEY_SINGLE_SELECTED_TAG, singleSelectedTag)
            return getTargetIntent(
                context,
                GameCollectionTagSelectActivity::class.java,
                GameCollectionTagSelectFragment::class.java,
                bundle
            )
        }

        @JvmStatic
        fun getIntent(context: Context, chooseMaxCount: Int, selectedTags: ArrayList<TagInfoEntity>? = null): Intent {
            val bundle = Bundle()
            bundle.putBoolean(KEY_IS_SINGLE_CHOICE, chooseMaxCount == 1)
            bundle.putInt(KEY_MAX_SELECT_COUNT_TAG, chooseMaxCount)
            bundle.putParcelableArrayList(KEY_SELECT_TAGS, selectedTags)
            return getTargetIntent(
                context,
                GameCollectionTagSelectActivity::class.java,
                GameCollectionTagSelectFragment::class.java,
                bundle
            )
        }
    }
}