-
Notifications
You must be signed in to change notification settings - Fork 102
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
BREAKING: Compose overhaul makes ViewEnvironment less in your face. #1207
Conversation
605b33b
to
6f57480
Compare
b3f43e1
to
059b5e7
Compare
workflow-ui/compose/src/main/java/com/squareup/workflow1/ui/compose/LocalWorkflowEnvironment.kt
Show resolved
Hide resolved
...-ui/compose/src/main/java/com/squareup/workflow1/ui/compose/ScreenComposableFactoryFinder.kt
Outdated
Show resolved
Hide resolved
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.
really awesome stuff!
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 tracks and makes sense to me at a high-level but I'm realizing that I need to take more of a deep-dive into the Workflow Compose integration. I've been taking it for granted.
...compose/src/main/java/com/squareup/workflow1/ui/compose/ViewEnvironmentWithComposeSupport.kt
Show resolved
Hide resolved
@wardellbagby I've kept this README up to date. |
* Introduces `LocalWorkflowEnvironment` and eliminates explicit `ViewEnvironment` parameters from `ScreenComposableFactory.Content`, `ComposeScreen.Content`, etc. It is put in place automatically by the default implementation of `ScreenComposableFactoryFinder`. * Adds optional `CompositionRoot` argument to `ViewEnvironment.withComposeInteropSupport()`. `CompositionRoot` is our existing hook to ensure `CompositionLocal`s (e.g. for UI themes) are put in play above the `@Composable Content()` function invoked for any `Screen`. * Replaces `ViewEnvironment.withCompositionRoot` with `@Composable fun ViewEnvironment.RootScreen`, as our preferred Compose-friendly alternative to `WorkflowLayout` An `Activity` that uses `setContent {}` instead of `setContentView()` can now kick things off like so: ```kotlin override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val environment : ViewEnvironment = ViewEnvironment.EMPTY + // ... .withComposeInteropSupport() val rootScreen by RootWorkflow.renderAsState( props = Unit, onOutput = {}, ) setContent { environment.RootScreen(rootScreen) } } ```
059b5e7
to
6fb63df
Compare
@RBusarow any guesses as to why the checks aren't running on this PR? |
Maybe lingering effects from the earlier outage. Closed and opened to try again. |
Introduces
LocalWorkflowEnvironment
and eliminates explicitViewEnvironment
parameters fromScreenComposableFactory.Content
,ComposeScreen.Content
, etc. It is put in place automatically by the default implementation ofScreenComposableFactoryFinder
.Adds optional
CompositionRoot
argument toViewEnvironment.withComposeInteropSupport()
.CompositionRoot
is our existing hook to ensureCompositionLocal
s (e.g. for UI themes) are put in play above the@Composable Content()
function invoked for anyScreen
.Replaces
ViewEnvironment.withCompositionRoot
with@Composable fun ViewEnvironment.RootScreen
, as our preferred Compose-friendly alternative toWorkflowLayout
An
Activity
that usessetContent {}
instead ofsetContentView()
can now kick things off like so: