val keyboardController = LocalSoftwareKeyboardController.current
val view = LocalView.current
val viewTreeObserver = view.viewTreeObserver
DisposableEffect(viewTreeObserver) {
val listener = ViewTreeObserver.OnGlobalLayoutListener {
val isKeyboardOpen = ViewCompat.getRootWindowInsets(view)
?.isVisible(WindowInsetsCompat.Type.ime()) ?: true
println("Rajuprint:isKeyboardOpen="+isKeyboardOpen)
if (!isKeyboardOpen) {
focusRequester.freeFocus()
}
}
viewTreeObserver.addOnGlobalLayoutListener(listener)
onDispose {
viewTreeObserver.removeOnGlobalLayoutListener(listener)
}
}