Reputation: 101
I have a Scaffold like this:
Scaffold(
topBar = {
TopBar(...)
},
bottomBar = {
BottomNavigationBar(...)
}
) {
NavHost(...)
}
What is the best way to change TopBar when I navigate to another screen?
Upvotes: 10
Views: 2883
Reputation: 1042
There are two possible ways to go:
Observing currentScreen
and use when
inside topBar
and change it according to that
Put topbar
inside the screen it belongs to.
For me prefer the second one since it's not shared with each other, there's no reason to use ugly when
statement for it.
Upvotes: 2