[Kotlin] Compose system bar 설정 (with. AppBar)
@Composable
fun BarColorsTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
// ...
/*
DarkTheme 인지 아닌지로 colors 객체 결정 로직
*/
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colors.primary.toArgb() //시스템바 색상 변경
window.navigationBarColor = colors.primary.toArgb() //시스템 내비게이션바 색상
WindowCompat.getInsetsController(window, view)
.isAppearanceLightStatusBars = darkTheme
WindowCompat.getInsetsController(window, view)
.isAppearanceLightNavigationBars = darkTheme
}
}
// ...
}