/*Change this value to "keyboard_on" when the keyboard is turned on and "keyboard_off" when the keyboard is closed again. You can give different names for different usage areas. That's why we're using a string, not a Boolean.*/
var taskCodeValue = remember { mutableStateOf("keyboard_off") }
var sheetOpener by remember { mutableStateOf(true) }
if (taskCodeValue.value == "keyboard_off"){
LaunchedEffect(taskCodeValue.value == "keyboard_off"){
delay(500)
sheetOpener = true
}
}else {
sheetOpener = false
}
/*
By adding the Scaffold, which includes ModalBottomSheet and other compose
elements, into a box, we enable them to work independently of each other.
*/
Box(modifier = Modifier.fillMaxSize()) {
Scaffold(
content = {}
)
if (sheetOpener){
ModalBottomSheetLayout(
sheetState = sheetState,
sheetContent = {}
) {}
}
}
2条答案
按热度按时间58wvjzkj1#
我的同事,所以他插入了一个布尔值,检查键盘是否打开,如果是,不要把ap模态底层。
pes8fvy92#
您可以使用此方法,直到通过其他更新修复此问题。
你可以使用LaunchedEffect来实现这个功能。下面是一个例子。
此处重要的是在键盘打开时禁用ModalBottomSheetDialog,并在键盘关闭半秒后重新启用它。
您可以在键盘打开时为此变量赋值,然后在键盘关闭时更改并检查此值,从而触发所需的函数。