Hello all, Trying to implement compose in pieces ...
# compose
b
Hello all, Trying to implement compose in pieces in an old app written mostly in Java. Is it possible to launch a compose BottomSheet from an Activity and then of course communicate the bottom sheet selection back to the activity?
s
You can hoist your state to the activity level. Read more about state hoisting here.
State hoisting is a programming pattern where you move the state of a composable to the caller of that composable
You can create your state in the activity and then pass it down to the bottom sheet, or you can create it in your view model and pass the view model down to your bottom sheet from the activity.
b
For the state that makes sense. I am still stuck on how to integrate the compose BottomSheet into an existing xml layout file that is inflated by a Java activity.
s
I guess you need
ComposeView
?
b
that is a tough one, not sure how to implement, because I think the compose bottomsheet needs to wrap the entire layout.