From 3fdff3b75b043b7473a95a6e5a43ff118b0468a1 Mon Sep 17 00:00:00 2001 From: PetarVelikov Date: Tue, 17 Dec 2024 11:11:05 +0100 Subject: [PATCH 1/2] [AND-160] Make mentions color customizable. --- .../api/stream-chat-android-compose.api | 12 ++-- .../messages/factory/MessageContentFactory.kt | 1 + .../android/compose/ui/theme/MessageTheme.kt | 3 + .../compose/ui/util/MessageTextFormatter.kt | 26 +++++++- .../ui/util/MessageTextFormatterUtils.kt | 66 +++++++++++++++++++ .../ui/util/QuotedMessageTextFormatter.kt | 13 +++- .../docs/kotlin/compose/general/ChatTheme.kt | 21 ++++-- 7 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatterUtils.kt diff --git a/stream-chat-android-compose/api/stream-chat-android-compose.api b/stream-chat-android-compose/api/stream-chat-android-compose.api index 0af6b59ffa6..052e1ed0549 100644 --- a/stream-chat-android-compose/api/stream-chat-android-compose.api +++ b/stream-chat-android-compose/api/stream-chat-android-compose.api @@ -2384,10 +2384,11 @@ public final class io/getstream/chat/android/compose/ui/theme/MessageOptionsThem public final class io/getstream/chat/android/compose/ui/theme/MessageTheme { public static final field $stable I public static final field Companion Lio/getstream/chat/android/compose/ui/theme/MessageTheme$Companion; - public synthetic fun (Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;JLkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Landroidx/compose/ui/text/TextStyle; public final fun component10 ()Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle; public final fun component11 ()Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle; + public final fun component12-0d7_KjU ()J public final fun component2 ()Lio/getstream/chat/android/compose/ui/theme/ComponentPadding; public final fun component3-0d7_KjU ()J public final fun component4 ()Landroidx/compose/foundation/BorderStroke; @@ -2396,8 +2397,8 @@ public final class io/getstream/chat/android/compose/ui/theme/MessageTheme { public final fun component7-0d7_KjU ()J public final fun component8-0d7_KjU ()J public final fun component9 ()Lio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme; - public final fun copy-pk3EwZ4 (Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;)Lio/getstream/chat/android/compose/ui/theme/MessageTheme; - public static synthetic fun copy-pk3EwZ4$default (Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;ILjava/lang/Object;)Lio/getstream/chat/android/compose/ui/theme/MessageTheme; + public final fun copy-D31MQNc (Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;J)Lio/getstream/chat/android/compose/ui/theme/MessageTheme; + public static synthetic fun copy-D31MQNc$default (Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Landroidx/compose/ui/text/TextStyle;Lio/getstream/chat/android/compose/ui/theme/ComponentPadding;JLandroidx/compose/foundation/BorderStroke;Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes;Landroidx/compose/ui/text/TextStyle;JJLio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme;Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle;Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle;JILjava/lang/Object;)Lio/getstream/chat/android/compose/ui/theme/MessageTheme; public fun equals (Ljava/lang/Object;)Z public final fun getAudioRecording ()Lio/getstream/chat/android/compose/ui/theme/messages/attachments/AudioRecordingAttachmentTheme; public final fun getBackgroundBorder ()Landroidx/compose/foundation/BorderStroke; @@ -2405,6 +2406,7 @@ public final class io/getstream/chat/android/compose/ui/theme/MessageTheme { public final fun getBackgroundShapes ()Lio/getstream/chat/android/compose/ui/theme/MessageBackgroundShapes; public final fun getContentPadding ()Lio/getstream/chat/android/compose/ui/theme/ComponentPadding; public final fun getDeletedBackgroundColor-0d7_KjU ()J + public final fun getMentionColor-0d7_KjU ()J public final fun getPoll ()Lio/getstream/chat/android/compose/ui/theme/messages/list/PollMessageStyle; public final fun getQuoted ()Lio/getstream/chat/android/compose/ui/theme/messages/list/QuotedMessageStyle; public final fun getQuotedBackgroundColor-0d7_KjU ()J @@ -3361,7 +3363,7 @@ public abstract interface class io/getstream/chat/android/compose/ui/util/Messag public final class io/getstream/chat/android/compose/ui/util/MessageTextFormatter$Companion { public final fun composite ([Lio/getstream/chat/android/compose/ui/util/MessageTextFormatter;)Lio/getstream/chat/android/compose/ui/util/MessageTextFormatter; - public final fun defaultFormatter (ZZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/MessageTextFormatter; + public final fun defaultFormatter (ZZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/MessageTextFormatter; public final fun defaultFormatter (ZZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamShapes;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/MessageTextFormatter; } @@ -3382,7 +3384,7 @@ public abstract interface class io/getstream/chat/android/compose/ui/util/Quoted public final class io/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter$Companion { public final fun composite ([Lio/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter;)Lio/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter; public final fun defaultFormatter (ZLandroid/content/Context;ZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lio/getstream/chat/android/compose/ui/theme/StreamShapes;Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Lio/getstream/chat/android/compose/ui/theme/MessageTheme;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter; - public final fun defaultFormatter (ZLandroid/content/Context;ZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lio/getstream/chat/android/compose/ui/theme/StreamShapes;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter; + public final fun defaultFormatter (ZLandroid/content/Context;ZLio/getstream/chat/android/compose/ui/theme/StreamTypography;Lio/getstream/chat/android/compose/ui/theme/StreamColors;Lio/getstream/chat/android/compose/ui/theme/StreamShapes;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)Lio/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter; } public final class io/getstream/chat/android/compose/ui/util/ReactionDrawable { diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory.kt index 1a2c9198aca..3965ea9203b 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory.kt @@ -78,6 +78,7 @@ public open class MessageContentFactory { currentUser = currentUser, onLongItemClick = onLongItemClick, onLinkClick = onLinkClick, + onUserMentionClick = onUserMentionClick, ) } diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt index 1e5b38a6279..2f0e2d0b464 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt @@ -41,6 +41,7 @@ import io.getstream.chat.android.compose.ui.theme.messages.list.QuotedMessageSty * @param quotedBackgroundColor The background color for the quoted messages. * @param deletedBackgroundColor The background color for the deleted messages. * @param audioRecording The theming for the audio recording attachment. + * @param mentionColor The color for the mentions in the messages. */ @Immutable public data class MessageTheme( @@ -71,6 +72,7 @@ public data class MessageTheme( val audioRecording: AudioRecordingAttachmentTheme, val quoted: QuotedMessageStyle, val poll: PollMessageStyle, + val mentionColor: Color, ) { public companion object { @@ -188,6 +190,7 @@ public data class MessageTheme( colors = colors, shapes = shapes, ), + mentionColor = colors.primaryAccent, ).let { theme -> theme.copy( quoted = theme.quoted.copy( diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatter.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatter.kt index 6af3f2eff7e..8974b4cae85 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatter.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatter.kt @@ -18,6 +18,7 @@ package io.getstream.chat.android.compose.ui.util import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import io.getstream.chat.android.compose.ui.theme.ChatTheme @@ -68,9 +69,17 @@ public fun interface MessageTextFormatter { else -> StreamColors.defaultColors() }, textStyle: (isMine: Boolean) -> TextStyle = defaultTextStyle(isInDarkMode, typography, colors), + mentionColor: (isMine: Boolean) -> Color = defaultMentionColor(isInDarkMode, typography, colors), builder: AnnotatedMessageTextBuilder? = null, ): MessageTextFormatter { - return DefaultMessageTextFormatter(autoTranslationEnabled, typography, colors, textStyle, builder) + return DefaultMessageTextFormatter( + autoTranslationEnabled = autoTranslationEnabled, + typography = typography, + colors = colors, + textStyle = textStyle, + mentionColor = mentionColor, + builder = builder, + ) } /** @@ -111,7 +120,16 @@ public fun interface MessageTextFormatter { builder: AnnotatedMessageTextBuilder? = null, ): MessageTextFormatter { val textStyle = defaultTextStyle(ownMessageTheme, otherMessageTheme) - return defaultFormatter(autoTranslationEnabled, isInDarkMode, typography, colors, textStyle, builder) + val mentionColor = defaultMentionColor(ownMessageTheme, otherMessageTheme) + return defaultFormatter( + autoTranslationEnabled = autoTranslationEnabled, + isInDarkMode = isInDarkMode, + typography = typography, + colors = colors, + textStyle = textStyle, + mentionColor = mentionColor, + builder = builder, + ) } @Composable @@ -186,6 +204,7 @@ private class DefaultMessageTextFormatter( private val typography: StreamTypography, private val colors: StreamColors, private val textStyle: (isMine: Boolean) -> TextStyle, + private val mentionColor: (isMine: Boolean) -> Color, private val builder: AnnotatedMessageTextBuilder? = null, ) : MessageTextFormatter { @@ -198,12 +217,13 @@ private class DefaultMessageTextFormatter( } val mentionedUserNames = message.mentionedUsers.map { it.name.ifEmpty { it.id } } val textColor = textStyle(message.isMine(currentUser)).color + val mentionColor = mentionColor(message.isMine(currentUser)) return buildAnnotatedMessageText( text = displayedText, textColor = textColor, textFontStyle = typography.body.fontStyle, linkColor = colors.primaryAccent, - mentionsColor = colors.primaryAccent, + mentionsColor = mentionColor, mentionedUserNames = mentionedUserNames, builder = { builder?.invoke(this, message, currentUser) diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatterUtils.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatterUtils.kt new file mode 100644 index 00000000000..06823f3ebf5 --- /dev/null +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessageTextFormatterUtils.kt @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. + * + * Licensed under the Stream License; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.getstream.chat.android.compose.ui.util + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import io.getstream.chat.android.compose.ui.theme.MessageTheme +import io.getstream.chat.android.compose.ui.theme.StreamColors +import io.getstream.chat.android.compose.ui.theme.StreamShapes +import io.getstream.chat.android.compose.ui.theme.StreamTypography + +/** + * Function that returns the color of the mentions text, depending on whether the message is mine or not. + * + * @param ownTheme The theme for messages from the current user. + * @param otherTheme The theme for messages from the other user. + * + * @return A function that returns the color of the mention text, based on whether the message is from the current user + * or from another user. + */ +@Composable +internal fun defaultMentionColor( + ownTheme: MessageTheme, + otherTheme: MessageTheme, +): (Boolean) -> Color { + return { isMine -> + if (isMine) ownTheme.mentionColor else otherTheme.mentionColor + } +} + +/** + * Function that returns the color of the mentions text, depending on whether the message is mine or not. + * + * @param isInDarkMode Indicator if the app is in dark mode. + * @param typography The typography to use for styling. + * @param colors The colors to use for styling. + * @param shapes The shapes to use for styling. + * + * @return A function that returns the color of the mention text, based on whether the message is from the current user + * or from another user. + */ +@Composable +internal fun defaultMentionColor( + isInDarkMode: Boolean, + typography: StreamTypography, + colors: StreamColors, + shapes: StreamShapes = StreamShapes.defaultShapes(), +): (Boolean) -> Color { + val ownTheme = MessageTheme.defaultOwnTheme(isInDarkMode, typography, shapes, colors) + val otherTheme = MessageTheme.defaultOtherTheme(isInDarkMode, typography, shapes, colors) + return defaultMentionColor(ownTheme, otherTheme) +} diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter.kt index 204d32b5ac4..4c1033ca4fd 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/QuotedMessageTextFormatter.kt @@ -19,6 +19,7 @@ package io.getstream.chat.android.compose.ui.util import android.content.Context import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle @@ -62,6 +63,7 @@ public fun interface QuotedMessageTextFormatter { * @param typography The typography to use for styling. * @param colors The colors to use for styling. * @param textStyle The text style to use for styling. + * @param mentionColor The color to use for mentions. * @param builder The builder to use for customizing the text. * @return The default implementation of [QuotedMessageTextFormatter]. * @@ -79,6 +81,7 @@ public fun interface QuotedMessageTextFormatter { }, shapes: StreamShapes = StreamShapes.defaultShapes(), textStyle: (isMine: Boolean) -> TextStyle = defaultTextStyle(isInDarkMode, typography, colors, shapes), + mentionColor: (isMine: Boolean) -> Color = defaultMentionColor(isInDarkMode, typography, colors, shapes), builder: AnnotatedQuotedMessageTextBuilder? = null, ): QuotedMessageTextFormatter { return DefaultQuotedMessageTextFormatter( @@ -87,6 +90,7 @@ public fun interface QuotedMessageTextFormatter { typography, colors, textStyle, + mentionColor, builder, ) } @@ -122,6 +126,7 @@ public fun interface QuotedMessageTextFormatter { builder: AnnotatedQuotedMessageTextBuilder? = null, ): QuotedMessageTextFormatter { val textStyle = defaultTextStyle(ownMessageTheme, otherMessageTheme) + val mentionColor = defaultMentionColor(ownMessageTheme, otherMessageTheme) return defaultFormatter( autoTranslationEnabled, context, @@ -130,6 +135,7 @@ public fun interface QuotedMessageTextFormatter { colors, shapes, textStyle, + mentionColor, builder, ) } @@ -204,6 +210,7 @@ private class DefaultQuotedMessageTextFormatter( private val typography: StreamTypography, private val colors: StreamColors, private val textStyle: (isMine: Boolean) -> TextStyle, + private val mentionColor: (isMine: Boolean) -> Color, private val builder: AnnotatedQuotedMessageTextBuilder? = null, ) : QuotedMessageTextFormatter { @@ -236,13 +243,15 @@ private class DefaultQuotedMessageTextFormatter( "quotedMessageText is null. Cannot display invalid message title." } - val textColor = textStyle(replyMessage?.isMine(currentUser) != false).color + val isMine = replyMessage?.isMine(currentUser) != false + val textColor = textStyle(isMine).color + val mentionColor = mentionColor(isMine) return buildAnnotatedMessageText( text = quotedMessageText, textColor = textColor, textFontStyle = typography.body.fontStyle, linkColor = colors.primaryAccent, - mentionsColor = colors.primaryAccent, + mentionsColor = mentionColor, builder = { builder?.invoke(this, message, replyMessage, currentUser) }, diff --git a/stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/compose/general/ChatTheme.kt b/stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/compose/general/ChatTheme.kt index f108034af8f..d8845ce6803 100644 --- a/stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/compose/general/ChatTheme.kt +++ b/stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/compose/general/ChatTheme.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.unit.dp import io.getstream.chat.android.compose.ui.messages.MessagesScreen import io.getstream.chat.android.compose.ui.theme.ChatTheme +import io.getstream.chat.android.compose.ui.theme.MessageTheme import io.getstream.chat.android.compose.ui.theme.StreamColors import io.getstream.chat.android.compose.ui.theme.StreamShapes import io.getstream.chat.android.compose.ui.theme.StreamTypography @@ -307,7 +308,13 @@ private object ChatThemeQuotedMessageTextFormatterDefaultSnippet : ChatThemeCust colors: StreamColors, ): QuotedMessageTextFormatter { return QuotedMessageTextFormatter.defaultFormatter( - autoTranslationEnabled, LocalContext.current, isInDarkMode, typography, colors + autoTranslationEnabled = autoTranslationEnabled, + context = LocalContext.current, + isInDarkMode = isInDarkMode, + typography = typography, + colors = colors, + ownMessageTheme = MessageTheme.defaultOwnTheme(), + otherMessageTheme = MessageTheme.defaultOtherTheme(), ) { message, replyMessage, currentUser -> addStyle( SpanStyle( @@ -346,11 +353,13 @@ private object ChatThemeQuotedMessageTextFormatterCompositeSnippet : ChatThemeCu ): QuotedMessageTextFormatter { return QuotedMessageTextFormatter.composite( QuotedMessageTextFormatter.defaultFormatter( - autoTranslationEnabled, - LocalContext.current, - isInDarkMode, - typography, - colors + autoTranslationEnabled = autoTranslationEnabled, + context = LocalContext.current, + isInDarkMode = isInDarkMode, + typography = typography, + colors = colors, + ownMessageTheme = MessageTheme.defaultOwnTheme(), + otherMessageTheme = MessageTheme.defaultOtherTheme(), ), blueLettersQuotedMessageTextFormatter() ) From 19ab3fe5ff987b8b1cbf9c20ed59191dc6a702e8 Mon Sep 17 00:00:00 2001 From: PetarVelikov Date: Tue, 17 Dec 2024 11:44:02 +0100 Subject: [PATCH 2/2] [AND-160] Update CHANGELOG.md. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff8037e4e89..27a1ded9f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ - Add `MessageOptionItemVisibility.isBlockUserVisible` property to show/hide the block user option. [#5512](https://github.com/GetStream/stream-chat-android/pull/5512) - Add `ChatTheme.channelOptionsTheme` property to customize the channel options. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513) - Add `SearchResultItemState.channel` property containing the cached info of the channel where the message was sent. [#5500](https://github.com/GetStream/stream-chat-android/pull/5500) +- Add `MessageTheme.mentionColor` property for customizing the mentions color in messages. [#5528](https://github.com/GetStream/stream-chat-android/pull/5528) ### ⚠️ Changed - 🚨 Breaking change: The `SearchResultNameFormatter.formatMessageTitle` method receives a `SearchResultItemState` instead of a `Message`. [#5500](https://github.com/GetStream/stream-chat-android/pull/5500)