I am using a dialog
composable within a NavHost
from NavGraphBuilder 2.8.4.
I have a demo project setup to pinpoint a issue within a larger project but it seems either decorFitsSystemWindows
doesn't account for the insets from the keyboard in multi-window mode or that I am missing something else. The padding adjusts correctly otherwise when not in multi-window mode. I also have android:windowSoftInputMode="adjustPan"
set in my app's manifest.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
MyScreen()
}
}
}
@Composable
fun MyScreen() {
val navController = rememberNavController()
MyElevatedPopupSurface {
NavHost(navController = navController, startDestination = "main") {
composable(route = "main"){
Button(onClick = { navController.navigate("list-view") {
launchSingleTop = true
} }) {
Text("List of inputs")
}
}
dialog(
route = "list-view",
dialogProperties = DialogProperties(
usePlatformDefaultWidth = false,
decorFitsSystemWindows = false
)
){
Column(modifier = Modifier
.verticalScroll(state = rememberScrollState(), reverseScrolling = true)
.imePadding()
) {
for (index in 0 until 20) {
TextField(
value = "",
onValueChange = { /* Handle text input */ },
label = { Text("Input ${index + 1}") },
modifier = Modifier.fillMaxWidth()
)
}
}
}
}
}
}
@Composable
fun MyElevatedPopupSurface(
modifier: Modifier = Modifier,
content: @Composable () -> Unit
)
{
Box(
modifier = modifier.then(
Modifier
.padding(8.dp)
.clickable {}, // intercept click events
)
) {
PopupSurface(
elevation = 4.dp
) {
content()
}
}
}