Last active
February 11, 2025 18:01
-
-
Save vitoksmile/b2dea34a7b106eeb5a5383e74f837dce to your computer and use it in GitHub Desktop.
ComposeHints
This file contains hidden or 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
| val LocalHintOverlayColor = staticCompositionLocalOf<Color> { Color(0x44000000) } | |
| val LocalHintOverlayBrush = staticCompositionLocalOf<Brush?> { null } | |
| @Composable | |
| fun HintOverlay() { | |
| Popup { | |
| Box( | |
| modifier = Modifier | |
| .fillMaxSize() | |
| .overlayBackground() | |
| ) { | |
| Text( | |
| modifier = Modifier.align(Alignment.Center), | |
| text = "Draw hints here", | |
| color = Color.White, | |
| ) | |
| } | |
| } | |
| } | |
| /** | |
| * Set `background` either from [LocalHintOverlayBrush] or from [LocalHintOverlayColor]. | |
| */ | |
| private fun Modifier.overlayBackground(): Modifier = composed { | |
| LocalHintOverlayBrush.current?.let { background(it) } | |
| ?: background(LocalHintOverlayColor.current) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment