@@ -69,8 +69,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
69
69
70
70
bool get isMessageBySender => widget.message.sentBy == currentUser? .id;
71
71
72
- bool get isLastMessage =>
73
- chatController? .initialMessageList.last.id == widget.message.id;
72
+ bool get isLastMessage => chatController? .initialMessageList.last.id == widget.message.id;
74
73
75
74
FeatureActiveConfig ? featureActiveConfig;
76
75
ChatController ? chatController;
@@ -123,19 +122,16 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
123
122
margin: chatBubbleConfig? .margin ?? const EdgeInsets .only (bottom: 10 ),
124
123
child: Row (
125
124
mainAxisSize: MainAxisSize .min,
126
- mainAxisAlignment:
127
- isMessageBySender ? MainAxisAlignment .end : MainAxisAlignment .start,
125
+ mainAxisAlignment: isMessageBySender ? MainAxisAlignment .end : MainAxisAlignment .start,
128
126
crossAxisAlignment: CrossAxisAlignment .end,
129
127
children: [
130
- if (! isMessageBySender &&
131
- (featureActiveConfig? .enableOtherUserProfileAvatar ?? true ))
128
+ if (! isMessageBySender && (featureActiveConfig? .enableOtherUserProfileAvatar ?? true ))
132
129
profileCircle (messagedUser),
133
130
Expanded (
134
131
child: _messagesWidgetColumn (messagedUser),
135
132
),
136
133
if (isMessageBySender) ...[getReceipt ()],
137
- if (isMessageBySender &&
138
- (featureActiveConfig? .enableCurrentUserProfileAvatar ?? true ))
134
+ if (isMessageBySender && (featureActiveConfig? .enableCurrentUserProfileAvatar ?? true ))
139
135
profileCircle (messagedUser),
140
136
],
141
137
),
@@ -152,8 +148,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
152
148
imageUrl: messagedUser? .profilePhoto,
153
149
imageType: messagedUser? .imageType,
154
150
defaultAvatarImage: messagedUser? .defaultAvatarImage ?? profileImage,
155
- networkImageProgressIndicatorBuilder:
156
- messagedUser? .networkImageProgressIndicatorBuilder,
151
+ networkImageProgressIndicatorBuilder: messagedUser? .networkImageProgressIndicatorBuilder,
157
152
assetImageErrorBuilder: messagedUser? .assetImageErrorBuilder,
158
153
networkImageErrorBuilder: messagedUser? .networkImageErrorBuilder,
159
154
circleRadius: profileCircleConfig? .circleRadius,
@@ -164,49 +159,39 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
164
159
165
160
void onRightSwipe () {
166
161
if (maxDuration != null ) {
167
- widget.message.voiceMessageDuration =
168
- Duration (milliseconds: maxDuration! );
162
+ widget.message.voiceMessageDuration = Duration (milliseconds: maxDuration! );
169
163
}
170
164
if (chatListConfig.swipeToReplyConfig? .onRightSwipe != null ) {
171
- chatListConfig.swipeToReplyConfig? .onRightSwipe !(
172
- widget.message.message, widget.message.sentBy);
165
+ chatListConfig.swipeToReplyConfig? .onRightSwipe !(widget.message.message, widget.message.sentBy);
173
166
}
174
167
widget.onSwipe (widget.message);
175
168
}
176
169
177
170
void onLeftSwipe () {
178
171
if (maxDuration != null ) {
179
- widget.message.voiceMessageDuration =
180
- Duration (milliseconds: maxDuration! );
172
+ widget.message.voiceMessageDuration = Duration (milliseconds: maxDuration! );
181
173
}
182
174
if (chatListConfig.swipeToReplyConfig? .onLeftSwipe != null ) {
183
- chatListConfig.swipeToReplyConfig? .onLeftSwipe !(
184
- widget.message.message, widget.message.sentBy);
175
+ chatListConfig.swipeToReplyConfig? .onLeftSwipe !(widget.message.message, widget.message.sentBy);
185
176
}
186
177
widget.onSwipe (widget.message);
187
178
}
188
179
189
180
void _onAvatarTap (ChatUser ? user) {
190
- if (chatListConfig.profileCircleConfig? .onAvatarTap != null &&
191
- user != null ) {
181
+ if (chatListConfig.profileCircleConfig? .onAvatarTap != null && user != null ) {
192
182
chatListConfig.profileCircleConfig? .onAvatarTap !(user);
193
183
}
194
184
}
195
185
196
186
Widget getReceipt () {
197
- final showReceipts = chatListConfig.chatBubbleConfig
198
- ? .outgoingChatBubbleConfig? .receiptsWidgetConfig? .showReceiptsIn ??
187
+ final showReceipts = chatListConfig.chatBubbleConfig? .outgoingChatBubble? .receiptsWidgetConfig? .showReceiptsIn ??
199
188
ShowReceiptsIn .lastMessage;
200
189
if (showReceipts == ShowReceiptsIn .all) {
201
190
return ValueListenableBuilder (
202
191
valueListenable: widget.message.statusNotifier,
203
192
builder: (context, value, child) {
204
- if (ChatViewInheritedWidget .of (context)
205
- ? .featureActiveConfig
206
- .receiptsBuilderVisibility ??
207
- true ) {
208
- return chatListConfig.chatBubbleConfig? .outgoingChatBubbleConfig
209
- ? .receiptsWidgetConfig? .receiptsBuilder
193
+ if (ChatViewInheritedWidget .of (context)? .featureActiveConfig.receiptsBuilderVisibility ?? true ) {
194
+ return chatListConfig.chatBubbleConfig? .outgoingChatBubble? .receiptsWidgetConfig? .receiptsBuilder
210
195
? .call (value) ??
211
196
sendMessageAnimationBuilder (value);
212
197
}
@@ -215,15 +200,10 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
215
200
);
216
201
} else if (showReceipts == ShowReceiptsIn .lastMessage && isLastMessage) {
217
202
return ValueListenableBuilder (
218
- valueListenable:
219
- chatController! .initialMessageList.last.statusNotifier,
203
+ valueListenable: chatController! .initialMessageList.last.statusNotifier,
220
204
builder: (context, value, child) {
221
- if (ChatViewInheritedWidget .of (context)
222
- ? .featureActiveConfig
223
- .receiptsBuilderVisibility ??
224
- true ) {
225
- return chatListConfig.chatBubbleConfig? .outgoingChatBubbleConfig
226
- ? .receiptsWidgetConfig? .receiptsBuilder
205
+ if (ChatViewInheritedWidget .of (context)? .featureActiveConfig.receiptsBuilderVisibility ?? true ) {
206
+ return chatListConfig.chatBubbleConfig? .outgoingChatBubble? .receiptsWidgetConfig? .receiptsBuilder
227
207
? .call (value) ??
228
208
sendMessageAnimationBuilder (value);
229
209
}
@@ -234,59 +214,48 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
234
214
}
235
215
236
216
void _onAvatarLongPress (ChatUser ? user) {
237
- if (chatListConfig.profileCircleConfig? .onAvatarLongPress != null &&
238
- user != null ) {
217
+ if (chatListConfig.profileCircleConfig? .onAvatarLongPress != null && user != null ) {
239
218
chatListConfig.profileCircleConfig? .onAvatarLongPress !(user);
240
219
}
241
220
}
242
221
243
222
Widget _messagesWidgetColumn (ChatUser ? messagedUser) {
244
223
return Column (
245
- crossAxisAlignment:
246
- isMessageBySender ? CrossAxisAlignment .end : CrossAxisAlignment .start,
224
+ crossAxisAlignment: isMessageBySender ? CrossAxisAlignment .end : CrossAxisAlignment .start,
247
225
children: [
248
226
if ((chatController? .otherUsers.isNotEmpty ?? false ) &&
249
227
! isMessageBySender &&
250
228
(featureActiveConfig? .enableOtherUserName ?? true ))
251
229
Padding (
252
- padding: chatListConfig
253
- .chatBubbleConfig? .inComingChatBubbleConfig? .padding ??
230
+ padding: chatListConfig.chatBubbleConfig? .incomingChatBubble? .padding ??
254
231
const EdgeInsets .symmetric (horizontal: 8 , vertical: 4 ),
255
232
child: Text (
256
233
messagedUser? .name ?? '' ,
257
- style: chatListConfig.chatBubbleConfig? .inComingChatBubbleConfig
258
- ? .senderNameTextStyle,
234
+ style: chatListConfig.chatBubbleConfig? .incomingChatBubble? .senderNameTextStyle,
259
235
),
260
236
),
261
237
if (replyMessage.isNotEmpty)
262
- chatListConfig.repliedMessageConfig? .repliedMessageWidgetBuilder !=
263
- null
264
- ? chatListConfig.repliedMessageConfig!
265
- .repliedMessageWidgetBuilder !(widget.message.replyMessage)
238
+ chatListConfig.repliedMessageConfig? .repliedMessageWidgetBuilder != null
239
+ ? chatListConfig.repliedMessageConfig! .repliedMessageWidgetBuilder !(widget.message.replyMessage)
266
240
: ReplyMessageWidget (
267
241
message: widget.message,
268
242
repliedMessageConfig: chatListConfig.repliedMessageConfig,
269
- onTap: () => widget.onReplyTap
270
- ? .call (widget.message.replyMessage.messageId),
243
+ onTap: () => widget.onReplyTap? .call (widget.message.replyMessage.messageId),
271
244
),
272
245
SwipeToReply (
273
246
isMessageByCurrentUser: isMessageBySender,
274
247
onSwipe: isMessageBySender ? onLeftSwipe : onRightSwipe,
275
248
child: MessageView (
276
- outgoingChatBubbleConfig:
277
- chatListConfig.chatBubbleConfig? .outgoingChatBubbleConfig,
278
- isLongPressEnable:
279
- (featureActiveConfig? .enableReactionPopup ?? true ) ||
280
- (featureActiveConfig? .enableReplySnackBar ?? true ),
281
- inComingChatBubbleConfig:
282
- chatListConfig.chatBubbleConfig? .inComingChatBubbleConfig,
249
+ outgoingChatBubble: chatListConfig.chatBubbleConfig? .outgoingChatBubble,
250
+ isLongPressEnable: (featureActiveConfig? .enableReactionPopup ?? true ) ||
251
+ (featureActiveConfig? .enableReplySnackBar ?? true ),
252
+ incomingChatBubble: chatListConfig.chatBubbleConfig? .incomingChatBubble,
283
253
message: widget.message,
284
254
isMessageBySender: isMessageBySender,
285
255
messageConfig: chatListConfig.messageConfig,
286
256
onLongPress: widget.onLongPress,
287
257
chatBubbleMaxWidth: chatListConfig.chatBubbleConfig? .maxWidth,
288
- longPressAnimationDuration:
289
- chatListConfig.chatBubbleConfig? .longPressAnimationDuration,
258
+ longPressAnimationDuration: chatListConfig.chatBubbleConfig? .longPressAnimationDuration,
290
259
onDoubleTap: featureActiveConfig? .enableDoubleTapToLike ?? false
291
260
? chatListConfig.chatBubbleConfig? .onDoubleTap ??
292
261
(message) => currentUser != null
@@ -299,12 +268,9 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
299
268
: null ,
300
269
shouldHighlight: widget.shouldHighlight,
301
270
controller: chatController,
302
- highlightColor: chatListConfig.repliedMessageConfig
303
- ? .repliedMsgAutoScrollConfig.highlightColor ??
304
- Colors .grey,
305
- highlightScale: chatListConfig.repliedMessageConfig
306
- ? .repliedMsgAutoScrollConfig.highlightScale ??
307
- 1.1 ,
271
+ highlightColor:
272
+ chatListConfig.repliedMessageConfig? .repliedMsgAutoScrollConfig.highlightColor ?? Colors .grey,
273
+ highlightScale: chatListConfig.repliedMessageConfig? .repliedMsgAutoScrollConfig.highlightScale ?? 1.1 ,
308
274
onMaxDuration: _onMaxDuration,
309
275
),
310
276
),
0 commit comments