adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.27k stars 109 forks source link

How to set the actionbar functionalities using the TabNavigation? #389

Open andretietz opened 1 month ago

andretietz commented 1 month ago

Hey!

I am struggeling to find a solution for setting the actionbar title and backbutton functionality, when using the TabNavigation.

I am using the TabNavigation like so:

TabNavigator(Tab1) { nav ->
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text(nav.current.options.title) },
            )
        },
        modifier = Modifier
            .fillMaxSize(),
        bottomBar = {
            NavigationBar {
                TabNavigationItem(Tab1)
                TabNavigationItem(Tab2)
                TabNavigationItem(Tab3)
                TabNavigationItem(SettingsTab)
            }
        },
        content = { CurrentTab() },
    )
}

Every Tab has it's own navigation stack. I would like to see that every Screen can set it's own title (not just the tab as I am doing in the code right now). Also important is setting a Back button functionality, which is also very dependent on which Screen I am at.

Is there a common pattern for that already? If so, I didn't find it yet.