Fix WheelPicker Manual Input (#1209)

* Fix WheelPicker Manual Input

* Lambda

* inline

* Update WheelPicker.kt

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Roshan Varughese 2024-09-15 02:43:03 +12:00 committed by GitHub
parent 223af5508f
commit 339dc33f58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,23 +149,25 @@ private fun <T> WheelPicker(
} }
val scope = rememberCoroutineScope() 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( BasicTextField(
modifier = Modifier modifier = Modifier
.align(Alignment.Center) .align(Alignment.Center)
.showSoftKeyboard(true) .showSoftKeyboard(true)
.clearFocusOnSoftKeyboardHide { .clearFocusOnSoftKeyboardHide(processManualInput),
scope.launch { onKeyboardAction = { processManualInput() },
items
.indexOfFirst { it.toString() == value.text }
.takeIf { it >= 0 }
?.apply {
internalOnSelectionChanged(this)
lazyListState.scrollToItem(this)
}
showManualInput = false
}
},
state = value, state = value,
lineLimits = TextFieldLineLimits.SingleLine, lineLimits = TextFieldLineLimits.SingleLine,
keyboardOptions = KeyboardOptions( keyboardOptions = KeyboardOptions(