Skip to content

Commit

Permalink
Fix WheelPicker Manual Input (#1209)
Browse files Browse the repository at this point in the history
* Fix WheelPicker Manual Input

* Lambda

* inline

* Update WheelPicker.kt

---------

Co-authored-by: AntsyLich <[email protected]>
  • Loading branch information
Animeboynz and AntsyLich committed Sep 14, 2024
1 parent 223af55 commit 339dc33
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,25 @@ private fun <T> WheelPicker(
}

val scope = rememberCoroutineScope()
val processManualInput: () -> Unit = {
scope.launch {
items
.indexOfFirst { it.toString() == value.text }
.takeIf { it >= 0 }
?.apply {
internalOnSelectionChanged(this)
lazyListState.scrollToItem(this)
}
showManualInput = false
}
}

BasicTextField(
modifier = Modifier
.align(Alignment.Center)
.showSoftKeyboard(true)
.clearFocusOnSoftKeyboardHide {
scope.launch {
items
.indexOfFirst { it.toString() == value.text }
.takeIf { it >= 0 }
?.apply {
internalOnSelectionChanged(this)
lazyListState.scrollToItem(this)
}

showManualInput = false
}
},
.clearFocusOnSoftKeyboardHide(processManualInput),
onKeyboardAction = { processManualInput() },
state = value,
lineLimits = TextFieldLineLimits.SingleLine,
keyboardOptions = KeyboardOptions(
Expand Down

0 comments on commit 339dc33

Please sign in to comment.