-
Notifications
You must be signed in to change notification settings - Fork 101
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
Conversation
5394b1b
to
a6b9ecf
Compare
...mpose-tooling/src/main/java/com/squareup/workflow1/ui/compose/tooling/ScreenViewFactories.kt
Outdated
Show resolved
Hide resolved
a6b9ecf
to
8623624
Compare
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.
8623624
to
e5b5ba9
Compare
Update eliminates unnecessary "FunctionName" warning suppression -- my IDE config was botched. |
samples/compose-samples/src/main/java/com/squareup/sample/compose/preview/PreviewActivity.kt
Show resolved
Hide resolved
* [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( |
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: PreviewViewEnvironment
The same goes for the original/overloaded function above this.
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.
I think I'll fix that on main.
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.
Oh, nevermind, it's non-public. Might as well do it here.
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.
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.
Ah! Nevermind then! My mistake!
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.
Should be called rememberPreview…
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.
@@ -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( |
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.
Why no public?
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.
Oops! Good catch, thanks.
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.
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).* |
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.
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( |
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.
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 { |
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.
any reason this became internal? given strict mode this would have been package private before?
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.
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.
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 everyViewFactory
can produce either a@Composable
or aView
as needed. That's a crucial trait, and it's most easily maintained by teaching the same trick toScreenViewFactory
.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.