I have a bottomnavigationview which is linked with navigation component using setupWithNavController(). It works as you would expect, pressing on the menu item will move me to a required window.
The problem is, that before redirecting to a different screen, I need to check if user is logged in or not and depending on that, I would need to redirect to a different screen.
So far it seems that I can use setOnNavigationItemSelectedListener() on my bottomnavigationview, but then I loose all the convenience of setupWithNavController() as then I have to manually specify all the destinations I want to go.
Are there any better ways to implement this?
Edit: My login screen is actually transparent so, going to required fragment and then showing login screen on top might be tricky
bottomNav.setOnNavigationItemSelectedListener {
if (//not login) {
//to login fragment
false
} else {
NavigationUI.onNavDestinationSelected(it, homeController)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With