From 5ab5390fd20878d6ddd9ef555aa653622def2d84 Mon Sep 17 00:00:00 2001 From: Jaewoong Eum Date: Wed, 4 Dec 2024 19:49:52 +0900 Subject: [PATCH] Implement overriding footer message contents on MessageContentFactory (#5505) * Implement MessageContentFactory * Update API valitations * Update CHANGELOG * Implement overriding fooeter message contents on MessageContentFactory --------- Co-authored-by: Kanat Kiialbaev --- .../api/stream-chat-android-compose.api | 19 +++++----- .../messages/factory/MessageContentFactory.kt | 36 +++++++++++++++++++ .../compose/ui/messages/MessagesScreen.kt | 4 ++- .../ui/messages/list/MessageContainer.kt | 5 +++ .../compose/ui/messages/list/MessageItem.kt | 23 ++++++------ .../compose/ui/messages/list/MessageList.kt | 8 +++++ 6 files changed, 75 insertions(+), 20 deletions(-) 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 e7ba185e9a9..feeb00170ea 100644 --- a/stream-chat-android-compose/api/stream-chat-android-compose.api +++ b/stream-chat-android-compose/api/stream-chat-android-compose.api @@ -1206,9 +1206,12 @@ public class io/getstream/chat/android/compose/ui/components/messages/factory/Me public static final field $stable I public fun ()V public fun MessageDeletedContent (Landroidx/compose/ui/Modifier;Landroidx/compose/runtime/Composer;I)V + public fun MessageFooterContent (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/runtime/Composer;I)V public fun MessageGiphyContent (Lio/getstream/chat/android/models/Message;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V public fun MessageTextContent (Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/User;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V + public fun OwnedMessageVisibilityContent (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/runtime/Composer;I)V public fun QuotedMessageContent (Lio/getstream/chat/android/models/Message;Lio/getstream/chat/android/models/User;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V + public fun UploadingFooterContent (Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/runtime/Composer;I)V } public final class io/getstream/chat/android/compose/ui/components/moderatedmessage/ComposableSingletons$ModeratedMessageDialogKt { @@ -1481,7 +1484,7 @@ public final class io/getstream/chat/android/compose/ui/messages/MessagesScreenK public static final fun MessageDialogs (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Landroidx/compose/runtime/Composer;I)V public static final fun MessageMenus (Landroidx/compose/foundation/layout/BoxScope;Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Lio/getstream/chat/android/compose/viewmodel/messages/MessageComposerViewModel;ZZLandroidx/compose/runtime/Composer;I)V public static final fun MessageModerationDialog (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Lio/getstream/chat/android/compose/viewmodel/messages/MessageComposerViewModel;ZZLandroidx/compose/runtime/Composer;I)V - public static final fun MessagesScreen (Lio/getstream/chat/android/compose/viewmodel/messages/MessagesViewModelFactory;ZLio/getstream/chat/android/models/ReactionSorting;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZZZLio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V + public static final fun MessagesScreen (Lio/getstream/chat/android/compose/viewmodel/messages/MessagesViewModelFactory;ZLio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lio/getstream/chat/android/models/ReactionSorting;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZZZLio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V public static final fun PollDialogs (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;ZLandroidx/compose/runtime/Composer;I)V } @@ -1857,10 +1860,8 @@ public final class io/getstream/chat/android/compose/ui/messages/list/Composable public final class io/getstream/chat/android/compose/ui/messages/list/ComposableSingletons$MessageItemKt { public static final field INSTANCE Lio/getstream/chat/android/compose/ui/messages/list/ComposableSingletons$MessageItemKt; public static field lambda-1 Lkotlin/jvm/functions/Function4; - public static field lambda-2 Lkotlin/jvm/functions/Function4; public fun ()V public final fun getLambda-1$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function4; - public final fun getLambda-2$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function4; } public final class io/getstream/chat/android/compose/ui/messages/list/ComposableSingletons$MessageListKt { @@ -1880,20 +1881,20 @@ public final class io/getstream/chat/android/compose/ui/messages/list/Composable } public final class io/getstream/chat/android/compose/ui/messages/list/MessageContainerKt { - public static final fun MessageContainer (Lio/getstream/chat/android/ui/common/state/messages/list/MessageListItemState;Lio/getstream/chat/android/models/ReactionSorting;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIII)V + public static final fun MessageContainer (Lio/getstream/chat/android/ui/common/state/messages/list/MessageListItemState;Lio/getstream/chat/android/models/ReactionSorting;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIII)V } public final class io/getstream/chat/android/compose/ui/messages/list/MessageItemKt { public static final field HighlightFadeOutDurationMillis I - public static final fun DefaultMessageItemCenterContent (Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V + public static final fun DefaultMessageItemCenterContent (Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;III)V public static final fun EmojiMessageContent (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V - public static final fun MessageItem (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Lio/getstream/chat/android/models/ReactionSorting;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;IIII)V - public static final fun RegularMessageContent (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V + public static final fun MessageItem (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Lio/getstream/chat/android/models/ReactionSorting;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RegularMessageContent (Lio/getstream/chat/android/ui/common/state/messages/list/MessageItemState;Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V } public final class io/getstream/chat/android/compose/ui/messages/list/MessageListKt { - public static final fun MessageList (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Lio/getstream/chat/android/models/ReactionSorting;Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/PaddingValues;Lio/getstream/chat/android/compose/ui/messages/list/MessagesLazyListState;Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIIIII)V - public static final fun MessageList (Lio/getstream/chat/android/ui/common/state/messages/list/MessageListState;Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lio/getstream/chat/android/models/ReactionSorting;Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/PaddingValues;Lio/getstream/chat/android/compose/ui/messages/list/MessagesLazyListState;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIIIII)V + public static final fun MessageList (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Lio/getstream/chat/android/models/ReactionSorting;Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/PaddingValues;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lio/getstream/chat/android/compose/ui/messages/list/MessagesLazyListState;Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIIIII)V + public static final fun MessageList (Lio/getstream/chat/android/ui/common/state/messages/list/MessageListState;Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart;Lio/getstream/chat/android/models/ReactionSorting;Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/PaddingValues;Lio/getstream/chat/android/compose/ui/components/messages/factory/MessageContentFactory;Lio/getstream/chat/android/compose/ui/messages/list/MessagesLazyListState;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;IIIIII)V } public final class io/getstream/chat/android/compose/ui/messages/list/MessagesKt { 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 d0c85080bb2..1a2c9198aca 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 @@ -23,11 +23,14 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import io.getstream.chat.android.compose.ui.components.messages.DefaultMessageDeletedContent import io.getstream.chat.android.compose.ui.components.messages.DefaultMessageGiphyContent +import io.getstream.chat.android.compose.ui.components.messages.MessageFooter import io.getstream.chat.android.compose.ui.components.messages.MessageText import io.getstream.chat.android.compose.ui.components.messages.QuotedMessage +import io.getstream.chat.android.compose.ui.components.messages.UploadingFooter import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.User import io.getstream.chat.android.ui.common.state.messages.list.GiphyAction +import io.getstream.chat.android.ui.common.state.messages.list.MessageItemState /** * Factory for creating message contents that are used to represent the chat message items. @@ -100,4 +103,37 @@ public open class MessageContentFactory { ) } } + + @Composable + public open fun UploadingFooterContent( + modifier: Modifier, + messageItem: MessageItemState, + ) { + val message = messageItem.message + UploadingFooter( + modifier = modifier, + message = message, + ) + } + + /** + * Represents the default message visibility content. + */ + @Composable + public open fun OwnedMessageVisibilityContent( + messageItem: MessageItemState, + ) { + val message = messageItem.message + io.getstream.chat.android.compose.ui.components.messages.OwnedMessageVisibilityContent(message = message) + } + + /** + * Represents the default message footer. + */ + @Composable + public open fun MessageFooterContent( + messageItem: MessageItemState, + ) { + MessageFooter(messageItem = messageItem) + } } diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt index 5a809835789..e67a2c9d07c 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt @@ -62,6 +62,7 @@ import io.getstream.chat.android.compose.state.mediagallerypreview.MediaGalleryP import io.getstream.chat.android.compose.state.messageoptions.MessageOptionItemState import io.getstream.chat.android.compose.ui.components.SimpleDialog import io.getstream.chat.android.compose.ui.components.messageoptions.defaultMessageOptionsState +import io.getstream.chat.android.compose.ui.components.messages.factory.MessageContentFactory import io.getstream.chat.android.compose.ui.components.moderatedmessage.ModeratedMessageDialog import io.getstream.chat.android.compose.ui.components.poll.PollAnswersDialog import io.getstream.chat.android.compose.ui.components.poll.PollMoreOptionsDialog @@ -137,6 +138,7 @@ import io.getstream.chat.android.ui.common.state.messages.updateMessage public fun MessagesScreen( viewModelFactory: MessagesViewModelFactory, showHeader: Boolean = true, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, reactionSorting: ReactionSorting = ReactionSortingByFirstReactionAt, onBackPressed: () -> Unit = {}, onHeaderTitleClick: (channel: Channel) -> Unit = {}, @@ -230,6 +232,7 @@ public fun MessagesScreen( .background(ChatTheme.colors.appBackground) .padding(it), viewModel = listViewModel, + messageContentFactory = messageContentFactory, reactionSorting = reactionSorting, messagesLazyListState = rememberMessageListState(parentMessageId = currentState.parentMessageId), threadMessagesStart = threadMessagesStart, @@ -635,7 +638,6 @@ private fun BoxScope.MessagesScreenReactionsPicker( * perform actions. */ @Suppress("LongMethod") -@OptIn(ExperimentalAnimationApi::class) @Composable public fun BoxScope.AttachmentsPickerMenu( listViewModel: MessageListViewModel, diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt index dd770c24915..e21a2074c13 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt @@ -34,6 +34,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import io.getstream.chat.android.compose.R import io.getstream.chat.android.compose.state.mediagallerypreview.MediaGalleryPreviewResult +import io.getstream.chat.android.compose.ui.components.messages.factory.MessageContentFactory import io.getstream.chat.android.compose.ui.theme.ChatTheme import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory import io.getstream.chat.android.models.Message @@ -84,6 +85,7 @@ import io.getstream.chat.android.ui.common.state.messages.poll.PollSelectionType public fun MessageContainer( messageListItemState: MessageListItemState, reactionSorting: ReactionSorting, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onLongItemClick: (Message) -> Unit = {}, onReactionsClick: (Message) -> Unit = {}, onThreadClick: (Message) -> Unit = {}, @@ -115,6 +117,7 @@ public fun MessageContainer( messageItemContent: @Composable (MessageItemState) -> Unit = { DefaultMessageItem( messageItem = it, + messageContentFactory = messageContentFactory, reactionSorting = reactionSorting, onLongItemClick = onLongItemClick, onReactionsClick = onReactionsClick, @@ -286,6 +289,7 @@ internal fun DefaultSystemMessageContent(systemMessageState: SystemMessageItemSt internal fun DefaultMessageItem( messageItem: MessageItemState, reactionSorting: ReactionSorting, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onLongItemClick: (Message) -> Unit, onReactionsClick: (Message) -> Unit = {}, onThreadClick: (Message) -> Unit, @@ -305,6 +309,7 @@ internal fun DefaultMessageItem( ) { MessageItem( messageItem = messageItem, + messageContentFactory = messageContentFactory, reactionSorting = reactionSorting, onLongItemClick = onLongItemClick, onReactionsClick = onReactionsClick, diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt index 7b94cb875d1..529977b0ec7 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt @@ -64,12 +64,9 @@ import io.getstream.chat.android.compose.state.reactionoptions.ReactionOptionIte import io.getstream.chat.android.compose.ui.components.avatar.UserAvatar import io.getstream.chat.android.compose.ui.components.messages.MessageBubble import io.getstream.chat.android.compose.ui.components.messages.MessageContent -import io.getstream.chat.android.compose.ui.components.messages.MessageFooter import io.getstream.chat.android.compose.ui.components.messages.MessageHeaderLabel import io.getstream.chat.android.compose.ui.components.messages.MessageReactions -import io.getstream.chat.android.compose.ui.components.messages.OwnedMessageVisibilityContent import io.getstream.chat.android.compose.ui.components.messages.PollMessageContent -import io.getstream.chat.android.compose.ui.components.messages.UploadingFooter import io.getstream.chat.android.compose.ui.components.messages.factory.MessageContentFactory import io.getstream.chat.android.compose.ui.theme.ChatTheme import io.getstream.chat.android.compose.ui.util.isEmojiOnlyWithoutBubble @@ -135,6 +132,7 @@ public fun MessageItem( reactionSorting: ReactionSorting, onLongItemClick: (Message) -> Unit, modifier: Modifier = Modifier, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onReactionsClick: (Message) -> Unit = {}, onThreadClick: (Message) -> Unit = {}, onPollUpdated: (Message, Poll) -> Unit = { _, _ -> }, @@ -167,6 +165,7 @@ public fun MessageItem( DefaultMessageItemCenterContent( messageItem = it, onLongItemClick = onLongItemClick, + messageContentFactory = messageContentFactory, onMediaGalleryPreviewResult = onMediaGalleryPreviewResult, onGiphyActionClick = onGiphyActionClick, onQuotedMessageClick = onQuotedMessageClick, @@ -182,7 +181,7 @@ public fun MessageItem( ) }, footerContent: @Composable ColumnScope.(MessageItemState) -> Unit = { - DefaultMessageItemFooterContent(messageItem = it) + DefaultMessageItemFooterContent(messageItem = it, messageContentFactory = messageContentFactory) }, trailingContent: @Composable RowScope.(MessageItemState) -> Unit = { DefaultMessageItemTrailingContent(messageItem = it) @@ -384,23 +383,22 @@ internal fun DefaultMessageItemHeaderContent( @Composable internal fun ColumnScope.DefaultMessageItemFooterContent( messageItem: MessageItemState, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, ) { val message = messageItem.message when { message.isUploading() -> { - UploadingFooter( + messageContentFactory.UploadingFooterContent( modifier = Modifier.align(End), - message = message, + messageItem = messageItem, ) } message.isDeleted() && messageItem.deletedMessageVisibility == DeletedMessageVisibility.VISIBLE_FOR_CURRENT_USER -> { - OwnedMessageVisibilityContent(message = message) + messageContentFactory.OwnedMessageVisibilityContent(messageItem = messageItem) } - else -> { - MessageFooter(messageItem = messageItem) - } + else -> messageContentFactory.MessageFooterContent(messageItem = messageItem) } val position = messageItem.groupPosition @@ -447,6 +445,7 @@ internal fun DefaultMessageItemTrailingContent( public fun DefaultMessageItemCenterContent( modifier: Modifier = Modifier, messageItem: MessageItemState, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onLongItemClick: (Message) -> Unit = {}, onGiphyActionClick: (GiphyAction) -> Unit = {}, onQuotedMessageClick: (Message) -> Unit = {}, @@ -494,6 +493,7 @@ public fun DefaultMessageItemCenterContent( RegularMessageContent( modifier = finalModifier, messageItem = messageItem, + messageContentFactory = messageContentFactory, onLongItemClick = onLongItemClick, onGiphyActionClick = onGiphyActionClick, onMediaGalleryPreviewResult = onMediaGalleryPreviewResult, @@ -572,6 +572,7 @@ public fun EmojiMessageContent( public fun RegularMessageContent( messageItem: MessageItemState, modifier: Modifier = Modifier, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onLongItemClick: (Message) -> Unit = {}, onGiphyActionClick: (GiphyAction) -> Unit = {}, onQuotedMessageClick: (Message) -> Unit = {}, @@ -598,6 +599,7 @@ public fun RegularMessageContent( MessageContent( message = message, currentUser = messageItem.currentUser, + messageContentFactory = messageContentFactory, onLongItemClick = onLongItemClick, onGiphyActionClick = onGiphyActionClick, onMediaGalleryPreviewResult = onMediaGalleryPreviewResult, @@ -616,6 +618,7 @@ public fun RegularMessageContent( content = { MessageContent( message = message, + messageContentFactory = messageContentFactory, currentUser = messageItem.currentUser, onLongItemClick = onLongItemClick, onGiphyActionClick = onGiphyActionClick, diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageList.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageList.kt index ee2f9f31274..4c81cbcaa85 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageList.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageList.kt @@ -31,6 +31,7 @@ import io.getstream.chat.android.compose.R import io.getstream.chat.android.compose.state.mediagallerypreview.MediaGalleryPreviewResult import io.getstream.chat.android.compose.state.mediagallerypreview.MediaGalleryPreviewResultType import io.getstream.chat.android.compose.ui.components.LoadingIndicator +import io.getstream.chat.android.compose.ui.components.messages.factory.MessageContentFactory import io.getstream.chat.android.compose.ui.theme.ChatTheme import io.getstream.chat.android.compose.ui.util.rememberMessageListState import io.getstream.chat.android.compose.viewmodel.messages.MessageListViewModel @@ -91,6 +92,7 @@ public fun MessageList( reactionSorting: ReactionSorting = ReactionSortingByFirstReactionAt, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(vertical = 16.dp), + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, messagesLazyListState: MessagesLazyListState = rememberMessageListState(parentMessageId = viewModel.currentMessagesState.parentMessageId), threadMessagesStart: ThreadMessagesStart = ThreadMessagesStart.BOTTOM, @@ -168,6 +170,7 @@ public fun MessageList( DefaultMessageContainer( messageListItemState = messageListItem, reactionSorting = reactionSorting, + messageContentFactory = messageContentFactory, onMediaGalleryPreviewResult = onMediaGalleryPreviewResult, onCastVote = onCastVote, onRemoveVote = onRemoveVote, @@ -190,6 +193,7 @@ public fun MessageList( MessageList( reactionSorting = reactionSorting, modifier = modifier, + messageContentFactory = messageContentFactory, contentPadding = contentPadding, currentState = viewModel.currentMessagesState, messagesLazyListState = messagesLazyListState, @@ -238,6 +242,7 @@ public fun MessageList( internal fun DefaultMessageContainer( messageListItemState: MessageListItemState, reactionSorting: ReactionSorting, + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, onMediaGalleryPreviewResult: (MediaGalleryPreviewResult?) -> Unit = {}, onThreadClick: (Message) -> Unit, onLongItemClick: (Message) -> Unit, @@ -257,6 +262,7 @@ internal fun DefaultMessageContainer( ) { MessageContainer( messageListItemState = messageListItemState, + messageContentFactory = messageContentFactory, reactionSorting = reactionSorting, onLongItemClick = onLongItemClick, onReactionsClick = onReactionsClick, @@ -348,6 +354,7 @@ public fun MessageList( reactionSorting: ReactionSorting, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(vertical = 16.dp), + messageContentFactory: MessageContentFactory = ChatTheme.messageContentFactory, messagesLazyListState: MessagesLazyListState = rememberMessageListState(parentMessageId = currentState.parentMessageId), onMessagesPageStartReached: () -> Unit = {}, @@ -388,6 +395,7 @@ public fun MessageList( DefaultMessageContainer( messageListItemState = it, reactionSorting = reactionSorting, + messageContentFactory = messageContentFactory, onPollUpdated = onPollUpdated, onCastVote = onCastVote, onRemoveVote = onRemoveVote,