NumberField
Abstract class of Field that handles numeric types.
Usage
// Basic text field input
@Preview
@Composable
fun BasicNumberPreview() = PreviewLab {
val count: Int = fieldValue {
IntField("Count", 0)
}
Counter(count = count)
}
// With prefix and suffix for units
@Preview
@Composable
fun PricePreview() = PreviewLab {
val price: Double = fieldValue {
DoubleField(
label = "Price",
initialValue = 99.99,
inputType = NumberField.InputType.TextField(
prefix = { Text("$") },
suffix = { Text("USD") }
)
)
}
PriceDisplay(price = price)
}
// Multiple number fields for complex inputs
@Preview
@Composable
fun DimensionsPreview() = PreviewLab {
val width: Int = fieldValue { IntField("Width", 100) }
val height: Int = fieldValue { IntField("Height", 200) }
Rectangle(width = width, height = height)
}Parameters
label of the field.
initial value of the field.
Function to convert a string to the numeric type of this Field.
Function to convert the numeric type of this Field to a string.
InputType, specifies how values are made available for input in the UI. See InputType.
See also
Inheritors
Types
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.