-
Notifications
You must be signed in to change notification settings - Fork 6
Add the ability to display nested renderings with bindCompose. #7
Conversation
94f16de to
7b16503
Compare
core-compose/src/main/java/com/squareup/workflow/ui/compose/ViewFactories.kt
Outdated
Show resolved
Hide resolved
core-compose/src/main/java/com/squareup/workflow/ui/compose/ViewFactories.kt
Show resolved
Hide resolved
| * | ||
| * See [this slack message](https://kotlinlang.slack.com/archives/CJLTWPH7S/p1576264533012000?thread_ts=1576262311.008800&cid=CJLTWPH7S). | ||
| */ | ||
| private class ComposableViewStubWrapper(context: Context) : FrameLayout(context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Might be a simpler way to do this using a WVS directly with a Ref, so we could get rid of this class altogether. Will probably explore as a follow up though, right now hosting legacy views in Composables is not fully supported by compose anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this, didn't work. I think it has something to do with LayoutParams not getting set correctly.
7b16503 to
62ce98e
Compare
|
Made the sample demonstrate dipping back into legacy views as well, and fixed a layout issue with legacy views. |
core-compose/src/main/java/com/squareup/workflow/ui/compose/ComposeViewFactory.kt
Outdated
Show resolved
Hide resolved
62ce98e to
308dbd5
Compare
| * Workflows can render other workflows, and renderings from one workflow can contain renderings | ||
| * from other workflows. These renderings may all be bound to their own [ViewFactory]s. Regular | ||
| * [ViewFactory]s and `LayoutRunner`s use | ||
| * [WorkflowViewStub][com.squareup.workflow.ui.WorkflowViewStub] to recursively show nested | ||
| * renderings using the [ViewRegistry][com.squareup.workflow.ui.ViewRegistry]. | ||
| * | ||
| * View factories defined using this function may also show nested renderings. Doing so is as simple | ||
| * as calling [ViewEnvironment.showRendering] and passing in the nested rendering. See the kdoc on | ||
| * that function for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjrjr How's this?
This is the Compose analog to `WorkflowViewStub`, and delegates to `WorkflowViewStub` except when the child `ViewFactory` was also created with `bindCompose`. In that case, it just invokes that factory's Composable function directly to avoid jumping back out into legacy View land.
308dbd5 to
430d476
Compare
This is the Compose analog to
WorkflowViewStub, and delegates toWorkflowViewStubexcept when the childViewFactorywas also createdwith
bindCompose. In that case, it just invokes that factory'sComposable function directly to avoid jumping back out into legacy
View land.
The API is really simple:
Includes a sample that demonstrates drawing recursive composable bindings:
