Skip to content

//workflow/com.squareup.workflow1.ui

Package com.squareup.workflow1.ui

Types

Name Summary
AndroidScreen [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface AndroidScreen<S : AndroidScreen<S>> : Screen
More info
Interface implemented by a rendering class to allow it to drive an Android UI via an appropriate ScreenViewFactory implementation.


AndroidViewRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface AndroidViewRendering<V : AndroidViewRendering<V>>
More info
This will be deprecated in favor of AndroidScreen very soon.


AsScreen [jvm]
Content
@WorkflowUiExperimentalApi()

class AsScreen<W : Any>(rendering: W) : Screen, Compatible
More info
Provides backward compatibility for legacy non-Screen renderings.


BackButtonScreen [androidJvm]
Content
@WorkflowUiExperimentalApi()

class BackButtonScreen<W : Any>(wrapped: W, shadow: Boolean, onBackPressed: () -> Unit?) : AndroidViewRendering<BackButtonScreen<>>
More info
**This will be deprecated in favor of*
com.squareup.workflow1.ui.container.BackButtonScreen very soon.


BackPressHandler [androidJvm]
Content
@WorkflowUiExperimentalApi()

typealias BackPressHandler = () -> Unit
More info


A function passed to View.backPressedHandler, to be called if the back button is pressed while that view is attached to a window.




BuilderViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

class BuilderViewFactory<RenderingT : Any>(type: KClass<RenderingT>, viewConstructor: (RenderingT, initialViewEnvironment: ViewEnvironment, contextForNewView: Context, container: ViewGroup?) -> View) : ViewFactory<RenderingT>
More info
This will be deprecated in favor of ScreenViewFactory.fromCode very soon.


Compatible [jvm]
Content
@WorkflowUiExperimentalApi()

interface Compatible
More info
Implemented by objects whose compatibility requires more nuance than just being of the same type.


DecorativeViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

class DecorativeViewFactory<OuterT : Any, InnerT : Any>(type: KClass<OuterT>, map: (OuterT, ViewEnvironment) -> Pair<InnerT, ViewEnvironment>, viewStarter: ViewStarter?, doShowRendering: (view: View, ViewShowRendering<InnerT>, OuterT, env: ViewEnvironment) -> Unit) : ViewFactory<OuterT>
More info
This will be deprecated in favor of ScreenViewFactory.toUnwrappingViewFactory very soon.


LayoutRunner [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun fun interface LayoutRunner<RenderingT : Any>
More info
This will be deprecated in favor of ScreenViewRunner very soon.


Named [jvm]
Content
@WorkflowUiExperimentalApi()

data class Named<W : Any>(wrapped: W, name: String) : Compatible
More info
This will be deprecated in favor of NamedScreen very soon.


NamedScreen [jvm]
Content
@WorkflowUiExperimentalApi()

data class NamedScreen<W : Screen>(wrapped: W, name: String) : Screen, Compatible
More info
Allows Screen renderings that do not implement Compatible themselves to be distinguished by more than just their type.


ParcelableTextController [androidJvm]
Content
@WorkflowUiExperimentalApi()

class ParcelableTextController : TextController, Parcelable
More info
Parcelable implementation of TextController.


Screen [jvm]
Content
@WorkflowUiExperimentalApi()

interface Screen
More info
Marker interface implemented by renderings that map to a UI system’s 2d view class.


ScreenViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface ScreenViewFactoryScreenT : Screen> : ViewRegistry.Entry<ScreenT>
More info
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.


ScreenViewFactoryFinder [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface ScreenViewFactoryFinder
More info
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.


ScreenViewHolder [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface ScreenViewHolderScreenT : Screen>
More info
Associates a view with a function (runner) that can update it to display instances of ScreenT.


ScreenViewRunner [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun fun interface ScreenViewRunnerScreenT : Screen>
More info
The function that updates a View instance built by a ScreenViewFactory.


TextController [jvm]
Content
@WorkflowUiExperimentalApi()

interface TextController
More info
Helper class for keeping a workflow in sync with editable text in a UI, without interfering with the user’s typing.


ViewBindingInflater [androidJvm]
Content
@WorkflowUiExperimentalApi()

typealias ViewBindingInflater<BindingT> = (LayoutInflater, ViewGroup?, Boolean) -> BindingT


ViewEnvironment [jvm]
Content
@WorkflowUiExperimentalApi()

class ViewEnvironment
More info
Immutable map of values that a parent view can pass down to its children.


ViewEnvironmentKey [jvm]
Content
@WorkflowUiExperimentalApi()

abstract class ViewEnvironmentKey<T : Any>(type: KClass<T>)
More info
Defines a value that can be provided by a ViewEnvironment map, specifying its type and default value.


ViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

interface ViewFactoryRenderingT : Any> : ViewRegistry.Entry<RenderingT>
More info
This will be deprecated in favor of ScreenViewFactory very soon.


ViewRegistry [jvm]
Content
@WorkflowUiExperimentalApi()

interface ViewRegistry
More info
The ViewEnvironment service that can be used to display the stream of renderings from a workflow tree as View instances.


ViewShowRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

typealias ViewShowRendering<RenderingT> = (@UnsafeVariance()RenderingT, ViewEnvironment) -> Unit
More info


Function attached to a view created by ViewFactory, to allow it to respond to View.showRendering.




ViewStarter [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun fun interface ViewStarter
More info
A wrapper for the function invoked when ScreenViewFactory.startShowing is called, allowing for custom initialization of a newly built View before or after the first call to ScreenViewHolder.show.


WorkflowLayout [androidJvm]
Content
@WorkflowUiExperimentalApi()

class WorkflowLayout(context: Context, attributeSet: AttributeSet?) : FrameLayout
More info
A view that can be driven by a stream of Screen renderings passed to its take method.


WorkflowUiExperimentalApi [jvm]
Content
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS])

annotation class WorkflowUiExperimentalApi
More info
Marks Workflow user interface APIs which are still in flux.


WorkflowViewStub [androidJvm]
Content
@WorkflowUiExperimentalApi()

class WorkflowViewStub@JvmOverloads()constructor(context: Context, attributeSet: AttributeSet?, defStyle: Int, defStyleRes: Int) : View
More info
A placeholder View that can replace itself with ones driven by workflow renderings, similar to android.view.ViewStub.


Functions

Name Summary
asScreen [jvm]
Content
@WorkflowUiExperimentalApi()

fun asScreen(rendering: Any): Screen
More info
Ensures rendering implements Screen, wrapping it in an AsScreen if necessary.


bindShowRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> View.bindShowRendering(initialRendering: RenderingT, initialViewEnvironment: ViewEnvironment, showRendering: ViewShowRendering<RenderingT>)
More info
This will be deprecated in favor of ScreenViewHolder very soon.


buildView [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> ViewRegistry.buildView(initialRendering: RenderingT, initialViewEnvironment: ViewEnvironment, contextForNewView: Context, container: ViewGroup? = null, viewStarter: ViewStarter? = null): View
More info
This will be deprecated in favor of ScreenViewFactory.startShowing very soon.


canShow [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun ScreenViewHolder<*>.canShow(screen: Screen): Boolean
More info
Returns true if screen is compatible with the Screen instance that was last shown by the view managed by the receiver.


canShowRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun View.canShowRendering(rendering: Any): Boolean
More info
This will be deprecated in favor of ScreenViewHolder.canShow very soon.


compatible [jvm]
Content
@WorkflowUiExperimentalApi()

fun compatible(me: Any, you: Any): Boolean
More info
Normally returns true if me and you are instances of the same class.


control [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun TextController.control(view: EditText)
More info
Call this from your view code’s showRendering method.


get [jvm]
Content
@WorkflowUiExperimentalApi()

inline operator fun <RenderingT : Any> ViewRegistry.get(renderingType: KClassRenderingT>): ViewRegistry.Entry<RenderingT>?


getFactoryFor [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> ViewRegistry.getFactoryFor(renderingType: KClassRenderingT>): ViewFactory<RenderingT>?
More info
This will be deprecated in favor of ViewRegistry.getEntryFor very soon.


getFactoryForRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> ViewRegistry.getFactoryForRendering(rendering: RenderingT): ViewFactory<RenderingT>
More info
This will be deprecated in favor of ScreenViewFactoryFinder.getViewFactoryForRendering very soon.


getRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

inline fun <RenderingT : Any> View.getRendering(): RenderingT?
More info
This will be deprecated in favor of screenOrNull very soon.


getShowRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> View.getShowRendering(): ViewShowRendering<RenderingT>?
More info
This will be deprecated in favor of ScreenViewHolder very soon.


merge [jvm]
Content
@WorkflowUiExperimentalApi()

infix fun ViewRegistry.merge(other: ViewRegistry): ViewRegistry
More info
Combines the receiver with other.


onBackPressedDispatcherOwnerOrNull [androidJvm]
Content
@WorkflowUiExperimentalApi()

tailrec fun Context.onBackPressedDispatcherOwnerOrNull(): OnBackPressedDispatcherOwner?


plus [jvm]
Content
@WorkflowUiExperimentalApi()

operator fun ViewEnvironment.plus(registry: ViewRegistry): ViewEnvironment


[jvm]
Content
@WorkflowUiExperimentalApi()

operator fun ViewRegistry.plus(entry: ViewRegistry.Entry<*>): ViewRegistry
More info
Transforms the receiver to add entry, throwing IllegalArgumentException if the receiver already has a matching entry.


[jvm]
Content
@WorkflowUiExperimentalApi()

operator fun ViewRegistry.plus(other: ViewRegistry): ViewRegistry
More info
Transforms the receiver to add all entries from other, throwing IllegalArgumentException if the receiver already has any matching entry.


renderWorkflowIn [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<Unit, OutputT, RenderingT>, scope: CoroutineScope, savedStateHandle: SavedStateHandle? = null, interceptors: List = emptyList(), onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>
@WorkflowUiExperimentalApi()

fun <PropsT, OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<PropsT, OutputT, RenderingT>, scope: CoroutineScope, prop: PropsT, savedStateHandle: SavedStateHandle? = null, interceptors: List = emptyList(), onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>
@WorkflowUiExperimentalApi()

fun <PropsT, OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<PropsT, OutputT, RenderingT>, scope: CoroutineScope, props: StateFlow<PropsT>, savedStateHandle: SavedStateHandle? = null, interceptors: List = emptyList(), onOutput: suspend (OutputT) -> Unit = {}): StateFlow<RenderingT>
More info
An Android ViewModel-friendly wrapper for com.squareup.workflow1.


ScreenViewHolder [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <ScreenT : Screen> ScreenViewHolder(initialEnvironment: ViewEnvironment, view: View, viewRunner: ScreenViewRunner<ScreenT>): ScreenViewHolder<ScreenT>


show [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <ScreenT : Screen> ScreenViewHolder<ScreenT>.show(screen: ScreenT, environment: ViewEnvironment)
More info
Updates the view managed by the receiver to display screen, and updates the receiver’s environment as well.


showRendering [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <RenderingT : Any> View.showRendering(rendering: RenderingT, viewEnvironment: ViewEnvironment)
More info
This will be deprecated in favor of ScreenViewHolder.show very soon.


start [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun View.start()
More info
This will be deprecated in favor of ScreenViewFactory.startShowing very soon.


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.


TextController [jvm]
Content
@WorkflowUiExperimentalApi()

fun TextController(initialValue: String = “”): TextController
More info
Create instance for default implementation of TextController.


toParcelable [androidJvm]
Content
inline fun <T : Parcelable> Snapshot.toParcelable(): T?
inline fun <T : Parcelable> ByteString.toParcelable(): T


toSnapshot [androidJvm]
Content
fun Parcelable.toSnapshot(): Snapshot
More info
Wraps receiver in a Snapshot suitable for use with com.squareup.workflow1.StatefulWorkflow.


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.


toViewFactory [androidJvm]
Content
@WorkflowUiExperimentalApi()

fun <ScreenT : Screen> ScreenT.toViewFactory(environment: ViewEnvironment): ScreenViewFactory<ScreenT>
More info
It is rare to call this method directly.


ViewRegistry [jvm]
Content
@WorkflowUiExperimentalApi()

fun ViewRegistry(): ViewRegistry
More info
Returns a ViewRegistry that contains no bindings.


[jvm]
Content
@WorkflowUiExperimentalApi()

fun ViewRegistry(vararg bindings: ViewRegistry.Entry<*>): ViewRegistry


Properties

Name Summary
backPressedHandler [androidJvm] @WorkflowUiExperimentalApi()

var View.backPressedHandler: BackPressHandler?A function to be called if the device back button is pressed while this view is attached to a window.
environmentOrNull [androidJvm] @WorkflowUiExperimentalApi()

val View.environmentOrNull: ViewEnvironment?Returns the most recent ViewEnvironment applied to this view, or null if bindShowRendering has never been called.
screenOrNull [androidJvm] @WorkflowUiExperimentalApi()

val View.screenOrNull: Screen?Returns the most recent Screen rendering shown in this view, or null if the receiver was not created via ScreenViewFactory.startShowing.
showing [androidJvm] @WorkflowUiExperimentalApi()

val ScreenViewHolder<*>.showing: ScreenReturns the Screen most recently used to update the receiver’s view via a call to show.