Miguel Kano
01/07/2023, 10:39 PMNavController.currentBackStackEntryAsState()
to mutate the top bar based on the current screen. This means the root Scaffold owns the declaration of the top bar. It works fine for simple cases like just toggling the visibility of the top bar or controlling the bottom bar, but I find it not very practical in the following aspects. I've searched around on this slack, but couldn't find an answer that feels satisfying.
Scaffolder(
topBar = {
if (currentScreen is ShowTopBar) {
TopAppBar(
actions = {
...
}
)
}
},
...
) {
NavHost {...}
}
1: How would the currently displayed composable screen receive the click event on the action items? Pushing the event down is discouraged. I found this post from Ian, but I don't get it
2: If which action items should display depends on the logic/data fetched from the current screen, how should that be communicated to the root Scaffold?
3: In reality with large apps, I would want to define/encapsulate such logic and click event handling closer to the actual feature rather than defining all variations of them at the root level.Christopher Mederos
06/30/2023, 5:25 AM