This repository was archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Inline WorkflowViewStub logic in ViewFactory.showRendering to avoid unnecessary intermediate Views. #29
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c93cda7
to
92dfd83
Compare
// Somewhere above us in the workflow rendering tree, there's another bindCompose factory. | ||
// We need to link to its composition reference so we inherit its ambients. | ||
setContent(recomposer, compositionReference, content) | ||
setContent(Recomposer.current(), parentComposition, content) |
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.
Everything is just using the main thread Recomposer, no need to pass it around ourselves.
Comment on lines
+126
to
+128
FrameManager.framed { | ||
renderState.value = Pair(rendering, environment) | ||
} |
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.
Seems more idiomatic to wrap the update itself in a framed, the Compose code does this internally a bunch.
ea6b394
to
fd59782
Compare
rjrjr
approved these changes
May 18, 2020
core-compose/src/main/java/com/squareup/workflow/ui/compose/ComposeViewFactory.kt
Outdated
Show resolved
Hide resolved
31407fc
to
acfbee0
Compare
fd59782
to
bf2a993
Compare
0a41c35
to
ecb5dee
Compare
…nnecessary intermediate Views. This is effectively the logic of `WorkflowViewStub`, but translated into Compose idioms. This approach has a few advantages: - Avoids extra custom views required to host `WorkflowViewStub` inside a Composition. Its trick of replacing itself in its parent doesn't play nice with Compose. - Allows us to pass the correct parent view for inflation (the root of the composition). - Avoids `WorkflowViewStub` having to do its own lookup to find the correct [ViewFactory], since we already have the correct one. Like `WorkflowViewStub`, this function uses the `ViewFactory` to create and memoize a `View` to display the rendering, keeps it updated with the latest `RenderingT` and `ViewEnvironment`, and adds it to the composition.
ecb5dee
to
da4527c
Compare
UI test for nested renderings was failing on SDK 24 device because the ordering of the semantics nodes returned by |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is effectively the logic of
WorkflowViewStub
, but translated into Compose idioms. This approach has a few advantages:WorkflowViewStub
inside a Composition. Its trickof replacing itself in its parent doesn't play nice with Compose.
WorkflowViewStub
having to do its own lookup to find the correct [ViewFactory], sincewe already have the correct one.
Like
WorkflowViewStub
, this function uses theViewFactory
to create and memoize aView
todisplay the rendering, keeps it updated with the latest
RenderingT
andViewEnvironment
, andadds it to the composition.