Berkeli Alashov
08/04/2021, 3:04 AMBackHandler
that consumes back calls before the inner most composable?
My use case is I have a BottomSheetScaffold
at the root of my app (Theme>BottomSheet>Home>NavHost) and I want to close the sheet on back clicks. But BackHandler defined in BottomSheet doesn't get invoked until all back handlers deeper in the tree are used (in my case, NavHost consumes before BottomSheet, until the first destination is reached / nav stack cleared).eygraber
08/04/2021, 3:10 AMenabled
parameter to BackHandler
but it can probably get complex managing that across your treeBerkeli Alashov
08/04/2021, 3:11 AMenabled
to only handle back clicks when the sheet is expanded. It's not checked before inner back handlers are used.eygraber
08/04/2021, 3:12 AMenabled = false
on the inner ones when you want to outer one to have controlBerkeli Alashov
08/04/2021, 3:14 AMBerkeli Alashov
08/04/2021, 3:15 AMModalBottomSheetLayout
. I can't use it because it has a HalfExpanded state that afaik can't be disabled.Ian Lake
08/04/2021, 3:18 AMIan Lake
08/04/2021, 3:19 AMif (expanded)
BackHandler {
// Collapse
}
}
ms
08/04/2021, 3:19 AManimateTo(Expanded)
which is what expand() uses under the hoodBerkeli Alashov
08/04/2021, 3:19 AMeygraber
08/04/2021, 3:20 AMIan Lake
08/04/2021, 3:21 AMIan Lake
08/04/2021, 3:22 AMBerkeli Alashov
08/04/2021, 3:22 AMeygraber
08/04/2021, 3:23 AMNavHost
is a child wouldn't that always get "added last" in this case (I guess not because OP said it worked, but I guess I'm missing something)Ian Lake
08/04/2021, 3:23 AMIan Lake
08/04/2021, 3:24 AMIan Lake
08/04/2021, 3:24 AMeygraber
08/04/2021, 3:25 AMIan Lake
08/04/2021, 3:26 AMeygraber
08/04/2021, 3:27 AMIan Lake
08/04/2021, 3:29 AMenabled
is absolutely the best way to do things when they aren't a temporary overlayjossiwolf
08/04/2021, 9:05 AMjossiwolf
08/04/2021, 5:47 PM