ScreenViewFactory

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 ScreenViewRunner.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 for some reason can't delegate to WorkflowViewStub, here is how to do the work yourself:

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
abstract val type: KClass<in ScreenT>

Functions

Link copied to clipboard
abstract fun buildView(initialRendering: ScreenT, initialEnvironment: ViewEnvironment, context: Context, container: ViewGroup? = null): ScreenViewHolder<ScreenT>

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

Link copied to clipboard
inline fun <SourceT : Screen, TransformedT : Screen> ScreenViewFactory<TransformedT>.map(noinline transform: (wrapperScreen: SourceT) -> TransformedT, crossinline prepEnvironment: (environment: ViewEnvironment) -> ViewEnvironment = { e -> e }, crossinline prepContext: (environment: ViewEnvironment, context: Context) -> Context = { _, c -> c }, crossinline showSource: (view: View, source: SourceT, transform: (wrapperScreen: SourceT) -> TransformedT, environment: ViewEnvironment, showTransformed: (TransformedT, ViewEnvironment) -> Unit) -> Unit = { _, src, xform, e, showTransformed -> showTransformed(xform(src), e) }): ScreenViewFactory<SourceT>

Transforms a ScreenViewFactory of TransformedT into one that can handle instances of SourceT.

Link copied to clipboard
fun <ScreenT : Screen> ScreenViewFactory<ScreenT>.startShowing(initialRendering: ScreenT, initialEnvironment: ViewEnvironment, contextForNewView: Context, container: ViewGroup? = null, viewStarter: ViewStarter? = null): ScreenViewHolder<ScreenT>

Convenience that combines ScreenViewFactory.buildView and ScreenViewHolder.startShowing, since we rarely need to do work between those two calls.