ursus
12/27/2022, 8:48 PMdrawBehind { .. .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
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
//
//
//
@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?