Whats the best approach to handle actions when it ...
# compose
s
Whats the best approach to handle actions when it comes to Bottom Sheet? I am using Accompanist Navigation Material , if i navigate from one Composable to BottomSheet one, and in the bottom sheet I have couple of actions that i can perform, but i need to transmit the action callbacks upstream as well, what would be the best way to do this? cc @jossiwolf
c
I don't think anything really changes? Pass lambdas into the bottom sheet and handle them where you would typically consume them.
i
What does "upstream" mean? Being destinations in your navigation graph means you can use the same techniques for returning a result to the previous destination: https://developer.android.com/guide/navigation/navigation-programmatic#returning_a_result
1
s
"Upstream" might not be the right terminology here. My case is something like this
Copy code
ModalBottomSheetLayout(bottomSheetNavigator) {
        NavHost(navController, startDestination = "home") {
           composable(route = "home") {
               Button(onClick = { navController.navigate("sheet") }) {
                   Text("Click me to see something cool!")
               }
           }
           bottomSheet(route = "sheet") {
               ConfirmationBottomSheet(
                onPositiveClick = {
                    // let "home" know "yes" is pressed
                },
                onNegativeClick = {
                   // let "home" know "no" is pressed
                }
            )
           }
        }
    }
i
So...returning a result to the previous destination? Sounds like the link I provided will be helpful then
s
Yes its should work, I was just overthinking this ! thanks alot