@@ -8,6 +8,7 @@ import 'package:stream_chat_flutter/src/context_menu_items/context_menu_reaction
88import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart' ;
99import 'package:stream_chat_flutter/src/dialogs/dialogs.dart' ;
1010import 'package:stream_chat_flutter/src/message_actions_modal/message_actions_modal.dart' ;
11+ import 'package:stream_chat_flutter/src/message_widget/bottom_row.dart' ;
1112import 'package:stream_chat_flutter/src/message_widget/message_widget_content.dart' ;
1213import 'package:stream_chat_flutter/src/message_widget/reactions/message_reactions_modal.dart' ;
1314import 'package:stream_chat_flutter/stream_chat_flutter.dart' ;
@@ -79,8 +80,15 @@ class StreamMessageWidget extends StatefulWidget {
7980 this .userAvatarBuilder,
8081 this .editMessageInputBuilder,
8182 this .textBuilder,
82- this .bottomRowBuilder,
83- this .deletedBottomRowBuilder,
83+ @Deprecated ('''
84+ Use [bottomRowBuilderWithDefaultWidget] instead.
85+ Will be removed in the next major version.
86+ ''' ) this .bottomRowBuilder,
87+ this .bottomRowBuilderWithDefaultWidget,
88+ @Deprecated ('''
89+ Use [bottomRowBuilderWithDefaultWidget] instead.
90+ Will be removed in the next major version.
91+ ''' ) this .deletedBottomRowBuilder,
8492 this .customAttachmentBuilders,
8593 this .padding,
8694 this .textPadding = const EdgeInsets .symmetric (
@@ -92,11 +100,18 @@ class StreamMessageWidget extends StatefulWidget {
92100 this .onQuotedMessageTap,
93101 this .customActions = const [],
94102 this .onAttachmentTap,
95- this .usernameBuilder,
103+ @Deprecated ('''
104+ Use [bottomRowBuilderWithDefaultWidget] instead.
105+ Will be removed in the next major version.
106+ ''' ) this .usernameBuilder,
96107 this .imageAttachmentThumbnailSize = const Size (400 , 400 ),
97108 this .imageAttachmentThumbnailResizeType = 'clip' ,
98109 this .imageAttachmentThumbnailCropType = 'center' ,
99- }) : attachmentBuilders = {
110+ }) : assert (
111+ bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null ,
112+ 'You can only use one of the two bottom row builders' ,
113+ ),
114+ attachmentBuilders = {
100115 'image' : (context, message, attachments) {
101116 final border = RoundedRectangleBorder (
102117 side: attachmentBorderSide ??
@@ -306,7 +321,13 @@ class StreamMessageWidget extends StatefulWidget {
306321 /// {@template bottomRowBuilder}
307322 /// Widget builder for building a bottom row below the message
308323 /// {@endtemplate}
309- final Widget Function (BuildContext , Message )? bottomRowBuilder;
324+ final BottomRowBuilder ? bottomRowBuilder;
325+
326+ /// {@template bottomRowBuilderWithDefaultWidget}
327+ /// Widget builder for building a bottom row below the message.
328+ /// Also contains the default bottom row widget.
329+ /// {@endtemplate}
330+ final BottomRowBuilderWithDefaultWidget ? bottomRowBuilderWithDefaultWidget;
310331
311332 /// {@template deletedBottomRowBuilder}
312333 /// Widget builder for building a bottom row below a deleted message
@@ -537,9 +558,19 @@ class StreamMessageWidget extends StatefulWidget {
537558 void Function (Message )? onReplyTap,
538559 Widget Function (BuildContext , Message )? editMessageInputBuilder,
539560 Widget Function (BuildContext , Message )? textBuilder,
540- Widget Function (BuildContext , Message )? usernameBuilder,
541- Widget Function (BuildContext , Message )? bottomRowBuilder,
542- Widget Function (BuildContext , Message )? deletedBottomRowBuilder,
561+ @Deprecated ('''
562+ Use [bottomRowBuilderWithDefaultWidget] instead.
563+ Will be removed in the next major version.
564+ ''' ) Widget Function (BuildContext , Message )? usernameBuilder,
565+ @Deprecated ('''
566+ Use [bottomRowBuilderWithDefaultWidget] instead.
567+ Will be removed in the next major version.
568+ ''' ) BottomRowBuilder ? bottomRowBuilder,
569+ BottomRowBuilderWithDefaultWidget ? bottomRowBuilderWithDefaultWidget,
570+ @Deprecated ('''
571+ Use [bottomRowBuilderWithDefaultWidget] instead.
572+ Will be removed in the next major version.
573+ ''' ) Widget Function (BuildContext , Message )? deletedBottomRowBuilder,
543574 void Function (BuildContext , Message )? onMessageActions,
544575 Message ? message,
545576 StreamMessageThemeData ? messageTheme,
@@ -587,6 +618,29 @@ class StreamMessageWidget extends StatefulWidget {
587618 String ? imageAttachmentThumbnailResizeType,
588619 String ? imageAttachmentThumbnailCropType,
589620 }) {
621+ assert (
622+ bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null ,
623+ 'You can only use one of the two bottom row builders' ,
624+ );
625+
626+ var _bottomRowBuilderWithDefaultWidget =
627+ bottomRowBuilderWithDefaultWidget ??
628+ this .bottomRowBuilderWithDefaultWidget;
629+
630+ _bottomRowBuilderWithDefaultWidget ?? = (context, message, defaultWidget) {
631+ final _bottomRowBuilder = bottomRowBuilder ?? this .bottomRowBuilder;
632+ if (_bottomRowBuilder != null ) {
633+ return _bottomRowBuilder (context, message);
634+ }
635+
636+ return defaultWidget.copyWith (
637+ onThreadTap: onThreadTap ?? this .onThreadTap,
638+ usernameBuilder: usernameBuilder ?? this .usernameBuilder,
639+ deletedBottomRowBuilder:
640+ deletedBottomRowBuilder ?? this .deletedBottomRowBuilder,
641+ );
642+ };
643+
590644 return StreamMessageWidget (
591645 key: key ?? this .key,
592646 onMentionTap: onMentionTap ?? this .onMentionTap,
@@ -595,10 +649,7 @@ class StreamMessageWidget extends StatefulWidget {
595649 editMessageInputBuilder:
596650 editMessageInputBuilder ?? this .editMessageInputBuilder,
597651 textBuilder: textBuilder ?? this .textBuilder,
598- usernameBuilder: usernameBuilder ?? this .usernameBuilder,
599- bottomRowBuilder: bottomRowBuilder ?? this .bottomRowBuilder,
600- deletedBottomRowBuilder:
601- deletedBottomRowBuilder ?? this .deletedBottomRowBuilder,
652+ bottomRowBuilderWithDefaultWidget: _bottomRowBuilderWithDefaultWidget,
602653 onMessageActions: onMessageActions ?? this .onMessageActions,
603654 message: message ?? this .message,
604655 messageTheme: messageTheme ?? this .messageTheme,
@@ -838,52 +889,69 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
838889 ? Alignment .centerRight
839890 : Alignment .centerLeft,
840891 widthFactor: widget.widthFactor,
841- child: MessageWidgetContent (
842- streamChatTheme: _streamChatTheme,
843- showUsername: showUsername,
844- showTimeStamp: showTimeStamp,
845- showThreadReplyIndicator: showThreadReplyIndicator,
846- showSendingIndicator: showSendingIndicator,
847- showInChannel: showInChannel,
848- isGiphy: isGiphy,
849- isOnlyEmoji: isOnlyEmoji,
850- hasUrlAttachments: hasUrlAttachments,
851- messageTheme: widget.messageTheme,
852- reverse: widget.reverse,
853- message: widget.message,
854- hasNonUrlAttachments: hasNonUrlAttachments,
855- shouldShowReactions: shouldShowReactions,
856- hasQuotedMessage: hasQuotedMessage,
857- textPadding: widget.textPadding,
858- attachmentBuilders: widget.attachmentBuilders,
859- attachmentPadding: widget.attachmentPadding,
860- avatarWidth: avatarWidth,
861- bottomRowPadding: bottomRowPadding,
862- isFailedState: isFailedState,
863- isPinned: isPinned,
864- messageWidget: widget,
865- showBottomRow: showBottomRow,
866- showPinHighlight: widget.showPinHighlight,
867- showReactionPickerIndicator:
868- widget.showReactionPickerIndicator,
869- showReactions: showReactions,
870- showUserAvatar: widget.showUserAvatar,
871- streamChat: _streamChat,
872- translateUserAvatar: widget.translateUserAvatar,
873- deletedBottomRowBuilder: widget.deletedBottomRowBuilder,
874- onThreadTap: widget.onThreadTap,
875- shape: widget.shape,
876- borderSide: widget.borderSide,
877- borderRadiusGeometry: widget.borderRadiusGeometry,
878- textBuilder: widget.textBuilder,
879- onLinkTap: widget.onLinkTap,
880- onMentionTap: widget.onMentionTap,
881- onQuotedMessageTap: widget.onQuotedMessageTap,
882- bottomRowBuilder: widget.bottomRowBuilder,
883- onUserAvatarTap: widget.onUserAvatarTap,
884- userAvatarBuilder: widget.userAvatarBuilder,
885- usernameBuilder: widget.usernameBuilder,
886- ),
892+ child: Builder (builder: (context) {
893+ var _bottomRowBuilderWithDefaultWidget =
894+ widget.bottomRowBuilderWithDefaultWidget;
895+
896+ _bottomRowBuilderWithDefaultWidget ?? =
897+ (context, message, defaultWidget) {
898+ final _bottomRowBuilder = widget.bottomRowBuilder;
899+ if (_bottomRowBuilder != null ) {
900+ return _bottomRowBuilder (context, message);
901+ }
902+
903+ return defaultWidget.copyWith (
904+ onThreadTap: widget.onThreadTap,
905+ usernameBuilder: widget.usernameBuilder,
906+ deletedBottomRowBuilder: widget.deletedBottomRowBuilder,
907+ );
908+ };
909+
910+ return MessageWidgetContent (
911+ streamChatTheme: _streamChatTheme,
912+ showUsername: showUsername,
913+ showTimeStamp: showTimeStamp,
914+ showThreadReplyIndicator: showThreadReplyIndicator,
915+ showSendingIndicator: showSendingIndicator,
916+ showInChannel: showInChannel,
917+ isGiphy: isGiphy,
918+ isOnlyEmoji: isOnlyEmoji,
919+ hasUrlAttachments: hasUrlAttachments,
920+ messageTheme: widget.messageTheme,
921+ reverse: widget.reverse,
922+ message: widget.message,
923+ hasNonUrlAttachments: hasNonUrlAttachments,
924+ shouldShowReactions: shouldShowReactions,
925+ hasQuotedMessage: hasQuotedMessage,
926+ textPadding: widget.textPadding,
927+ attachmentBuilders: widget.attachmentBuilders,
928+ attachmentPadding: widget.attachmentPadding,
929+ avatarWidth: avatarWidth,
930+ bottomRowPadding: bottomRowPadding,
931+ isFailedState: isFailedState,
932+ isPinned: isPinned,
933+ messageWidget: widget,
934+ showBottomRow: showBottomRow,
935+ showPinHighlight: widget.showPinHighlight,
936+ showReactionPickerIndicator:
937+ widget.showReactionPickerIndicator,
938+ showReactions: showReactions,
939+ showUserAvatar: widget.showUserAvatar,
940+ streamChat: _streamChat,
941+ translateUserAvatar: widget.translateUserAvatar,
942+ shape: widget.shape,
943+ borderSide: widget.borderSide,
944+ borderRadiusGeometry: widget.borderRadiusGeometry,
945+ textBuilder: widget.textBuilder,
946+ onLinkTap: widget.onLinkTap,
947+ onMentionTap: widget.onMentionTap,
948+ onQuotedMessageTap: widget.onQuotedMessageTap,
949+ bottomRowBuilderWithDefaultWidget:
950+ _bottomRowBuilderWithDefaultWidget,
951+ onUserAvatarTap: widget.onUserAvatarTap,
952+ userAvatarBuilder: widget.userAvatarBuilder,
953+ );
954+ }),
887955 ),
888956 ),
889957 ),
0 commit comments