CombinedField
A field that combines multiple sub-fields into a single composite value.
CombinedField allows creating complex field types by combining simpler field types. For example, combining multiple number fields to create a coordinate field, or combining color and size fields to create a styled element field.
Usage
// Custom data class with multiple fields
data class Padding(val horizontal: Dp, val vertical: Dp)
@Preview
@Composable
fun CustomFieldPreview() = PreviewLab {
val padding: Padding = fieldValue {
CombinedField(
label = "Padding",
fields = listOf(
DpField("Horizontal", 16.dp),
DpField("Vertical", 8.dp)
),
combine = { values -> Padding(values[0] as Dp, values[1] as Dp) },
split = { listOf(it.horizontal, it.vertical) }
)
}
Box(
modifier = Modifier
.background(Color.LightGray)
.padding(horizontal = padding.horizontal, vertical = padding.vertical)
) {
Text("Content with custom padding")
}
}Parameters
The base type of the individual sub-fields
The composite value type created by combining the sub-fields
The display label for this combined field
The list of sub-fields to combine
Function to combine values from sub-fields into the composite value
Function to split a composite value back into individual sub-field values
Inheritors
Constructors
Functions
Composable, which displays the main UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI.
Default UI implementation of me.tbsten.compose.preview.lab.PreviewLabField.View. Display a label and draw the content below it.
Display the label of PreviewLabField.
Create a PreviewLabField that makes the receiver's PreviewLabField nullable.
Returns a KSerializer for this field's value type, or null if serialization is not supported.
Returns a list of representative values for this field to be used in automated testing.
Helper for UI of Fields that can be input with TextField.
Transforms a MutablePreviewLabField to work with a different value type.
Composable, which displays the entire UI for this Field. If you want to customize the UI, you can override this method in your PreviewLabField to customize the UI. However, in many cases where the UI is customized, overriding the content method is more appropriate.
Adds hint choices to a MutablePreviewLabField, allowing users to quickly select from predefined values.
Adds predefined color hints to a Color field for quick selection.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.serializer implementation.
Wraps this field with a custom me.tbsten.compose.preview.lab.PreviewLabField.valueCode implementation.
Wraps this field with additional composable content.