Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created July 30, 2021 13:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/eb81fa1e47c66cf4fb7596d289e68ba9 to your computer and use it in GitHub Desktop.
Save PatilShreyas/eb81fa1e47c66cf4fb7596d289e68ba9 to your computer and use it in GitHub Desktop.
@Composable
fun Social() {
val dividerId = "inlineDividerId"
val text = buildAnnotatedString {
// LinkedIn
append(AnnotatedString("LinkedIn ", spanStyle = SpanStyle(Color.Blue)))
// Divider
appendInlineContent(dividerId, "[divider]")
// Twitter
append(AnnotatedString(" Twitter ", spanStyle = SpanStyle(Color.Blue)))
// Divider
appendInlineContent(dividerId, "[divider]")
// Portfolio
append(AnnotatedString(" Portfolio", spanStyle = SpanStyle(Color.Blue)))
}
val inlineDividerContent = mapOf(
Pair(
// This tells the [CoreText] to replace the placeholder string "[divider]" by
// the composable given in the [InlineTextContent] object.
dividerId,
InlineTextContent(
// Placeholder tells text layout the expected size and vertical alignment of
// children composable.
Placeholder(
width = 0.15.em,
height = 0.90.em,
placeholderVerticalAlign = PlaceholderVerticalAlign.TextCenter
)
) {
Box(
modifier = Modifier
.rotate(15f)
.fillMaxSize()
.clip(RectangleShape)
.background(Color.DarkGray)
)
}
)
)
BasicText(text = text, inlineContent = inlineDividerContent, style = TextStyle(fontSize = 17.sp))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment