//workflow/com.squareup.workflow1.ui/TextController
TextController¶
[jvm] @WorkflowUiExperimentalApi()
interface TextController
Helper class for keeping a workflow in sync with editable text in a UI, without interfering with the user’s typing.
Usage¶
- For every editable string in your state, create a property of type [TextController](index.md). data class State(val text: TextController = TextController())
- Create a matching property in your rendering type. data class Rendering(val text: TextController)
- In your render method, copy each [TextController](index.md) from your state to your rendering: return Rendering(state.text)
- In your view code's showRendering method, call the appropriate extension function for your UI platform, e.g.:
- control() for an Android EditText viiew
- asMutableState() from an Android @Composable function
If your workflow needs to access or change the current text value, get the value from textValue. If your workflow needs to react to changes, it can observe onTextChanged by converting it to a worker.
Properties¶
Name | Summary |
---|---|
onTextChanged | [jvm] abstract val onTextChanged: Flow<String>A Flow that emits the text value whenever it changes – and only when it changes, the current value is not provided at subscription time. |
textValue | [jvm] abstract var textValue: StringThe current text value. |
Inheritors¶
Name |
---|
ParcelableTextController |
Extensions¶
Name | Summary |
---|---|
asMutableState | [androidJvm] Content @Composable() fun TextController.asMutableState(): MutableState<String> More info Exposes the textValue of a TextController as a remembered MutableState, suitable for use from @Composable functions. |
control | [androidJvm] Content @WorkflowUiExperimentalApi() fun TextController.control(view: EditText) More info Call this from your view code’s showRendering method. |