TextWithLinks

TextWithLinks
TextWithLinks

TextWithLinks shows a text with clickable links.

Usage

To use the TextWithLinks composable you need to:

  1. Define your string resource in your XML file with an annotation tag surrounding the link text.
    <string name="text_with_links">By continuing, you agree to the <annotation type="terms">Terms &amp; Conditions</annotation> and <annotation type="privacy">Privacy Policy</annotation>.</string>
  2. Create a list of TextLink which has the annotation type value and the link which should open.
    val textLinkList = listOf(
    TextLink("terms", "https://www.terms.com"),
    TextLink("privacy", "https://www.privacy.com")
    )
  3. Include the TextWithLinks composable to your screen.
    TextWithLinks(
    modifier = Modifier,
    stringResId = R.string.text_with_links,
    textLinkList = textLinkList,
    goToWebUrl = { url -> navigator.goToWeb(url) }
    )