-
-
Save nglauber/2898950a6a6f84b302502381f9580fa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity | |
import android.view.WindowManager | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.toArgb | |
import androidx.compose.ui.platform.LocalContext | |
@Composable | |
fun FullScreen( | |
color: Color, | |
isLightStatusBar: Boolean = !isSystemInDarkTheme(), | |
content: @Composable () -> Unit | |
) { | |
val context = LocalContext.current | |
if (context is Activity) { | |
context.window.run { | |
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) | |
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) | |
val wic = WindowInsetsControllerCompat(this, decorView) | |
wic.isAppearanceLightStatusBars = isLightStatusBar | |
statusBarColor = color.toArgb() | |
} | |
} | |
content() | |
} | |
@Composable | |
fun FullScreenTranslucent( | |
content: @Composable () -> Unit | |
) { | |
val context = LocalContext.current | |
if (context is Activity) { | |
context.window.run { | |
addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) | |
clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) | |
} | |
} | |
content() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment