I want to draw a fake statusbar, so I use `drawBeh...
# compose
u
I want to draw a fake statusbar, so I use
drawBehind { .. .drawRect … }
but how do I get the height of statusbar? I see the
statusBarPadding
but that’s modifier. Is there a way to read the actual integer value?) I see the
Copy code
WindowInsets.statusBars.getBottom(LocalDensity.current)
but that requires a composable context, which
drawBehind { .. }
lambda is not // // // // //
SystemUiController
from accompanist doesn’t cut it, as I have a single activity app, and the screens are fragments for now, and there are “slide up” transition animations. If I were to set the color via transitively the window.setStatusBarColor, it would color the statusbar immediately on screen transition, and the rest of the screen would the “join” it TLDR; I want a custom, say
FakeStatusBarDrawingSurface
but I need inset heights to read
// // //
Copy code
@Composable
fun ScreenRoot(
    statusBarColor: Color = Color.Yellow,
    content: @Composable BoxScope.() -> Unit
) {
    val statusBarHeight = WindowInsets.statusBars.getTop(LocalDensity.current).toFloat()

    Box(
        modifier = Modifier
            .fillMaxSize()
            .drawBehind {
                drawRect(
                    color = statusBarColor,
                    size = Size(width = size.width, height = statusBarHeight)
                )
            }
    )
}
How does this look? Is it cool to calculate the
statusBarHeight
like that?