@@ -38,6 +38,8 @@ class ChatBubbleWidget extends StatefulWidget {
38
38
required this .onLongPress,
39
39
required this .slideValue,
40
40
required this .onInitReplyToMessage,
41
+ this .previousMessage,
42
+ this .nextMessage,
41
43
this .profileCircleConfig,
42
44
this .chatBubbleConfig,
43
45
this .repliedMessageConfig,
@@ -52,6 +54,12 @@ class ChatBubbleWidget extends StatefulWidget {
52
54
/// Represent current instance of message.
53
55
final Message message;
54
56
57
+ /// Represent message sent before that one.
58
+ final Message ? previousMessage;
59
+
60
+ /// Represent message sent after that one.
61
+ final Message ? nextMessage;
62
+
55
63
/// Give callback once user long press on chat bubble.
56
64
final DoubleCallBack onLongPress;
57
65
@@ -101,6 +109,12 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
101
109
102
110
bool get isMessageBySender => widget.message.sendBy == currentUser? .id;
103
111
112
+ bool get isMessageBySameSenderAsPrevious =>
113
+ widget.previousMessage? .sendBy == widget.message.sendBy;
114
+
115
+ bool get isMessageLastFromSender =>
116
+ widget.nextMessage? .sendBy == widget.message.sendBy;
117
+
104
118
bool get isLastMessage =>
105
119
chatController? .initialMessageList.last.id == widget.message.id;
106
120
@@ -163,14 +177,22 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
163
177
padding:
164
178
widget.chatBubbleConfig? .padding ?? const EdgeInsets .only (left: 5.0 ),
165
179
margin:
166
- widget.chatBubbleConfig? .margin ?? const EdgeInsets .only (bottom: 10 ),
180
+ (widget.chatBubbleConfig? .margin ?? const EdgeInsets .only (bottom: 10 ))
181
+ .add (
182
+ isLastMessage
183
+ ? EdgeInsets .only (
184
+ bottom: widget.chatBubbleConfig
185
+ ? .additionalBottomInsetIfMessageIsLast ??
186
+ 16 )
187
+ : const EdgeInsets .all (0 ),
188
+ ),
167
189
child: Row (
168
190
mainAxisSize: MainAxisSize .min,
169
191
mainAxisAlignment:
170
192
isMessageBySender ? MainAxisAlignment .end : MainAxisAlignment .start,
171
193
crossAxisAlignment: CrossAxisAlignment .end,
172
194
children: [
173
- if (! isMessageBySender &&
195
+ if (! ( isMessageBySender || isMessageLastFromSender) &&
174
196
(featureActiveConfig? .enableOtherUserProfileAvatar ?? true ))
175
197
ProfileCircle (
176
198
bottomPadding: widget.message.reaction.reactions.isNotEmpty
@@ -188,6 +210,14 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
188
210
circleRadius: profileCircleConfig? .circleRadius,
189
211
onTap: () => _onAvatarTap (messagedUser),
190
212
onLongPress: () => _onAvatarLongPress (messagedUser),
213
+ )
214
+ else
215
+ SizedBox (
216
+ width: profileCircleConfig == null
217
+ ? 10
218
+ : (profileCircleConfig! .circleRadius * 2 +
219
+ (profileCircleConfig? .padding? .collapsedSize.width ??
220
+ 12 )),
191
221
),
192
222
Expanded (
193
223
child: SwipeToReply (
@@ -295,7 +325,8 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
295
325
crossAxisAlignment:
296
326
isMessageBySender ? CrossAxisAlignment .end : CrossAxisAlignment .start,
297
327
children: [
298
- if ((chatController? .chatUsers.length ?? 0 ) > 1 &&
328
+ if (! isMessageBySameSenderAsPrevious &&
329
+ (chatController? .chatUsers.length ?? 0 ) > 1 &&
299
330
! isMessageBySender &&
300
331
(featureActiveConfig? .enableOtherUserName ?? true ))
301
332
Padding (
0 commit comments