Skip to content

Instantly share code, notes, and snippets.

@alexstyl
Last active May 5, 2022 07:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexstyl/2245e6138b531fe061d00b92dd6162cb to your computer and use it in GitHub Desktop.
Save alexstyl/2245e6138b531fe061d00b92dd6162cb to your computer and use it in GitHub Desktop.
A Composable that will keep push its content so that they are not drawn behind the system bars. This is useful for when you want to work on a layout without having to worry about insets.
@Composable
fun SafeContent(
systemBarsColor: Color = Color(0xFF082A3A),
content: @Composable () -> Unit
) {
Box(
modifier = Modifier
.background(systemBarsColor)
.systemBarsPadding()
.background(MaterialTheme.colors.background)
.fillMaxSize()
) {
content()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment