
Safe-area and window-inset utilities for Compose, offering rememberWindowInsetsController, WindowInsetsController APIs, a WindowInsets UIViewController wrapper, navigation/status bar padding modifiers, and runtime visibility control.

implementation("eu.codlab:kotlin-safearea:$version")This will work on the following platforms :
Note : mingw(), linuxX64(), linuxArm64() are not compatible right now as Kotlin Multiplatform is not yet compatible.
Note : the library was originally made for giving access to various WindowInsets extensions
and Modifier.navigationBarsPadding() and Modifier.statusBarsPadding()
Since they are now available, it can now be used directly via the foundation library.
The WindowInsetsController can be made available via the Compose compatible rememberWindowInsetsController() method
@Composable
fun rememberWindowInsetsController(): WindowInsetsController?iOS
Only for this platform, the root compose needs to use WindowInsetsUIViewController giving the following :
fun MainViewController() = WindowInsetsUIViewController {
val isSystemDarkTheme = isSystemInDarkTheme()
App(
isDarkTheme = isSystemDarkTheme
)
}Example
@Composable
fun WindowsInsetsView() {
val controller = rememberWindowInsetsController()
LaunchedEffect(controller) {
controller?.setIsStatusBarsVisible(false)
}
Column(
modifier = Modifier
.navigationBarsPadding()
.statusBarsPadding()
) {
// some views
}
}
implementation("eu.codlab:kotlin-safearea:$version")This will work on the following platforms :
Note : mingw(), linuxX64(), linuxArm64() are not compatible right now as Kotlin Multiplatform is not yet compatible.
Note : the library was originally made for giving access to various WindowInsets extensions
and Modifier.navigationBarsPadding() and Modifier.statusBarsPadding()
Since they are now available, it can now be used directly via the foundation library.
The WindowInsetsController can be made available via the Compose compatible rememberWindowInsetsController() method
@Composable
fun rememberWindowInsetsController(): WindowInsetsController?iOS
Only for this platform, the root compose needs to use WindowInsetsUIViewController giving the following :
fun MainViewController() = WindowInsetsUIViewController {
val isSystemDarkTheme = isSystemInDarkTheme()
App(
isDarkTheme = isSystemDarkTheme
)
}Example
@Composable
fun WindowsInsetsView() {
val controller = rememberWindowInsetsController()
LaunchedEffect(controller) {
controller?.setIsStatusBarsVisible(false)
}
Column(
modifier = Modifier
.navigationBarsPadding()
.statusBarsPadding()
) {
// some views
}
}