Christopher Mederos
06/30/2023, 3:37 AMStylianos Gakis
06/30/2023, 5:46 AMChristopher Mederos
06/30/2023, 6:25 AMNavBackStackEntry.LocalOwnersProvider
(link) to pass the LocalViewModelStoreOwner from the nav destination to the TopAppBar. However, the documentation makes it sound like doing so might mark the NavBackStackEntry to live as long as the TopAppBar composable... which defeats the purpose of separating the content from the app bar in the scaffold in the first place?
val navController = rememberNavController()
val currentBackStack by navController.currentBackStackEntryAsState()
val currentDestinationFromStack = currentBackStack?.destination
val currentDestination =
allDestinations.find { it.route == currentDestinationFromStack?.route } ?: HomePageRoute
val navBackStackEntry by navController.currentBackStackEntryAsState()
val stateHolder = rememberSaveableStateHolder()
Scaffold(
topBar = {
navBackStackEntry?.LocalOwnersProvider(stateHolder) {
MyTopAppBar()
}
},
bottomBar = {
MyNavBar(
allDestinations = allDestinations,
currentDestination = currentDestination,
onScreenChange = { newDestination ->
navController.navigateSingleTopTo(
newDestination.route
)
})
}
) { innerPadding ->
MyNavHost(navController = navController, modifier = Modifier.padding(innerPadding))
}
Stylianos Gakis
06/30/2023, 7:48 AMChristopher Mederos
06/30/2023, 7:55 AMChristopher Mederos
07/03/2023, 12:18 AMStylianos Gakis
07/03/2023, 7:58 AMbryankeltonadams
07/24/2023, 9:25 PMStylianos Gakis
07/24/2023, 9:30 PMandroidx.compose.material3.ModalBottomSheet
which you can just use from anywhere and they are rendered on top of everything (on their own Window I think)
For dialogs I use androidx.compose.ui.window.Dialog
same thing as above
These two apply the right scrim and show at the right height all the time pretty much, haven’t had issues.
For TopAppBar that is not global at all, that is per screen if they need it. I got a custom Scaffold to make it easy to make those screens use it, so again nothing special needs to be done with it for this to work out.bryankeltonadams
07/24/2023, 9:33 PMStylianos Gakis
07/24/2023, 9:35 PMbryankeltonadams
07/24/2023, 9:36 PMStylianos Gakis
07/24/2023, 9:36 PMbryankeltonadams
07/24/2023, 9:38 PMStylianos Gakis
07/24/2023, 9:39 PMbryankeltonadams
07/24/2023, 9:40 PMStylianos Gakis
07/24/2023, 9:44 PMbryankeltonadams
07/24/2023, 9:45 PMStylianos Gakis
07/24/2023, 9:49 PMbryankeltonadams
07/24/2023, 9:51 PMbryankeltonadams
07/24/2023, 9:53 PMbryankeltonadams
07/24/2023, 9:58 PMStylianos Gakis
07/24/2023, 9:59 PMbryankeltonadams
07/24/2023, 10:00 PMbryankeltonadams
07/24/2023, 10:07 PMbryankeltonadams
07/24/2023, 10:11 PM