@@ -3,14 +3,14 @@ import 'package:flutter/material.dart';
3
3
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
4
4
import 'package:visibility_detector/visibility_detector.dart' ;
5
5
6
- import '../models/bubble_rtl_alignment.dart' ;
7
- import '../models/emoji_enlargement_behavior.dart' ;
8
- import '../models/preview_tap_options.dart' ;
9
- import '../util.dart' ;
6
+ import '../../models/bubble_rtl_alignment.dart' ;
7
+ import '../../models/emoji_enlargement_behavior.dart' ;
8
+ import '../../util.dart' ;
9
+ import '../state/inherited_chat_theme.dart' ;
10
+ import '../state/inherited_user.dart' ;
10
11
import 'file_message.dart' ;
11
12
import 'image_message.dart' ;
12
- import 'inherited_chat_theme.dart' ;
13
- import 'inherited_user.dart' ;
13
+ import 'message_status.dart' ;
14
14
import 'text_message.dart' ;
15
15
import 'user_avatar.dart' ;
16
16
@@ -42,7 +42,6 @@ class Message extends StatelessWidget {
42
42
this .onMessageTap,
43
43
this .onMessageVisibilityChanged,
44
44
this .onPreviewDataFetched,
45
- required this .previewTapOptions,
46
45
required this .roundBorder,
47
46
required this .showAvatar,
48
47
required this .showName,
@@ -135,9 +134,6 @@ class Message extends StatelessWidget {
135
134
final void Function (types.TextMessage , types.PreviewData )?
136
135
onPreviewDataFetched;
137
136
138
- /// See [TextMessage.previewTapOptions] .
139
- final PreviewTapOptions previewTapOptions;
140
-
141
137
/// Rounds border of the message to visually group messages together.
142
138
final bool roundBorder;
143
139
@@ -186,11 +182,7 @@ class Message extends StatelessWidget {
186
182
final borderRadius = bubbleRtlAlignment == BubbleRtlAlignment .left
187
183
? BorderRadiusDirectional .only (
188
184
bottomEnd: Radius .circular (
189
- currentUserIsAuthor
190
- ? roundBorder
191
- ? messageBorderRadius
192
- : 0
193
- : messageBorderRadius,
185
+ ! currentUserIsAuthor || roundBorder ? messageBorderRadius : 0 ,
194
186
),
195
187
bottomStart: Radius .circular (
196
188
currentUserIsAuthor || roundBorder ? messageBorderRadius : 0 ,
@@ -203,11 +195,7 @@ class Message extends StatelessWidget {
203
195
currentUserIsAuthor || roundBorder ? messageBorderRadius : 0 ,
204
196
),
205
197
bottomRight: Radius .circular (
206
- currentUserIsAuthor
207
- ? roundBorder
208
- ? messageBorderRadius
209
- : 0
210
- : messageBorderRadius,
198
+ ! currentUserIsAuthor || roundBorder ? messageBorderRadius : 0 ,
211
199
),
212
200
topLeft: Radius .circular (messageBorderRadius),
213
201
topRight: Radius .circular (messageBorderRadius),
@@ -286,7 +274,7 @@ class Message extends StatelessWidget {
286
274
onTap: () => onMessageStatusTap? .call (context, message),
287
275
child: customStatusBuilder != null
288
276
? customStatusBuilder !(message, context: context)
289
- : _statusBuilder (context ),
277
+ : MessageStatus (status : message.status ),
290
278
)
291
279
: null ,
292
280
),
@@ -365,7 +353,6 @@ class Message extends StatelessWidget {
365
353
nameBuilder: nameBuilder,
366
354
onPreviewDataFetched: onPreviewDataFetched,
367
355
options: textMessageOptions,
368
- previewTapOptions: previewTapOptions,
369
356
showName: showName,
370
357
usePreviewData: usePreviewData,
371
358
userAgent: userAgent,
@@ -374,52 +361,4 @@ class Message extends StatelessWidget {
374
361
return const SizedBox ();
375
362
}
376
363
}
377
-
378
- Widget _statusBuilder (BuildContext context) {
379
- switch (message.status) {
380
- case types.Status .delivered:
381
- case types.Status .sent:
382
- return InheritedChatTheme .of (context).theme.deliveredIcon != null
383
- ? InheritedChatTheme .of (context).theme.deliveredIcon!
384
- : Image .asset (
385
- 'assets/icon-delivered.png' ,
386
- color: InheritedChatTheme .of (context).theme.primaryColor,
387
- package: 'flutter_chat_ui' ,
388
- );
389
- case types.Status .error:
390
- return InheritedChatTheme .of (context).theme.errorIcon != null
391
- ? InheritedChatTheme .of (context).theme.errorIcon!
392
- : Image .asset (
393
- 'assets/icon-error.png' ,
394
- color: InheritedChatTheme .of (context).theme.errorColor,
395
- package: 'flutter_chat_ui' ,
396
- );
397
- case types.Status .seen:
398
- return InheritedChatTheme .of (context).theme.seenIcon != null
399
- ? InheritedChatTheme .of (context).theme.seenIcon!
400
- : Image .asset (
401
- 'assets/icon-seen.png' ,
402
- color: InheritedChatTheme .of (context).theme.primaryColor,
403
- package: 'flutter_chat_ui' ,
404
- );
405
- case types.Status .sending:
406
- return InheritedChatTheme .of (context).theme.sendingIcon != null
407
- ? InheritedChatTheme .of (context).theme.sendingIcon!
408
- : Center (
409
- child: SizedBox (
410
- height: 10 ,
411
- width: 10 ,
412
- child: CircularProgressIndicator (
413
- backgroundColor: Colors .transparent,
414
- strokeWidth: 1.5 ,
415
- valueColor: AlwaysStoppedAnimation <Color >(
416
- InheritedChatTheme .of (context).theme.primaryColor,
417
- ),
418
- ),
419
- ),
420
- );
421
- default :
422
- return const SizedBox (width: 8 );
423
- }
424
- }
425
364
}
0 commit comments