Zach Klippenstein (he/him) [MOD]
07/23/2020, 4:21 PMsetContent
extension functions to the dedicated AbstractComposeView
and ComposeView
classes. Is the ViewGroup.setContent
extension potentially going away as well? If so, will there still be a way to pass `CompositionReference`s to compositions hosted inside android views? (This issue: https://issuetracker.google.com/issues/156527485)Leland Richardson [G]
07/23/2020, 4:49 PMZach Klippenstein (he/him) [MOD]
07/23/2020, 5:00 PMLeland Richardson [G]
07/23/2020, 5:06 PMAdam Powell
07/23/2020, 5:51 PMZach Klippenstein (he/him) [MOD]
07/23/2020, 6:00 PMWould it be sufficient to have a subcomposition viewCurious what this API would look like, but I think so.
it might not be compatible with a LayoutInflater and would have to be constructed with the parent CompositionReferenceDo you mean that it would not be inflatable (must be instantiated in java/kotlin code), and that you would need to pass a CompositionReference in order to instantiate (e.g. through constructor or a factory function)? That would work for my use case perfectly, assuming that child views of this view would still be able to inflate other views. So e.g. something like this?
class SubcompositionView(
context: Context, …,
parentReference: CompositionReference
): AbstractComposeView(context, …) {
fun setContent(content: @Composable () -> Unit) {
// Set my content to content as a child of parentReference.
}
}
View
factories, and a special View
type that can be used be used to lookup a factory from the map, instantiate it, and display it. I want to be able to write a view factory that defines its content as a Composable, and can display its own nested views from the map, but any nested views that are also defined as Composables should be linked as subcompositions from the parent. Not sure if that makes it any clearer.
Here’s my actual current implementation: https://github.com/square/workflow-kotlin-compose/blob/a4636fc4c740f90e34690775b67475ab4bb89905/core-compose/src/main/java/com/squareup/workflow/ui/compose/ComposeViewFactory.kt#L123-L137 (ViewEnvironment
here is a concept that is basically the same thing as an Ambient
map).Adam Powell
07/23/2020, 6:48 PMAbstractComposeView
in this case.Zach Klippenstein (he/him) [MOD]
07/23/2020, 7:30 PM