Package 

Object MessageTextFormatter.Companion

    • Method Detail

      • defaultFormatter

        @Composable() final MessageTextFormatter defaultFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamDesign.Typography typography, StreamDesign.Colors colors, Function2<Boolean, Message, TextStyle> textStyle, Function1<Boolean, TextStyle> linkStyle, Function1<Boolean, Color> mentionColor, Function3<AnnotatedString.Builder, Message, User, Unit> builder)

        Builds the default message text formatter.

        Parameters:
        autoTranslationEnabled - Whether the auto-translation is enabled.
        isInDarkMode - Whether the app is in dark mode.
        typography - The typography to use for styling.
        colors - The colors to use for styling.
        textStyle - The text style to use for styling.
        mentionColor - Return Color.Unspecified (the default) to use per-type tokens from colors; return a specified color to apply it to every mention.
        builder - The builder to use for customizing the text.
      • markdownFormatter

        @Composable() final MessageTextFormatter markdownFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamDesign.Typography typography, StreamDesign.Colors colors)

        Builds a formatter that renders the message text as markdown, in place of defaultFormatter:

        ChatTheme(
            messageTextFormatter = MessageTextFormatter.markdownFormatter(autoTranslationEnabled = true),
        )

        Mentions, links and emails are highlighted on top of the rendered markdown. Rendering changes the text's length, so offsets no longer line up with Message.text and this cannot be combined through composite, which styles by those offsets. Styling follows typography and colors.

        A single line break renders as a line break, where the specification collapses it to a space. Complying would leave two trailing spaces as the only way to write one, and would reflow every multi-line message that reads correctly as plain text today. The View-based kit deviates the same way.

        Emphasis, strikethrough, code, headings, lists, quotes and links are rendered. An image falls back to its alt text, and a table or task list to its source, since none of the three can be drawn in a styled string.