//workflow/com.squareup.workflow1.ui.compose/ComposeRendering
ComposeRendering¶
[androidJvm] @WorkflowUiExperimentalApi()
interface ComposeRendering : AndroidViewRendering<Nothing>
Interface implemented by a rendering class to allow it to drive a composable UI via an appropriate ComposeViewFactory implementation, by simply overriding the Content method. This is the compose analog to AndroidViewRendering.
Note that unlike most workflow view functions, Content does not take the rendering as a parameter. Instead, the rendering is the receiver, i.e. the current value of this.
Example:
@OptIn(WorkflowUiExperimentalApi::class)
data class HelloView(
val message: String,
val onClick: () -> Unit
) : ComposeRendering {
@Composable override fun Content(viewEnvironment: ViewEnvironment) {
Button(onClick) {
Text(message)
}
}
}
This is the simplest way to bridge the gap between your workflows and the UI, but using it requires your workflows code to reside in Android modules, instead of pure Kotlin. If this is a problem, or you need more flexibility for any other reason, you can use ViewRegistry to bind your renderings to ComposeViewFactory implementations at runtime.
Functions¶
Name | Summary |
---|---|
Content | [androidJvm] Content @Composable() abstract fun Content(viewEnvironment: ViewEnvironment) More info The composable content of this rendering. |
Properties¶
Name | Summary |
---|---|
viewFactory | [androidJvm] open override val viewFactory: ViewFactory<Nothing>Don’t override this, override Content instead. |