question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can we use this with bottom navigator of Scaffold?

See original GitHub issue

Hi, thanks for the exciting library.

I have a question about getting a navigator at the Scaffold bottom navigator.

When using Scaffold with vanilla nav host, we usually do like this,

@Composable
fun RallyApp() {
    RallyTheme {
        val allScreens = RallyScreen.values().toList()
        val navController = rememberNavController()
        val backstackEntry = navController.currentBackStackEntryAsState()
        val currentScreen = RallyScreen.fromRoute(
            backstackEntry.value?.destination?.route
        )
        Scaffold(
            topBar = {
                RallyTabRow(
                    allScreens = allScreens,
                    onTabSelected = { screen -> navController.navigate(screen.name) },
                    currentScreen = currentScreen
                )
            }
        ) { innerPadding ->
            RallyNavHost(
                navController = navController,
                modifier = Modifier.padding(innerPadding)
            )
        }
    }
}

But when using Destinations,

how can we give navigator to the top or bottom bar…? In this situation?

@Composable
fun RallyApp() {
    RallyTheme {
        val allScreens = RallyScreen.values().toList()
        Scaffold(
            topBar = {
                RallyTabRow(
                    allScreens = allScreens,
                    // todo: how can we give navigator?
                    onTabSelected = { screen -> navigator.navigate(screen.name) },
                    currentScreen = currentScreen
                )
            }
        ) { innerPadding ->
            DestinationsNavHost(navGraph = NavGraphs.root)
        }
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
wangmircommented, Feb 1, 2022

@wangmir Do you mind sharing the full implementation?

@Buggyy This is my toy project, so it’s a public repo, this is it. https://github.com/wangmir/calliope/blob/d08fc6d872e2a18da1a3c84513335a7b09b55771/app/src/main/java/com/wangmir/calliope/ui/view/Home.kt

(I changed address, in case I fix the code in the future.)

2reactions
raamcostacommented, Feb 1, 2022

@Buggyy let me know if there is any way I can help! 😃

I plan to have some tutorials for specific cases like this to complement the sample app. I have a lot of things in mind still, but I want to do that eventually. Meanwhile, if there is any way I can help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BottomNavigationBar class - material library - Dart API
A bottom navigation bar is usually used in conjunction with a Scaffold, where it is provided as the Scaffold.bottomNavigationBar argument.
Read more >
How to build a bottom navigation bar in Flutter - LogRocket Blog
This tutorial demonstrates how to build, integrate, and customize a bottom navigation bar in a Flutter app.
Read more >
Flutter - Custom Bottom Navigation Bar - GeeksforGeeks
A bottom navigation bar is a material widget that is present at the bottom of an app for selecting or navigating to different...
Read more >
Flutter Bottom Navigation Bar with Multiple Navigators: A Case ...
In the Scaffold body, create a Stack with one child for each tab. Each child is an Offstage widget with a child Navigator...
Read more >
Bottom Navigation and Navigation Drawer Using Scaffold from ...
In this post I'll show navigation using bottom navigation (and ... And this is all we need to use scaffold for holding our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found