KwikSearchView

fun KwikSearchView(modifier: Modifier = Modifier, state: MutableState<TextFieldValue>, placeholder: String = "Search", label: String? = null, delay: Boolean = false, delayDuration: Long = 500, maxChars: Int = 30, isError: Boolean = false, error: String? = null, textStyle: TextStyle = MaterialTheme.typography.bodyMedium, onTextChange: (String) -> Unit, onTextCleared: () -> Unit = {}, onFocusChanged: (Boolean) -> Unit = {}, onKeyboardDone: () -> Unit = {}, suggestionsModifier: Modifier = Modifier, onSuggestionSelected: (String) -> Unit = {}, suggestions: List<String> = listOf(), suggestionsContainerColor: Color = kwikFilledColorResolver(), colors: TextFieldColors = kwikTextFieldColors().copy( focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent ), shape: Shape = MaterialTheme.shapes.medium)

A search view that allows users to search for items.

Parameters

modifier

Modifier to be applied to the view.

state

The state of the search view.

placeholder

The placeholder text to be displayed.

delay

Whether to delay the search or not. Useful for debouncing.

delayDuration

The duration of the delay in milliseconds.

maxChars

The maximum number of characters allowed in the search field.

isError

Whether the search field has an error or not.

error

The error message to be displayed.

onTextChange

The callback to be called when the text changes.

onTextCleared

The callback to be called when the text is cleared.

onFocusChanged

The callback to be called when the focus changes.

onKeyboardDone

The callback to be called when the keyboard is done.

suggestionsModifier

Modifier to be applied to the suggestions view.

onSuggestionSelected

The callback to be called when a suggestion is selected.

suggestions

The list of suggestions to be displayed.

suggestionsContainerColor

The color of the suggestions container.

colors

The colors to be used for the text field.

Example usage:

 KwikSearchView(
state = searchQueryState,
onTextChange = {
// handle text change
},
onFocusChanged = { isFocused ->
// handle focus change
},
onKeyboardDone = {
// validate search query and perform search
},
onSuggestionSelected = { suggestion ->
// handle suggestion selection
}
)

This component is a custom search view that allows users to enter a search query and provides suggestions based on the input. It also handles focus changes, keyboard actions, and error states.

 KwikSearchView(
state = searchQueryState,
suggestions = listOf("Tortuga", "Isla de Muerta", "Shipwreck Cove", "Davy Jones' Locker"),
onTextChange = {
// handle text change
},
onKeyboardDone = {
// validate search query and perform search
},
onSuggestionSelected = { suggestion ->
// handle suggestion selection
}
)