Last active
December 28, 2023 21:12
-
-
Save m4kvn/b3993e9f2a4539ed3c391a93956abfd1 to your computer and use it in GitHub Desktop.
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
| @Composable | |
| fun OutlinedText( | |
| text: String, | |
| modifier: Modifier = Modifier, | |
| textStyle: TextStyle = TextStyle.Default, | |
| stroke: Stroke = Stroke(), | |
| strokeColor: Color = Color.Transparent, | |
| ) { | |
| var textLayoutResult: TextLayoutResult? by remember { | |
| mutableStateOf(null) | |
| } | |
| Text( | |
| text = text, | |
| style = textStyle, | |
| onTextLayout = { | |
| textLayoutResult = it | |
| }, | |
| modifier = modifier | |
| .drawBehind { | |
| textLayoutResult?.let { | |
| drawText( | |
| textLayoutResult = it, | |
| drawStyle = stroke, | |
| color = strokeColor, | |
| ) | |
| } | |
| } | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment