Othman El Jazouli
11/17/2022, 2:27 PMvar selectedUser: String? by remember {
mutableStateOf(null)
}
ModalBottomSheetLayout(
sheetState = sheetState,
sheetContent = {
selectedUser?.let {
UserDetail(
id = selectedUser,
onCloseClick = {
coroutineScope.launch {
sheetState.hide()
selectedUser = null
}
}
)
} ?: Box(modifier = Modifier.fillMaxSize())
},
) {
...
coroutineScope.launch {
selectedUser = "userid"
sheetState.show()
}
}
I added the default Box
because otherwise there is an exception
java.lang.IllegalArgumentException: The initial value must have an associated anchor.
so my questions is do you guys think this is the right way of making a dynamic modal bottom sheet or is there a better way without going through the Box?
(I know I could use scaffold but I don’t want interaction with the main screen)Hugo Bernardi
11/17/2022, 2:37 PM@Composable
private fun EmptySheet() {
// The swipeable modifier has a bug where it doesn't support having something with
// height = 0
// b/178529942
// If there are no destinations on the back stack, we need to add something to work
// around this
Box(Modifier.height(1.dp))
}
Othman El Jazouli
11/17/2022, 2:40 PMjossiwolf
11/18/2022, 12:59 PMmattinger
11/19/2022, 4:13 PMjossiwolf
11/19/2022, 4:15 PMmattinger
11/19/2022, 4:15 PMmattinger
11/19/2022, 4:16 PMmattinger
11/19/2022, 4:17 PMjossiwolf
11/19/2022, 4:26 PMmattinger
11/19/2022, 4:52 PMHugo Bernardi
11/21/2022, 8:17 AMModalBottomSheetLayout
(even if we remove the "empty sheet bug") is to have one ModalBottomSheetLayout
for multiple sheetContent
. It makes things a little bit complicated to isolate composable correctly.jossiwolf
11/21/2022, 6:21 PMsnackbarHost
to SnackbarHostState
to be able to offer a default Material snackbar implementation. Fwiw SnackbarData
is an interface, so that should allow your own definition if needed. Agree that it could be nicer though. File an issue? 🙂jossiwolf
11/21/2022, 6:22 PMI think it would be nice to handle bottom sheet with navigationDo you have more details? What are you looking for beyond Accompanist (which will be upstreamed eventually🙂)?
Hugo Bernardi
11/22/2022, 7:22 AMEmptySheet
before sheetState.hide()
call, causing a blink instead of a swipe down animation). It is a small issue but not really good for the user experience. Also, it seems that it is not recommended / not possible to override some behavior (but I think you know the subject better than me 😛)
Ultimately, I think currently the main problem with all possible implementations of the BottomSheet is the "no empty content bug" (+ material theme but we will wait for M3 impl 🙏).
Maybe I missed something? (I join you a demo back gesture vs click outside animation)