Skip to content

Conversation

@rjrjr
Copy link
Collaborator

@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 helios175 and vgonda 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
Collaborator 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
Collaborator 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
Collaborator 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
Collaborator 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
Collaborator 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
* @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
Collaborator 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
Collaborator 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…


/** 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
Collaborator 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.

5 participants