Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Created October 29, 2024 10:22
Show Gist options
  • Save KatieBarnett/a708ad418930f630ce6733a2ed33d8f8 to your computer and use it in GitHub Desktop.
Save KatieBarnett/a708ad418930f630ce6733a2ed33d8f8 to your computer and use it in GitHub Desktop.
Initial fetch of current wallpaper color
@Composable
fun MotivateMeGlanceTheme(
context: Context,
content: @Composable (Boolean) -> Unit,
) {
val wallpaperManager = WallpaperManager.getInstance(context)
val colors = wallpaperManager.getWallpaperColors(FLAG_SYSTEM)
var useDarkColorOnWallpaper by remember {
mutableStateOf(
getUseDarkColorOnWallPaper(colors, FLAG_SYSTEM) ?: false
)
}
GlanceTheme(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
GlanceTheme.colors
} else {
MotivateMeGlanceColorScheme.colors
}
) {
content.invoke(useDarkColorOnWallpaper)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment