Dennis
03/15/2024, 2:39 PMtylerwilson
03/15/2024, 2:46 PMtylerwilson
03/15/2024, 2:47 PMDennis
03/15/2024, 2:48 PMStan van der Bend
09/23/2025, 1:09 AM1.10.0+dev2969
you can set the inputAccessoryView:
@OptIn(ExperimentalComposeUiApi::class)
actual fun numericPlatformImeOptions(onIosDone: () -> Unit): PlatformImeOptions? {
return PlatformImeOptions {
inputAccessoryView(
value = DoneToolBar(onIosDone)
)
}
}
@OptIn(ExperimentalForeignApi::class)
private class DoneToolBar(
val action: () -> Unit
) : UIToolbar(frame = CGRectZero.readValue()) {
init {
translatesAutoresizingMaskIntoConstraints = false
sizeToFit()
val flexSpace = UIBarButtonItem(
barButtonSystemItem = UIBarButtonSystemItem.UIBarButtonSystemItemFlexibleSpace,
target = null,
action = null
)
val done = UIBarButtonItem(
title = "Done",
style = UIBarButtonItemStyle.UIBarButtonItemStyleDone,
target = this,
action = NSSelectorFromString(::handleTap.name)
)
setItems(listOf(flexSpace, done), animated = false)
}
@OptIn(BetaInteropApi::class)
@ObjCAction
fun handleTap() = action()
}
in keyboardOptions:
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Decimal,
imeAction = ImeAction.Done,
platformImeOptions = numericPlatformImeOptions(
onIosDone = {
focusManager.clearFocus()
submit(input)
}
)
),