package kr.co.vividnext.sodalive.live.roulette.config

import android.os.Bundle
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.databinding.ActivityRouletteConfigBinding

class RouletteConfigActivity : BaseActivity<ActivityRouletteConfigBinding>(
    ActivityRouletteConfigBinding::inflate
) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        changeFragment()
    }

    override fun setupView() {
        binding.toolbar.tvBack.text = "룰렛설정"
        binding.toolbar.tvBack.setOnClickListener { finish() }
    }

    private fun changeFragment(tag: String = "settings") {
        val fragmentManager = supportFragmentManager
        val fragmentTransaction = fragmentManager.beginTransaction()

        val currentFragment = fragmentManager.primaryNavigationFragment
        if (currentFragment != null) {
            fragmentTransaction.hide(currentFragment)
        }

        val fragment = RouletteSettingsFragment()
        fragmentTransaction.add(R.id.container, fragment, tag)
        fragmentTransaction.setPrimaryNavigationFragment(fragment)
        fragmentTransaction.setReorderingAllowed(true)
        fragmentTransaction.commitNow()
    }
}
