https://kotlinlang.org logo
#compose
Title
# compose
c

chansek

03/11/2022, 4:45 PM
How can we show ModalBottomSheet using Compose Navigation? This is how my Modal sheet looks like:
Copy code
fun AddressPicker(
    sheetState: ModalBottomSheetState,
    onConfirm: (Address) -> Unit
) {
    ModalBottomSheetLayout(
        sheetState = sheetState,
        sheetContent = { AddressForm(onConfirm) }
    ) {}
}
Then I added this into my nav graph:
Copy code
composable(route = Screen.AddressPickerScreen.route) {
    AddressPicker(sheetState = sheetState) {
       // ...
    }
}
And to show it, I used below code:
Copy code
navController.navigate(Screen.AddressPickerScreen.route)
Instead of showing the sheet content, it shows a blank canvas. What am I doing wrong?
j

jossiwolf

03/11/2022, 6:12 PM
We have Accompanist Nav Material to help you with that! Beware that it has some issues we are still working out though; it works best if your sheet content is static.
c

chansek

03/12/2022, 1:52 PM
This worked beautifully. Thanks @jossiwolf
🙌 1