My app has the following structure and because Route B has a own bottom navigation bar and thus an own NavHost, how can I navigate from Screen C (opened from the tab bar) to Route A?
- Nested Route "/onboarding_route", startDestination = 'start'
- route 'start' -> Screen 'Login' (Composable)
- route 'legal' -> Screen 'Legal' (Composable)
- Nested Route "/login_route", startDestination = 'login'
- route 'login' -> Screen 'Login' (Composable)
- route 'register' -> Screen 'Register' (composable)
- route 'recover' -> Screen 'Recover' (composable)
- Nested Route '/main_app', startDestination 'dashboard' => with bottom navigation
- route 'dashboard' -> Screen 'Dashboard' (composable)
- route 'product' -> Screen 'Product' (composable)
- route 'profile' -> Screen 'Profile'
The navigating to the route 'main_app' should display the bottom bar navigation with three NavigationItems. I could do this with a scaffold with a bottom bar in each screen (Dashboard, Product, Profile) or I can add a MainView Screen on top, which holds the scaffold with the bottom bar:
- Nested Route '/main_app', startDestination 'mainVie/dashboard' => with bottom navigation
- route 'mainView/{tabname} => Screen 'MainView' with Scaffold & bottom bar
- route 'dashboard' -> Screen 'Dashboard' (composable)
- route 'product' -> Screen 'Product' (composable)
- route 'profile' -> Screen 'Profile'
If I work with this solution I have the following problem: Within the screens 'Dashboard', "Product' and 'Profile' I only have the navigation controller from the BottomBar and I can't navigatate to top routes like 'login_route'.
I think this is quite common scenario: You have an onboarding screen, login / registration screens and they all without a bottom bar. Once you are in the main screen you want to have displayed a bottom bar and then you probably want to go back to the login screen from one of the screen. If the whole navigations is seperated in nested navigation routes (as Google recommends) I don't know how to navigate from a nested screen back to one of the top routes.
What are the best practices to have proper and clean navigation structure?