PreviewLabScope

The scope of the PreviewLab, which provides methods to create fields, handle events, and manage layout nodes.

See also

Constructors

Link copied to clipboard
constructor(state: PreviewLabState)

Types

Link copied to clipboard

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun <Value> PreviewLabScope.ChangeEvent(value: Value, title: (Value) -> String, description: (Value) -> String? = { null })
fun <Value> PreviewLabScope.ChangeEvent(value: Value, title: String, description: String? = null)

An effect that calls onEvent to record an event when a value changes. This is useful when you want to monitor a specific value in a Composable, such as a CompositionLocal value.

Link copied to clipboard

Creates a mutable field that can be used to store and observe state in the Preview Lab. Use fieldValue if you do not need to update the status. This is useful, for example, for a TextField, where you want to use both the state value and its updates. For example, use the following.

Link copied to clipboard

Creates a field that can be used to store and observe state in the Preview Lab. Use this if you do not need to update the status. Use when the change process does not need to be included in the Preview, for example, in the button text below.

Link copied to clipboard
fun onEvent(title: String, description: String? = null)

Records an event in the Preview Lab. When onEvent is called, Toast is displayed and the event is recorded on the Event tab in the right sidebar. This is useful for manual testing of events that may occur in components.

Link copied to clipboard

Provides default Compose composition local fields for PreviewLab.

Link copied to clipboard
fun PreviewLabScope.withEvent(title: String, description: String? = null, block: () -> Unit = {}): () -> Unit
fun <Arg1> PreviewLabScope.withEvent(title: String, description: String? = null, block: (Arg1) -> Unit = {}): (Arg1) -> Unit
fun <Arg1, Arg2> PreviewLabScope.withEvent(title: String, description: String? = null, block: (Arg1, Arg2) -> Unit): (Arg1, Arg2) -> Unit
fun <Arg1, Arg2, Arg3> PreviewLabScope.withEvent(title: String, description: String? = null, block: (Arg1, Arg2, Arg3) -> Unit): (Arg1, Arg2, Arg3) -> Unit

Create a function to record events. This is simply a short-hand for the onEvent call.