package com.sambath.kunkhmer.app

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.sambath.kunkhmer.R
import com.sambath.kunkhmer.screen.fighter.FighterFragment

class MainActivity : AppCompatActivity(), FighterFragment.TabSelectionListener {

    lateinit var navView: BottomNavigationView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)

        navView =  findViewById<BottomNavigationView>(R.id.nav_view)
        val navController = findNavController(R.id.nav_host_fragment_activity_main)
        val appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.navigation_home,
                R.id.navigation_dashboard,
                R.id.navigation_live,
                R.id.navigation_event,
                R.id.navigation_shop
            )
        )

        //setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }

    override fun onTabSelected(tabIndex: Int) {
        val fragment = supportFragmentManager.findFragmentById(R.id.navigation_home)
        if (fragment is FighterFragment) {
            fragment.selectTab(tabIndex)
        }
    }
}