JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
14.85k stars 1.08k forks source link

Ignore safe area below bottom bar #4727

Closed slikasgiedrius closed 2 weeks ago

slikasgiedrius commented 2 weeks ago

Describe the bug I am looking for an advice how to remove safe area on ios below the bottom bar (removing top would be beneficial also). Thank you

Affected platforms

Screenshots Screenshot 2024-04-29 at 16 09 07

Code:

@Composable
fun BottomNavigationExample() {
    val screens = listOf("Home", "Feed", "Alert", "Jobs")
    var selectedScreen by remember { mutableStateOf(screens.first()) }

    Scaffold(
        bottomBar = {
            BottomNavigation {
                screens.forEach { screen ->
                    BottomNavigationItem(
                        icon = { Icon(getIconForScreen(screen), contentDescription = screen) },
                        label = { Text(screen) },
                        selected = screen == selectedScreen,
                        onClick = { selectedScreen = screen },
                        modifier = Modifier.padding(0.dp)
                    )
                }
            }
        },
        content = {
            Column(
                modifier = Modifier.fillMaxSize(),
                verticalArrangement = Arrangement.Center,
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Text(text = "Selected Screen: $selectedScreen")
            }

        }
    )
}

@Composable
fun getIconForScreen(screen: String): ImageVector {
    return when (screen) {
        "Home" -> Icons.Default.Home
        "Feed" -> Icons.Default.AccountBox
        "Alert" -> Icons.Default.Notifications
        "Jobs" -> Icons.Default.Done
        else -> Icons.Default.Home
    }
}
igordmn commented 2 weeks ago

You should add ignoresSafeArea to the root container. Example

slikasgiedrius commented 2 weeks ago

Is it possible to achieve this inside multiplatform code? I am trying to stay away from platform-based changes as much as possible

igordmn commented 2 weeks ago

No, root containers are platform-specific.