Skip to content

Update multiple-links snippet #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,28 @@ private object TextEffectiveStateManagement2 {
// [START android_compose_text_link_1]
@Composable
fun AnnotatedStringWithLinkSample() {
// Display a link in the text
// Display multiple links in the text
Text(
buildAnnotatedString {
append("Build better apps faster with ")
append("Go to the ")
withLink(
LinkAnnotation.Url(
"https://developer.android.com/jetpack/compose",
"https://developer.android.com/",
TextLinkStyles(style = SpanStyle(color = Color.Blue))
)
) {
append("Jetpack Compose")
append("Android Developers ")
}
append("website, and check out the")
withLink(
LinkAnnotation.Url(
"https://developer.android.com/jetpack/compose",
TextLinkStyles(style = SpanStyle(color = Color.Green))
)
) {
append("Compose guidance")
}
append(".")
}
)
}
Expand Down Expand Up @@ -592,7 +602,7 @@ fun AnnotatedStringWithListenerSample() {
// [END android_compose_text_link_2]

@Composable
private fun TextSample(samples: Map<String, @Composable ()->Unit>) {
private fun TextSample(samples: Map<String, @Composable () -> Unit>) {
MaterialTheme {
Box(
Modifier
Expand Down Expand Up @@ -626,6 +636,7 @@ private const val SAMPLE_LONG_TEXT =
"It simplifies and accelerates UI development on Android bringing your apps " +
"to life with less code, powerful tools, and intuitive Kotlin APIs. " +
"It makes building Android UI faster and easier."

@Composable
@Preview
fun LineBreakSample() {
Expand Down