Skip to content

Commit

Permalink
feat: 바텀 네비게이션 클릭 시 쌓였던 BackStack 이 초기화된다.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed May 19, 2024
1 parent 8b995af commit 6ed29d7
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.navigation.NavController
import androidx.navigation.NavOptions
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.festago.festago.presentation.R
Expand Down Expand Up @@ -60,9 +61,23 @@ class HomeActivity : AppCompatActivity() {
(supportFragmentManager.findFragmentById(R.id.fcvHomeContainer) as NavHostFragment).navController
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.nvHome)
bottomNavigationView.setupWithNavController(navController)

setBottomNavPopUpBackstack(bottomNavigationView)
setNavColor()
}

private fun setBottomNavPopUpBackstack(bottomNavigationView: BottomNavigationView) {
bottomNavigationView.setOnItemSelectedListener {
val options = NavOptions.Builder()
.setPopUpTo(R.id.main_graph_xml, false)
.setLaunchSingleTop(true)
.build()

navController.navigate(it.itemId, null, options)
true
}
}

private fun setNavColor() {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.white)
Expand Down

0 comments on commit 6ed29d7

Please sign in to comment.