CountryPickerUiField

class CountryPickerUiField(val initialValue: String, var label: LbcTextSpec?, var placeholder: LbcTextSpec?, val id: String, val savedStateHandle: SavedStateHandle, val isFieldInError: (String?) -> UiFieldError?, uiFieldStyleData: UiFieldStyleData = DefaultUiFieldStyleData(), val onValueChange: (String) -> Unit, val readOnly: Boolean = false, val enabled: Boolean = true, coroutineScope: CoroutineScope, countryPickerBottomSheetRenderer: CountryPickerBottomSheetRenderer, trailingIcon: @Composable () -> Unit? = null) : TextUiField<String>

A UiField implementation for selecting a country from a list presented in a bottom sheet.

This field displays the selected country's name. When the user focuses on the field, a bottom sheet appears, allowing them to search for and select a country. The field's value is the ISO 3166-1 alpha-2 country code (e.g., "US", "FR").

It uses the hbb20.CountryCodePicker-Android library for country data.

Parameters

initialValue

The initial ISO 3166-1 alpha-2 country code to be displayed.

label

The label for the text field, as a LbcTextSpec.

placeholder

The placeholder text to be displayed when the field is empty, as a LbcTextSpec.

id

A unique identifier for the field, used for state saving.

savedStateHandle

The SavedStateHandle used to persist the field's state across process death.

isFieldInError

A lambda function that determines if the current value is in an error state. It should return a UiFieldError if there is an error, or null otherwise.

uiFieldStyleData

The styling data for the text field, implementing UiFieldStyleData. Defaults to DefaultUiFieldStyleData.

onValueChange

A callback that is invoked when the selected country changes. The new value is the country's ISO code.

readOnly

A boolean indicating whether the field is read-only. If true, the user cannot change the value.

enabled

A boolean indicating whether the field is enabled. If false, the field is disabled and does not respond to user input.

coroutineScope

The CoroutineScope used for managing background operations, such as country search.

Constructors

Link copied to clipboard
constructor(initialValue: String, label: LbcTextSpec?, placeholder: LbcTextSpec?, id: String, savedStateHandle: SavedStateHandle, isFieldInError: (String?) -> UiFieldError?, uiFieldStyleData: UiFieldStyleData = DefaultUiFieldStyleData(), onValueChange: (String) -> Unit, readOnly: Boolean = false, enabled: Boolean = true, coroutineScope: CoroutineScope, countryPickerBottomSheetRenderer: CountryPickerBottomSheetRenderer, trailingIcon: @Composable () -> Unit? = null)

Properties

Link copied to clipboard
open override val enabled: Boolean
Link copied to clipboard
open override val id: String
Link copied to clipboard
open override val initialValue: String
Link copied to clipboard
open override val isFieldInError: (String?) -> UiFieldError?
Link copied to clipboard
val isInError: Flow<Boolean>
Link copied to clipboard
open override var label: LbcTextSpec?
Link copied to clipboard
open override val onValueChange: (String) -> Unit
Link copied to clipboard
open override val options: List<UiFieldOption>
Link copied to clipboard
open override var placeholder: LbcTextSpec?
Link copied to clipboard
open override val readOnly: Boolean
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open override fun Composable(modifier: Modifier, uiFieldStyleData: UiFieldStyleData)
override fun Composable(modifier: Modifier)
Link copied to clipboard
Link copied to clipboard
fun displayError(displayError: UiFieldError)
Link copied to clipboard
open override fun formToDisplay(value: String): TextFieldValue
Link copied to clipboard
open override fun restoreFromSavedStateHandle(savedStateHandle: SavedStateHandle): String?
Link copied to clipboard
open override fun saveToSavedStateHandle(value: String, savedStateHandle: SavedStateHandle)