Package-level declarations

Types

Link copied to clipboard

Interface implemented by a Screen rendering class to minimize the boilerplate required for it to drive an Android UI via an appropriate ScreenViewFactory implementation.

Link copied to clipboard

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.

Link copied to clipboard

ViewEnvironment service object used by Screen.toViewFactory to find the right ScreenViewFactory to build and manage a View to display Screens of the type of the receiver. The default implementation makes AndroidScreen work, and provides default bindings for NamedScreen, EnvironmentScreen, BackStackScreen, etc.

Link copied to clipboard

Associates a view with a function (runner) that can update it to display instances of ScreenT. Also holds a reference to the ViewEnvironment that was most recently used to update the view.

Link copied to clipboard

The function that updates a View instance built by a ScreenViewFactory. Each ScreenViewRunner instance is paired with a single View instance, its neighbor in a ScreenViewHolder.

Link copied to clipboard

A wrapper for the function invoked when ScreenViewHolder.startShowing is called, allowing for custom initialization of a newly built View before or after the first call to ScreenViewHolder.show. Most typical use is to call WorkflowLifecycleOwner.installOn), at just the right moment.

Link copied to clipboard

A view that can be driven by a stream of Screen renderings passed to its take method.

Link copied to clipboard
class WorkflowViewStub @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defStyle: Int = 0, defStyleRes: Int = 0) : View

A placeholder View that can replace itself with ones driven by workflow renderings, similar to android.view.ViewStub.

Properties

Link copied to clipboard

Returns the most recent ViewEnvironment applied to this view, or null if the receiver was not initialized via ScreenViewHolder.startShowing.

Link copied to clipboard

Returns the most recent Screen rendering shown in this view, or throws a NullPointerException if the receiver was not created via ScreenViewFactory.startShowing.

Link copied to clipboard

Returns the most recent Screen rendering shown in this view, or null if the receiver was not initialized via ScreenViewHolder.startShowing.

Link copied to clipboard

Returns the Screen most recently used to update the receiver's view via a call to show.

Functions

Link copied to clipboard

Returns true if screen is compatible with the Screen instance that was last shown by the view managed by the receiver.

Link copied to clipboard

Call this from your view code's showRendering method. This method is idempotent: if it has already been called with a particular EditText, and the view has not been detached since the last call, it will do nothing. If a different TextController's control is called on the same EditText, the old one will be disconnected and the new one will replace it.

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 <OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<Unit, OutputT, RenderingT>, scope: CoroutineScope, savedStateHandle: SavedStateHandle? = null, interceptors: List<WorkflowInterceptor> = emptyList(), runtimeConfig: RuntimeConfig = RuntimeConfigOptions.DEFAULT_CONFIG, onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>

An Android ViewModel-friendly wrapper for com.squareup.workflow1.renderWorkflowIn, for use with a workflow that takes no input (that is, has PropsT set to Unit).

fun <PropsT, OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<PropsT, OutputT, RenderingT>, scope: CoroutineScope, prop: PropsT, savedStateHandle: SavedStateHandle? = null, interceptors: List<WorkflowInterceptor> = emptyList(), runtimeConfig: RuntimeConfig = RuntimeConfigOptions.DEFAULT_CONFIG, onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>

An Android ViewModel-friendly wrapper for com.squareup.workflow1.renderWorkflowIn, for use with a workflow that requires one input value (prop) to run.

fun <PropsT, OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<PropsT, OutputT, RenderingT>, scope: CoroutineScope, props: StateFlow<PropsT>, savedStateHandle: SavedStateHandle? = null, interceptors: List<WorkflowInterceptor> = emptyList(), runtimeConfig: RuntimeConfig = RuntimeConfigOptions.DEFAULT_CONFIG, onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>

An Android ViewModel-friendly wrapper for com.squareup.workflow1.renderWorkflowIn, for use with a workflow that requires input (props) to run.

Link copied to clipboard

Updates the view managed by the receiver to display screen, and updates the receiver's environment as well.

Link copied to clipboard
fun <ScreenT : Screen> ScreenViewHolder<ScreenT>.startShowing(initialRendering: ScreenT, initialEnvironment: ViewEnvironment, viewStarter: ViewStarter?)

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 and ScreenViewHolder machinery for you. See ScreenViewFactory for details.

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.

Link copied to clipboard
inline fun <T : Parcelable> Snapshot.toParcelable(): T?
inline fun <T : Parcelable> ByteString.toParcelable(): T
Link copied to clipboard

Wraps receiver in a Snapshot suitable for use with com.squareup.workflow1.StatefulWorkflow. Intended to allow use of @Parcelize.

Link copied to clipboard

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, ScreenViewHolder, and ScreenViewFactoryFinder machinery for you.