diff --git a/presentation/src/main/java/com/gta/presentation/ui/MainActivity.kt b/presentation/src/main/java/com/gta/presentation/ui/MainActivity.kt index dca02985..467819b1 100644 --- a/presentation/src/main/java/com/gta/presentation/ui/MainActivity.kt +++ b/presentation/src/main/java/com/gta/presentation/ui/MainActivity.kt @@ -1,19 +1,50 @@ package com.gta.presentation.ui import android.os.Bundle +import android.view.View import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController import com.gta.presentation.R import com.gta.presentation.databinding.ActivityMainBinding import com.gta.presentation.ui.base.BaseActivity class MainActivity : BaseActivity(ActivityMainBinding::inflate) { + private val navHostFragment by lazy { supportFragmentManager.findFragmentById(R.id.fcv_main) as NavHostFragment } + private val navController by lazy { navHostFragment.navController } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val navHostFragment = - supportFragmentManager.findFragmentById(R.id.fcv_home_fragment) as NavHostFragment - val navController = navHostFragment.navController - binding.bnvHomeBottomNav.setupWithNavController(navController) + + setSupportActionBar(binding.tbMain) + + setupWithBottomNavigation() + + setupWithAppBar() + } + + private fun setupWithAppBar() { + val appBarConfiguration = AppBarConfiguration(setOf(R.id.mapFragment, R.id.chattingFragment, R.id.myPageFragment)) + setupActionBarWithNavController(navController, appBarConfiguration) + } + + private fun setupWithBottomNavigation() { + binding.bnvMain.setupWithNavController(navController) + + navController.addOnDestinationChangedListener { _, destination, _ -> + when (destination.id) { + R.id.mapFragment, R.id.chattingFragment, R.id.myPageFragment -> showBottomNav() + else -> hideBottomNav() + } + } + } + + private fun showBottomNav() { + binding.bnvMain.visibility = View.VISIBLE + } + + private fun hideBottomNav() { + binding.bnvMain.visibility = View.GONE } } diff --git a/presentation/src/main/res/layout/activity_main.xml b/presentation/src/main/res/layout/activity_main.xml index 142ccd38..369c02c3 100644 --- a/presentation/src/main/res/layout/activity_main.xml +++ b/presentation/src/main/res/layout/activity_main.xml @@ -6,20 +6,26 @@ android:layout_height="match_parent" tools:context=".ui.MainActivity"> + + \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 8326d6a6..d602d71a 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -1,6 +1,6 @@ 니차내차 - 내주변 + 내 주변 채팅 마이페이지 \ No newline at end of file