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:
parent
ba43e5584c
commit
7e4c3fbe2b
1 changed files with 3 additions and 4 deletions
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue