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
Se7eN
05/10/2021, 9:36 PM
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
Billy Newman
05/11/2021, 11:37 AM
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
Se7eN
05/11/2021, 11:40 AM
I guess you need
ComposeView
?
b
Billy Newman
05/11/2021, 2:14 PM
that is a tough one, not sure how to implement, because I think the compose bottomsheet needs to wrap the entire layout.