feat: Implement keyboard dismissal on ChatsListScreen to enhance user experience
This commit is contained in:
@@ -152,13 +152,27 @@ fun ChatsListScreen(
|
||||
|
||||
val view = androidx.compose.ui.platform.LocalView.current
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val focusManager = androidx.compose.ui.platform.LocalFocusManager.current
|
||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// 🔥 ВСЕГДА закрываем клавиатуру при появлении ChatsListScreen
|
||||
LaunchedEffect(Unit) {
|
||||
// Используем DisposableEffect чтобы срабатывало при каждом появлении экрана
|
||||
DisposableEffect(Unit) {
|
||||
// Закрываем клавиатуру сразу
|
||||
val imm = context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as android.view.inputmethod.InputMethodManager
|
||||
imm.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
focusManager.clearFocus()
|
||||
|
||||
onDispose { }
|
||||
}
|
||||
|
||||
// Дополнительно закрываем клавиатуру с небольшой задержкой (на случай если она появляется после)
|
||||
LaunchedEffect(Unit) {
|
||||
kotlinx.coroutines.delay(100)
|
||||
val imm = context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as android.view.inputmethod.InputMethodManager
|
||||
imm.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
focusManager.clearFocus()
|
||||
}
|
||||
|
||||
// Update status bar and completely hide navigation bar
|
||||
|
||||
Reference in New Issue
Block a user