Skip to content

//workflow/com.squareup.workflow1.ui/ScreenViewFactory

ScreenViewFactory

[androidJvm] @WorkflowUiExperimentalApi()

interface ScreenViewFactoryScreenT : Screen> : ViewRegistry.Entry<ScreenT>

A ViewRegistry.Entry that can build Android View instances, along with functions that can update them to display Screen renderings of a particular type, bundled together in instances of ScreenViewHolder.

Use fromLayout, fromViewBinding, etc., to create a ScreenViewFactory. These helper methods take a layout resource, view binding, or view building function as arguments, along with a factory to create a showRendering function.

It is rare to call buildView directly. Instead the most common path is to pass Screen instances to WorkflowViewStub.show, which will apply the ScreenViewFactory machinery for you.

If you are building a custom container and WorkflowViewStub is too restrictive, use ScreenViewFactory.startShowing.

Types

Name Summary
Companion [androidJvm]
Content
object Companion


Functions

Name Summary
buildView [androidJvm]
Content
abstract fun buildView(initialRendering: ScreenT, initialEnvironment: ViewEnvironment, context: Context, container: ViewGroup? = null): ScreenViewHolder<ScreenT>
More info
It is rare to call this method directly.


Properties

Name Summary
type [androidJvm] abstract val type: KClassScreenT>

Inheritors

Name
ComposeScreenViewFactory

Extensions

Name Summary
Preview [androidJvm]
Content
@WorkflowUiExperimentalApi()
@Composable()

fun <RenderingT : Screen> ScreenViewFactory<RenderingT>.Preview(rendering: RenderingT, modifier: Modifier = Modifier, placeholderModifier: Modifier = Modifier, viewEnvironmentUpdater: (ViewEnvironment) -> ViewEnvironment? = null)
More info
Draws this ScreenViewFactory using a special preview ScreenViewFactoryFinder.


startShowing [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <ScreenT : Screen> ScreenViewFactory<ScreenT>.startShowing(initialRendering: ScreenT, initialEnvironment: ViewEnvironment, contextForNewView: Context, container: ViewGroup? = null, viewStarter: ViewStarter? = null): ScreenViewHolder<ScreenT>
More info
It is rare to call this method directly.


toUnwrappingViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

inline fun <WrapperT : Screen, WrappedT : Screen> ScreenViewFactory<WrappedT>.toUnwrappingViewFactory(crossinline unwrap: (WrapperT) -> WrappedT): ScreenViewFactory<WrapperT>
@WorkflowUiExperimentalApi()

inline fun <WrapperT : Screen, WrappedT : Screen> ScreenViewFactory<WrappedT>.toUnwrappingViewFactory(crossinline unwrap: (WrapperT) -> WrappedT, crossinline showWrapperScreen: (view: View, WrapperT, environment: ViewEnvironment, showUnwrappedScreen: (WrappedT, ViewEnvironment) -> Unit) -> Unit): ScreenViewFactory<WrapperT>
More info
Transforms a ScreenViewFactory of WrappedT into one that can handle instances of WrapperT.