Fix WheelPicker Manual Input (mihonapp/mihon#1209)

* Fix WheelPicker Manual Input

* Lambda

* inline

* Update WheelPicker.kt

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit 339dc33f5833b224c01577da3da081deecdbbca2)
This commit is contained in:
Roshan Varughese 2024-09-15 02:43:03 +12:00 committed by Cuong-Tran
parent ba43e5584c
commit 7e4c3fbe2b
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -149,7 +149,7 @@ private fun <T> WheelPicker(
}
val scope = rememberCoroutineScope()
fun onDone() {
val processManualInput: () -> Unit = {
scope.launch {
items
.indexOfFirst { it.toString() == value.text }
@ -158,7 +158,6 @@ private fun <T> WheelPicker(
internalOnSelectionChanged(this)
lazyListState.scrollToItem(this)
}
showManualInput = false
}
}
@ -167,10 +166,10 @@ private fun <T> WheelPicker(
.align(Alignment.Center)
.showSoftKeyboard(true)
// KMK -->
.clearFocusOnSoftKeyboardHide { onDone() },
.clearFocusOnSoftKeyboardHide(processManualInput),
/* clearFocusOnSoftKeyboardHide doesn't work because onSoftKeyboardHide won't trigger
a recomposition => use keyboardActions instead */
onKeyboardAction = { onDone() },
onKeyboardAction = { processManualInput() },
// KMK <--
state = value,
lineLimits = TextFieldLineLimits.SingleLine,