Kotlin Safe Area



Integration
implementation("eu.codlab:kotlin-safearea:$version")
This will work on the following platforms :
- Mobile (Android/iOS)
- Web (js)
- JVM (MacOS/Linux/Windows)
Note : mingw(), linuxX64(), linuxArm64() are not compatible right now as Kotlin Multiplatform is not yet compatible.
Usage
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()
) {
}
}