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
Update Compose to dev12. #41
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| public final class com/squareup/workflow/ui/compose/ComposeRendering { | ||
| public static final field Companion Lcom/squareup/workflow/ui/compose/ComposeRendering$Companion; | ||
| public static final fun <clinit> ()V | ||
| public fun <init> (Lkotlin/jvm/functions/Function2;)V | ||
| public fun <init> (Lkotlin/jvm/functions/Function4;)V | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These parameter count changes are due to the compiler changes that landed in dev12. See release notes for more info. |
||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/ComposeRendering$Companion { | ||
|
|
@@ -10,52 +10,43 @@ public final class com/squareup/workflow/ui/compose/ComposeRendering$Companion { | |
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/ComposeViewFactory : com/squareup/workflow/ui/ViewFactory { | ||
| public fun <init> (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function3;)V | ||
| public fun <init> (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function5;)V | ||
| public fun buildView (Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroid/content/Context;Landroid/view/ViewGroup;)Landroid/view/View; | ||
| public fun getType ()Lkotlin/reflect/KClass; | ||
| } | ||
|
|
||
| public abstract class com/squareup/workflow/ui/compose/ComposeWorkflow : com/squareup/workflow/Workflow { | ||
| public fun <init> ()V | ||
| public fun asStatefulWorkflow ()Lcom/squareup/workflow/StatefulWorkflow; | ||
| public abstract fun render (Ljava/lang/Object;Lcom/squareup/workflow/Sink;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/compose/Composer;)V | ||
| public abstract fun render (Ljava/lang/Object;Lcom/squareup/workflow/Sink;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/compose/Composer;II)V | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/ComposeWorkflowKt { | ||
| public static final fun composed (Lcom/squareup/workflow/Workflow$Companion;Lkotlin/jvm/functions/Function4;)Lcom/squareup/workflow/ui/compose/ComposeWorkflow; | ||
| public static final fun composed (Lcom/squareup/workflow/Workflow$Companion;Lkotlin/jvm/functions/Function6;)Lcom/squareup/workflow/ui/compose/ComposeWorkflow; | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/CompositionRootKt { | ||
| public static final fun <clinit> ()V | ||
| public static final fun withCompositionRoot (Lcom/squareup/workflow/ui/ViewEnvironment;Lkotlin/jvm/functions/Function2;)Lcom/squareup/workflow/ui/ViewEnvironment; | ||
| public static final fun withCompositionRoot (Lcom/squareup/workflow/ui/ViewRegistry;Lkotlin/jvm/functions/Function2;)Lcom/squareup/workflow/ui/ViewRegistry; | ||
| public static final fun withCompositionRoot (Lcom/squareup/workflow/ui/ViewEnvironment;Lkotlin/jvm/functions/Function4;)Lcom/squareup/workflow/ui/ViewEnvironment; | ||
| public static final fun withCompositionRoot (Lcom/squareup/workflow/ui/ViewRegistry;Lkotlin/jvm/functions/Function4;)Lcom/squareup/workflow/ui/ViewRegistry; | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/RenderAsStateKt { | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)Landroidx/compose/State; | ||
| public static synthetic fun renderAsState$default (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)Landroidx/compose/State; | ||
| public static synthetic fun renderAsState$default (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)Landroidx/compose/State; | ||
| public static synthetic fun renderAsState$default (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)Landroidx/compose/State; | ||
| public static synthetic fun renderAsState$default (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)Landroidx/compose/State; | ||
| public static final fun renderAsState (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)Landroidx/compose/State; | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/ViewEnvironmentsKt { | ||
| public static final fun WorkflowRendering (Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Landroidx/compose/Composer;)V | ||
| public static synthetic fun WorkflowRendering$default (Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Landroidx/compose/Composer;ILjava/lang/Object;)V | ||
| public static final fun WorkflowRendering (Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Landroidx/compose/Composer;III)V | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/WorkflowContainerKt { | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;)V | ||
| public static synthetic fun WorkflowContainer$default (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)V | ||
| public static synthetic fun WorkflowContainer$default (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)V | ||
| public static synthetic fun WorkflowContainer$default (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)V | ||
| public static synthetic fun WorkflowContainer$default (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;ILjava/lang/Object;)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)V | ||
| public static final fun WorkflowContainer (Lcom/squareup/workflow/Workflow;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow/ui/ViewEnvironment;Landroidx/ui/core/Modifier;Lcom/squareup/workflow/diagnostic/WorkflowDiagnosticListener;Landroidx/compose/Composer;III)V | ||
| } | ||
|
|
||
| public final class com/squareup/workflow/ui/compose/internal/ComposeSupportKt { | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,25 +18,19 @@ | |
| package com.squareup.workflow.ui.compose.internal | ||
|
|
||
| import android.content.Context | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.compose.Composable | ||
| import androidx.compose.Composition | ||
| import androidx.compose.CompositionReference | ||
| import androidx.compose.FrameManager | ||
| import androidx.compose.Recomposer | ||
| import androidx.compose.compositionFor | ||
| import androidx.lifecycle.LifecycleOwner | ||
| import androidx.ui.core.AndroidOwner | ||
| import androidx.ui.node.UiComposer | ||
| import com.squareup.workflow.ui.compose.internal.ReflectionSupport.ANDROID_OWNER_CLASS | ||
| import com.squareup.workflow.ui.compose.internal.ReflectionSupport.androidOwnerView | ||
| import com.squareup.workflow.ui.compose.internal.ReflectionSupport.createOwner | ||
| import com.squareup.workflow.ui.compose.internal.ReflectionSupport.createWrappedContent | ||
| import com.squareup.workflow.ui.compose.internal.ReflectionSupport.ownerRoot | ||
| import com.squareup.workflow.ui.core.compose.R | ||
|
|
||
| private typealias AndroidOwner = Any | ||
| private typealias WrappedComposition = Composition | ||
| private typealias LayoutNode = Any | ||
|
|
||
| private val DefaultLayoutParams = ViewGroup.LayoutParams( | ||
| ViewGroup.LayoutParams.WRAP_CONTENT, | ||
|
|
@@ -59,12 +53,13 @@ internal fun ViewGroup.setContent( | |
| parent: CompositionReference, | ||
| content: @Composable() () -> Unit | ||
| ): Composition { | ||
| FrameManager.ensureStarted() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the changes in this file are to ensure this code stays as close as possible to the actual private code in the runtime. |
||
| val composeView: AndroidOwner = | ||
| if (childCount > 0) { | ||
| getChildAt(0).takeIf(ANDROID_OWNER_CLASS::isInstance) | ||
| getChildAt(0) as? AndroidOwner | ||
| } else { | ||
| removeAllViews(); null | ||
| } ?: createOwner(context).also { addView(androidOwnerView(it), DefaultLayoutParams) } | ||
| } ?: AndroidOwner(context).also { addView(it.view, DefaultLayoutParams) } | ||
| return doSetContent(context, composeView, recomposer, parent, content) | ||
| } | ||
|
|
||
|
|
@@ -80,53 +75,38 @@ private fun doSetContent( | |
| content: @Composable() () -> Unit | ||
| ): Composition { | ||
| // val original = compositionFor(context, owner.root, recomposer) | ||
| val container = ownerRoot(owner) | ||
| val original = compositionFor( | ||
| container = container, | ||
| container = owner.root, | ||
| recomposer = recomposer, | ||
| parent = parent, | ||
| composerFactory = { slotTable, factoryRecomposer -> | ||
| UiComposer(context, container, slotTable, factoryRecomposer) | ||
| UiComposer(context, owner.root, slotTable, factoryRecomposer) | ||
| } | ||
| ) | ||
|
|
||
| val wrapped = androidOwnerView(owner).getTag(R.id.wrapped_composition_tag) | ||
| val wrapped = owner.view.getTag(R.id.wrapped_composition_tag) | ||
| as? WrappedComposition | ||
| // ?: WrappedComposition(owner, original).also { | ||
| ?: createWrappedContent(owner, original).also { | ||
| androidOwnerView(owner).setTag(R.id.wrapped_composition_tag, it) | ||
| owner.view.setTag(R.id.wrapped_composition_tag, it) | ||
| } | ||
| wrapped.setContent(content) | ||
| return wrapped | ||
| } | ||
|
|
||
| private object ReflectionSupport { | ||
|
|
||
| val ANDROID_OWNER_CLASS = Class.forName("androidx.ui.core.AndroidOwner") | ||
| private val WRAPPED_COMPOSITION_CLASS = Class.forName("androidx.ui.core.WrappedComposition") | ||
| private val ANDROID_OWNER_KT_CLASS = Class.forName("androidx.ui.core.AndroidOwnerKt") | ||
|
|
||
| private val WRAPPED_COMPOSITION_CTOR = | ||
| WRAPPED_COMPOSITION_CLASS.getConstructor(ANDROID_OWNER_CLASS, Composition::class.java) | ||
|
|
||
| private val CREATE_OWNER_FUN = | ||
| ANDROID_OWNER_KT_CLASS.getMethod("createOwner", Context::class.java, LifecycleOwner::class.java) | ||
| private val ANDROID_OWNER_ROOT_GETTER = ANDROID_OWNER_CLASS.getMethod("getRoot") | ||
| WRAPPED_COMPOSITION_CLASS.getConstructor(AndroidOwner::class.java, Composition::class.java) | ||
|
|
||
| init { | ||
| WRAPPED_COMPOSITION_CTOR.isAccessible = true | ||
| } | ||
|
|
||
| fun createOwner(context: Context): AndroidOwner = | ||
| CREATE_OWNER_FUN.invoke(null, context, null) as AndroidOwner | ||
|
|
||
| fun ownerRoot(owner: AndroidOwner): LayoutNode = | ||
| ANDROID_OWNER_ROOT_GETTER.invoke(owner) as LayoutNode | ||
|
|
||
| fun createWrappedContent( | ||
| owner: AndroidOwner, | ||
| original: Composition | ||
| ): WrappedComposition = WRAPPED_COMPOSITION_CTOR.newInstance(owner, original) as Composition | ||
|
|
||
| fun androidOwnerView(owner: AndroidOwner): View = owner as View | ||
| } | ||
Oops, something went wrong.
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.
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.
The
Pxtype is being deleted, replaced with raw floats.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.
Interesting. But…floats? Yuck.
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.
Yea, I'm not a fan either.