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