-
public class MessageTextFormatter.Companion
-
-
Field Summary
Fields Modifier and Type Field Description public final static MessageTextFormatter.CompanionINSTANCE
-
Method Summary
Modifier and Type Method Description final MessageTextFormatterdefaultFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamColors 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. final MessageTextFormatterdefaultFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamShapes shapes, StreamColors colors, MessageTheme ownMessageTheme, MessageTheme otherMessageTheme, Function3<AnnotatedString.Builder, Message, User, Unit> builder)Builds the default message text formatter. final MessageTextFormattermarkdownFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamColors colors)Builds a formatter that renders the message text as markdown, in place of defaultFormatter:
Mentions, links and emails are highlighted on top of the rendered markdown.ChatTheme( messageTextFormatter = MessageTextFormatter.markdownFormatter(autoTranslationEnabled = true), )final MessageTextFormattercomposite(MessageTextFormatter formatters)Builds a composite message text formatter. -
-
Method Detail
-
defaultFormatter
@Composable() final MessageTextFormatter defaultFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamColors 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.builder- The builder to use for customizing the text.
-
defaultFormatter
@Composable() final MessageTextFormatter defaultFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamShapes shapes, StreamColors colors, MessageTheme ownMessageTheme, MessageTheme otherMessageTheme, Function3<AnnotatedString.Builder, Message, User, Unit> builder)
Builds the default message text formatter.
- Parameters:
autoTranslationEnabled- Whether the auto-translation is enabled.typography- The typography to use for styling.colors- The colors to use for styling.ownMessageTheme- The theme to use for the current user's messages.otherMessageTheme- The theme to use for other users' messages.builder- The builder to use for customizing the text.
-
markdownFormatter
@Composable() final MessageTextFormatter markdownFormatter(Boolean autoTranslationEnabled, Boolean isInDarkMode, StreamTypography typography, StreamColors 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.
-
composite
final MessageTextFormatter composite(MessageTextFormatter formatters)
Builds a composite message text formatter.
- Parameters:
formatters- The list of formatters to use.
-
-
-
-