package com.gh.gamecenter.minigame.qq

import android.os.Bundle
import android.view.View
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.databinding.FragmentQgameHomeBinding

class QGameHomeWrapperFragment : ToolbarFragment() {

    private lateinit var viewBinding: FragmentQgameHomeBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setNavigationTitle(getString(R.string.mini_game_title))
        val contentFragment = childFragmentManager.findFragmentById(R.id.wrapper_content) ?: QGameFragment()
        childFragmentManager.beginTransaction().replace(R.id.wrapper_content, contentFragment).commitAllowingStateLoss()
    }

    override fun getInflatedLayout(): View =
        FragmentQgameHomeBinding.inflate(layoutInflater).also { viewBinding = it }.root

    override fun initView(view: View?) {
        super.initView(view)
        viewBinding.searchBar.root.setOnClickListener {
            DirectUtils.directToMiniGameSearch(it.context, "请输入小游戏关键词", "小游戏")
        }
    }

    override fun getLayoutId(): Int = 0
}