Skip to content

Overhaul of Compose support. #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2022
Merged

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Mar 1, 2022

I had originally thought about creating a new ScreenComposableFactory : ViewRegistry.Entry, but that did nothing but introduce complexity. The existing system has the elegant property that every ViewFactory can produce either a @Composable or a View as needed. That's a crucial trait, and it's most easily maintained by teaching the same trick to ScreenViewFactory.

Where possible, existing tests are copied into new files with a Legacy prefix and otherwise unchanged, so that diffs of the original tests will be reviewable.

@rjrjr rjrjr force-pushed the ray/simpler-compose-overhaul branch 9 times, most recently from 5394b1b to a6b9ecf Compare March 2, 2022 01:02
@rjrjr rjrjr marked this pull request as ready for review March 2, 2022 01:44
@rjrjr rjrjr requested review from a team and zach-klippenstein as code owners March 2, 2022 01:44
@rjrjr rjrjr requested review from vgonda and helios175 March 2, 2022 16:32
@rjrjr rjrjr force-pushed the ray/simpler-compose-overhaul branch from a6b9ecf to 8623624 Compare March 2, 2022 16:53
I had originally thought about creating a new `ScreenComposableFactory : ViewRegistry.Entry`, but that did nothing but introduce complexity. The existing system has the elegant property that every `ViewFactory` can produce either a `@Composable` or a `View` as needed. That's a crucial trait, and it's most easily maintained by teaching the same trick to `ScreenViewFactory`.

Where possible, existing tests are copied into new files with a `Legacy` prefix and otherwise unchanged, so that diffs of the original tests will be reviewable.
@rjrjr rjrjr force-pushed the ray/simpler-compose-overhaul branch from 8623624 to e5b5ba9 Compare March 2, 2022 17:24
@rjrjr
Copy link
Contributor Author

rjrjr commented Mar 2, 2022

Update eliminates unnecessary "FunctionName" warning suppression -- my IDE config was botched.

* [placeholderViewFactory] that will be used to show any renderings that don't match
* [mainFactory]'s type. All placeholders will have [placeholderModifier] applied.
*/
@Composable internal fun previewViewEnvironment(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: PreviewViewEnvironment

The same goes for the original/overloaded function above this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll fix that on main.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nevermind, it's non-public. Might as well do it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope!
Screen Shot 2022-03-02 at 12 21 13 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Nevermind then! My mistake!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called rememberPreview…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjrjr rjrjr merged commit 30f85c9 into ray/ui-update Mar 2, 2022
@rjrjr rjrjr deleted the ray/simpler-compose-overhaul branch March 2, 2022 20:56
@@ -40,21 +40,21 @@ public abstract class ComposeWorkflow<in PropsT, out OutputT : Any> :
* workflow's parent.
* @param viewEnvironment The [ViewEnvironment] passed down through the `ViewBinding` pipeline.
*/
@Composable public abstract fun RenderingContent(
@Composable abstract fun RenderingContent(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Good catch, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, because this is a sample, no explicit API mode -- public is redundant.

*
* *Note: [rendering] must be the same type as this [ViewFactory], even though the type system does
* not enforce this constraint. This is due to a Compose compiler bug tracked
* [here](https://issuetracker.google.com/issues/156527332).*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is fixed…

* [placeholderViewFactory] that will be used to show any renderings that don't match
* [mainFactory]'s type. All placeholders will have [placeholderModifier] applied.
*/
@Composable internal fun previewViewEnvironment(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called rememberPreview…

@@ -11,7 +11,7 @@ import kotlin.test.assertNotSame
import kotlin.test.assertTrue

/** Worker tests that use the [Worker.test] function. Core tests are in the core module. */
class WorkerTest {
internal class WorkerTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason this became internal? given strict mode this would have been package private before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we use explicit API mode, the IDE floods tests with warnings about the need to specificy visibility. Setting the class to internal squelches that noise and makes warnings useful again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants