|
1 | 1 | import 'dart:io'; |
2 | 2 |
|
3 | 3 | import 'package:flutter/material.dart'; |
4 | | -import 'package:flutter_riverpod/flutter_riverpod.dart'; |
5 | 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
6 | 5 | import 'package:gap/gap.dart'; |
7 | 6 |
|
8 | | -import 'package:whitenoise/config/providers/localization_provider.dart'; |
9 | 7 | import 'package:whitenoise/config/states/chat_search_state.dart'; |
10 | 8 | import 'package:whitenoise/domain/models/message_model.dart'; |
11 | 9 | import 'package:whitenoise/ui/chat/widgets/chat_bubble/bubble.dart'; |
12 | 10 | import 'package:whitenoise/ui/chat/widgets/media_modal.dart'; |
13 | 11 | import 'package:whitenoise/ui/chat/widgets/message_media_grid.dart'; |
14 | | -import 'package:whitenoise/ui/chat/widgets/message_media_tile.dart'; |
| 12 | +import 'package:whitenoise/ui/chat/widgets/message_reply_box.dart'; |
15 | 13 | import 'package:whitenoise/ui/core/themes/src/extensions.dart'; |
16 | 14 | import 'package:whitenoise/ui/core/ui/wn_avatar.dart'; |
17 | 15 | import 'package:whitenoise/ui/core/ui/wn_image.dart'; |
18 | | -import 'package:whitenoise/utils/message_utils.dart'; |
19 | 16 |
|
20 | 17 | class MessageWidget extends StatelessWidget { |
21 | 18 | final MessageModel message; |
@@ -132,7 +129,7 @@ class MessageWidget extends StatelessWidget { |
132 | 129 | ), |
133 | 130 | Gap(4.h), |
134 | 131 | ], |
135 | | - ReplyBox( |
| 132 | + MessageReplyBox( |
136 | 133 | replyingTo: message.replyTo, |
137 | 134 | onTap: |
138 | 135 | message.replyTo != null ? () => onReplyTap?.call(message.replyTo!.id) : null, |
@@ -481,79 +478,3 @@ class TimeAndStatus extends StatelessWidget { |
481 | 478 | ); |
482 | 479 | } |
483 | 480 | } |
484 | | - |
485 | | -class ReplyBox extends ConsumerWidget { |
486 | | - const ReplyBox({super.key, this.replyingTo, this.onTap}); |
487 | | - final MessageModel? replyingTo; |
488 | | - final VoidCallback? onTap; |
489 | | - |
490 | | - @override |
491 | | - Widget build(BuildContext context, WidgetRef ref) { |
492 | | - // Watch localization changes |
493 | | - ref.watch(currentLocaleProvider); |
494 | | - if (replyingTo == null) { |
495 | | - return const SizedBox.shrink(); |
496 | | - } |
497 | | - return Container( |
498 | | - margin: EdgeInsets.only(bottom: 8.h), |
499 | | - child: Material( |
500 | | - color: context.colors.secondary, |
501 | | - child: InkWell( |
502 | | - onTap: onTap, |
503 | | - child: Container( |
504 | | - padding: EdgeInsets.all(8.w), |
505 | | - decoration: BoxDecoration( |
506 | | - border: Border( |
507 | | - left: BorderSide( |
508 | | - color: context.colors.mutedForeground, |
509 | | - width: 3.0, |
510 | | - ), |
511 | | - ), |
512 | | - ), |
513 | | - child: Row( |
514 | | - children: [ |
515 | | - if (replyingTo?.mediaAttachments.isNotEmpty ?? false) ...[ |
516 | | - Padding( |
517 | | - padding: EdgeInsets.only(right: 8.w), |
518 | | - child: MessageMediaTile( |
519 | | - mediaFile: replyingTo!.mediaAttachments.first, |
520 | | - size: 32.w, |
521 | | - ), |
522 | | - ), |
523 | | - ], |
524 | | - Expanded( |
525 | | - child: Column( |
526 | | - crossAxisAlignment: CrossAxisAlignment.stretch, |
527 | | - children: [ |
528 | | - Text( |
529 | | - MessageUtils.getDisplayName(replyingTo, null), |
530 | | - style: TextStyle( |
531 | | - color: context.colors.mutedForeground, |
532 | | - fontSize: 12.sp, |
533 | | - fontWeight: FontWeight.w600, |
534 | | - ), |
535 | | - maxLines: 1, |
536 | | - overflow: TextOverflow.ellipsis, |
537 | | - ), |
538 | | - Gap(4.h), |
539 | | - Text( |
540 | | - replyingTo?.content ?? '', |
541 | | - style: TextStyle( |
542 | | - color: context.colors.primary, |
543 | | - fontSize: 12.sp, |
544 | | - fontWeight: FontWeight.w600, |
545 | | - ), |
546 | | - maxLines: 1, |
547 | | - overflow: TextOverflow.ellipsis, |
548 | | - ), |
549 | | - ], |
550 | | - ), |
551 | | - ), |
552 | | - ], |
553 | | - ), |
554 | | - ), |
555 | | - ), |
556 | | - ), |
557 | | - ); |
558 | | - } |
559 | | -} |
0 commit comments