Anmol Verma
05/04/2023, 3:32 PM@Composable
actual fun TextField(
modifier: Modifier,
text: String,
placeholder: String?,
onTextChange: (String) -> Unit
) {
UIKitView(
modifier = modifier,
factory = {
val label = UITextField()
label.setPlaceholder(placeholder)
label.setText(text)
label
}, onResize = { view: UIView, rect: CValue<CGRect> ->
CATransaction.begin()
CATransaction.setValue(true, kCATransactionDisableActions)
view.layer.setFrame(rect)
CATransaction.commit()
}, update = {
onTextChange(it.text() ?: "")
})
}
Alexander Zhirkevich
05/04/2023, 8:57 PMDima Avdeev
05/05/2023, 6:11 AMShivam Kanodia
05/05/2023, 9:42 AMAnmol Verma
05/05/2023, 9:59 AM<https://github.com/JetBrains/compose-multiplatform-core/blob/f9dfd04e830b08d6e81463daa78551b0b8c28e96/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/ComposeUITextField.uikit.kt#L19|ComposeUITextField>
in iosMain sources @Shivam KanodiaAnimasahun Ibrahim
05/05/2023, 9:00 PM@Composable
expect fun PlatformTextField(value: String, onValueChange: (String) -> Unit, modifier: Modifier)
iOS
@Composable
actual fun PlatformTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier,
) = ComposeUITextField(value, onValueChange, modifier)
Android
@Composable
actual fun PlatformTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier,
) = TextField(value, onValueChange, modifier)