ursus
03/03/2026, 10:01 PMentry<About>(
metadata = BottomSheetSceneStrategy.bottomSheet()
) {
AboutScreen(
onClose = { backStack.removeLastOrNull() }
)
}
When using BottomSheetStrategy in Nav3
When I have such sheet-y screen displayed and press system back button, it slides away nicely.
But when I do backstack.removeLastOrNull() from a button inside the sheet (X button on toolbar) it hides instantly
Why? Looking at onBack default value it does the same so wth?
How do I make it behave the same?Winson Chiu
03/03/2026, 10:46 PMremoveLastOrNull() when the animation finishes.ursus
03/03/2026, 10:47 PMursus
03/03/2026, 10:48 PMWinson Chiu
03/03/2026, 10:49 PMursus
03/03/2026, 10:50 PMWinson Chiu
03/03/2026, 10:50 PMWinson Chiu
03/03/2026, 10:51 PMursus
03/03/2026, 10:51 PMursus
03/03/2026, 10:52 PMursus
03/03/2026, 10:53 PMWinson Chiu
03/03/2026, 10:53 PMBackHandler, but on Android it might just be catching the dialog window finish?ursus
03/03/2026, 10:53 PMursus
03/03/2026, 10:54 PMursus
03/03/2026, 10:54 PMWinson Chiu
03/03/2026, 10:56 PMonDismiss which flows to your defined onBack which pops the back stack.ursus
03/03/2026, 10:57 PMursus
03/03/2026, 10:58 PMursus
03/03/2026, 11:00 PMWinson Chiu
03/03/2026, 11:01 PMWinson Chiu
03/03/2026, 11:01 PMursus
03/03/2026, 11:01 PMursus
03/03/2026, 11:19 PMIan Lake
03/03/2026, 11:23 PMIan Lake
03/03/2026, 11:24 PMAnimatedBottomSheetStrategy you could copy/paste into your project: https://android-review.googlesource.com/c/platform/frameworks/support/+/3931683/4/navigation[…]oidx/navigation3/ui/samples/AnimatedOverlaySamples.ktIan Lake
03/03/2026, 11:25 PMWinson Chiu
03/03/2026, 11:36 PMursus
03/03/2026, 11:46 PMWinson Chiu
03/03/2026, 11:48 PMIan Lake
03/03/2026, 11:50 PMursus
03/03/2026, 11:53 PMretain api in nav3, which currently doesn't really work with nav3 due to, or rather this PR fixes it
https://android-review.googlesource.com/c/platform/frameworks/support/+/3904490
which seems like completed but CICD failed, so not merged .. looks like a flake and then forgoten?Ian Lake
03/03/2026, 11:54 PMursus
03/03/2026, 11:55 PMIan Lake
03/03/2026, 11:57 PMursus
03/03/2026, 11:57 PMnav3x incubation space?Ian Lake
03/03/2026, 11:58 PMursus
03/03/2026, 11:59 PMursus
03/04/2026, 12:01 AMursus
03/04/2026, 12:01 AMModalBottomSheet(
onDismissRequest = onBack,
containerColor = Color.Blue, <-----
sheetState = sheetState,
modifier = Modifier.heightIn(min = minHeight.dp),
) {
entry.Content()
}Ian Lake
03/04/2026, 12:02 AMbottomSheet metadata, phewursus
03/04/2026, 12:03 AMIan Lake
03/04/2026, 12:04 AMursus
03/04/2026, 12:04 AMursus
03/04/2026, 12:10 AMreturn object : OverlayScene<Any> {
override val key = entry.contentKey
override val entries = listOf(entry)
override val previousEntries = entries.dropLast(1)
override val overlaidEntries = previousEntries.takeLast(1)
lateinit var sheetState: SheetState <-------
override val content: @Composable (() -> Unit) = {
sheetState = rememberModalBottomSheetState()
val minHeight = LocalWindowInfo.current.containerSize.height * 0.2 // 50% height
ModalBottomSheet(
onDismissRequest = onBack,
sheetState = sheetState,
modifier = Modifier.heightIn(min = minHeight.dp),
) {
entry.Content() <---------
}
}
I'm not sure how you managed it, but say you didn't come to save the day, but I'd have to make it work manually
in the beginning we discussed the entry (content) composable somehow having access to this sheetState from the stragegy/ anything from decoration really
and I was wondering what's the idiomatic way of doing this?
composition local? i.e. for entry composable to query some`LocalSheetState.get()` (`provides`ed by the content in strategy) and call hide on it? or this this direction of communication not desired at all?Ian Lake
03/04/2026, 12:12 AMursus
03/04/2026, 12:15 AMNavEntryDecorator that access a DI graph and want's to provide it to the entry
or any parameter to the entry composable
but since entry.Content() si final I'm not sure how - other than composition localIan Lake
03/04/2026, 12:16 AMursus
03/04/2026, 12:19 AM