Skip to content

Commit fe85b02

Browse files
authored
Merge pull request #732 from square/ray/legacy-env
Adds EnvironmentScreenLegacyViewFactory.
2 parents 7801194 + 19f177c commit fe85b02

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android.useAndroidX=true
88
systemProp.org.gradle.internal.publish.checksums.insecure=true
99

1010
GROUP=com.squareup.workflow1
11-
VERSION_NAME=1.8.0-uiUpdate01-SNAPSHOT
11+
VERSION_NAME=1.8.0-uiUpdate02-SNAPSHOT
1212

1313
POM_DESCRIPTION=Square Workflow
1414

workflow-ui/core-android/api/core-android.api

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ public final class com/squareup/workflow1/ui/container/DispatchCancelEventKt {
570570
public static final fun dispatchCancelEvent (Lkotlin/jvm/functions/Function1;)V
571571
}
572572

573+
public final class com/squareup/workflow1/ui/container/EnvironmentScreenLegacyViewFactory : com/squareup/workflow1/ui/ViewFactory {
574+
public static final field INSTANCE Lcom/squareup/workflow1/ui/container/EnvironmentScreenLegacyViewFactory;
575+
public fun buildView (Lcom/squareup/workflow1/ui/container/EnvironmentScreen;Lcom/squareup/workflow1/ui/ViewEnvironment;Landroid/content/Context;Landroid/view/ViewGroup;)Landroid/view/View;
576+
public synthetic fun buildView (Ljava/lang/Object;Lcom/squareup/workflow1/ui/ViewEnvironment;Landroid/content/Context;Landroid/view/ViewGroup;)Landroid/view/View;
577+
public fun getType ()Lkotlin/reflect/KClass;
578+
}
579+
573580
public final class com/squareup/workflow1/ui/container/EnvironmentScreenViewFactoryKt {
574581
public static final fun EnvironmentScreenViewFactory ()Lcom/squareup/workflow1/ui/ScreenViewFactory;
575582
}

workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/AndroidViewRegistry.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import android.content.Context
66
import android.view.View
77
import android.view.ViewGroup
88
import com.squareup.workflow1.ui.container.BackStackScreen
9+
import com.squareup.workflow1.ui.container.EnvironmentScreen
10+
import com.squareup.workflow1.ui.container.EnvironmentScreenLegacyViewFactory
911
import kotlin.reflect.KClass
1012

1113
@Deprecated("Use ScreenViewFactoryFinder.getViewFactoryForRendering()")
@@ -20,6 +22,9 @@ public fun <RenderingT : Any> ViewRegistry.getFactoryForRendering(
2022
?: (rendering as? BackStackScreen<*>)?.let {
2123
BackStackScreenLegacyViewFactory as ViewFactory<RenderingT>
2224
}
25+
?: (rendering as? EnvironmentScreen<*>)?.let {
26+
EnvironmentScreenLegacyViewFactory as ViewFactory<RenderingT>
27+
}
2328
?: (rendering as? Named<*>)?.let { NamedViewFactory as ViewFactory<RenderingT> }
2429
?: throw IllegalArgumentException(
2530
"A ViewFactory should have been registered to display $rendering, " +
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@file:Suppress("DEPRECATION")
2+
3+
package com.squareup.workflow1.ui.container
4+
5+
import com.squareup.workflow1.ui.DecorativeViewFactory
6+
import com.squareup.workflow1.ui.ViewFactory
7+
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
8+
import com.squareup.workflow1.ui.merge
9+
10+
@Suppress("DEPRECATION")
11+
@WorkflowUiExperimentalApi
12+
internal object EnvironmentScreenLegacyViewFactory : ViewFactory<EnvironmentScreen<*>>
13+
by DecorativeViewFactory(
14+
type = EnvironmentScreen::class,
15+
map = { environmentScreen, inheritedEnvironment ->
16+
Pair(environmentScreen.wrapped, environmentScreen.environment merge inheritedEnvironment)
17+
}
18+
)

0 commit comments

Comments
 (0)