Created
April 15, 2020 16:29
-
-
Save pardom/6e23b0c3f0e3c0debcdb213bf02a9093 to your computer and use it in GitHub Desktop.
Compose PlaceholderText
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
@Composable | |
fun PlaceholderText( | |
text: String, | |
color: Color = Color.LightGray, | |
shape: Shape = RoundedCornerShape(2.dp), | |
modifier: Modifier = Modifier.None, | |
style: TextStyle = currentTextStyle(), | |
softWrap: Boolean = true, | |
overflow: TextOverflow = TextOverflow.Clip, | |
maxLines: Int = Int.MAX_VALUE, | |
onTextLayout: (TextLayoutResult) -> Unit = {} | |
) { | |
Text( | |
text, | |
modifier = modifier + Modifier.drawBackground(color = color, shape = shape), | |
style = style.copy(color = color), | |
softWrap = softWrap, | |
overflow = overflow, | |
maxLines = maxLines, | |
onTextLayout = onTextLayout | |
) | |
} | |
@Composable | |
fun PlaceholderText( | |
text: AnnotatedString, | |
color: Color = Color.LightGray, | |
shape: Shape = RoundedCornerShape(2.dp), | |
modifier: Modifier = Modifier.None, | |
style: TextStyle = currentTextStyle(), | |
softWrap: Boolean = true, | |
overflow: TextOverflow = TextOverflow.Clip, | |
maxLines: Int = Int.MAX_VALUE, | |
onTextLayout: (TextLayoutResult) -> Unit = {} | |
) { | |
Text( | |
text, | |
modifier = modifier + Modifier.drawBackground(color = color, shape = shape), | |
style = style.copy(color = color), | |
softWrap = softWrap, | |
overflow = overflow, | |
maxLines = maxLines, | |
onTextLayout = onTextLayout | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment