diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 41e4fa5d..90c9533b 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `MessageListView.paginationLimit` - Allow the various ListView widgets to be themed via ThemeData classes +- Added `bottomRowBuilder` and `deletedBottomRowBuilder` that build a widget below a `MessageWidget` 🔄 Changed diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index f14abffc..fd29724d 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; +import 'package:stream_chat_flutter/src/visible_footnote.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; @@ -216,36 +217,11 @@ class GiphyAttachment extends AttachmentWidget { ), ), const SizedBox(height: 4), - Align( + const Align( alignment: Alignment.centerRight, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - StreamSvgIcon.eye( - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis - .withOpacity(0.5), - size: 16, - ), - const SizedBox( - width: 8, - ), - Text( - 'Only visible to you', - style: StreamChatTheme.of(context) - .textTheme - .footnote - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis - .withOpacity(0.5)), - ), - ], - ), + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: VisibleFootnote(), ), ), ], diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index e73f3a6d..970ae9da 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -92,6 +92,8 @@ class MessageWidget extends StatefulWidget { this.userAvatarBuilder, this.editMessageInputBuilder, this.textBuilder, + this.bottomRowBuilder, + this.deletedBottomRowBuilder, this.onReturnAction, Map? customAttachmentBuilders, this.readList, @@ -275,6 +277,12 @@ class MessageWidget extends StatefulWidget { /// Function called on long press final void Function(BuildContext, Message)? onMessageActions; + /// Widget builder for building a bottom row below the message + final Widget Function(BuildContext, Message)? bottomRowBuilder; + + /// Widget builder for building a bottom row below a deleted message + final Widget Function(BuildContext, Message)? deletedBottomRowBuilder; + /// Widget builder for building user avatar final Widget Function(BuildContext, User)? userAvatarBuilder; @@ -410,6 +418,8 @@ class MessageWidget extends StatefulWidget { Widget Function(BuildContext, Message)? editMessageInputBuilder, Widget Function(BuildContext, Message)? textBuilder, Widget Function(BuildContext, Message)? usernameBuilder, + Widget Function(BuildContext, Message)? bottomRowBuilder, + Widget Function(BuildContext, Message)? deletedBottomRowBuilder, void Function(BuildContext, Message)? onMessageActions, Message? message, MessageTheme? messageTheme, @@ -463,6 +473,9 @@ class MessageWidget extends StatefulWidget { editMessageInputBuilder ?? this.editMessageInputBuilder, textBuilder: textBuilder ?? this.textBuilder, usernameBuilder: usernameBuilder ?? this.usernameBuilder, + bottomRowBuilder: bottomRowBuilder ?? this.bottomRowBuilder, + deletedBottomRowBuilder: + deletedBottomRowBuilder ?? this.deletedBottomRowBuilder, onMessageActions: onMessageActions ?? this.onMessageActions, message: message ?? this.message, messageTheme: messageTheme ?? this.messageTheme, @@ -782,7 +795,11 @@ class _MessageWidgetState extends State bottom: isPinned && widget.showPinHighlight ? 6.0 : 0.0, ), - child: _bottomRow, + child: widget.bottomRowBuilder?.call( + context, + widget.message, + ) ?? + _bottomRow, ), if (isFailedState) Positioned( @@ -830,22 +847,11 @@ class _MessageWidgetState extends State Widget get _bottomRow { if (isDeleted) { - final chatThemeData = _streamChatTheme; - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - StreamSvgIcon.eye( - color: chatThemeData.colorTheme.textLowEmphasis, - size: 16, - ), - const SizedBox(width: 8), - Text( - 'Only visible to you', - style: chatThemeData.textTheme.footnote - .copyWith(color: chatThemeData.colorTheme.textLowEmphasis), - ), - ], - ); + return widget.deletedBottomRowBuilder?.call( + context, + widget.message, + ) ?? + const Offstage(); } final children = []; diff --git a/packages/stream_chat_flutter/lib/src/visible_footnote.dart b/packages/stream_chat_flutter/lib/src/visible_footnote.dart new file mode 100644 index 00000000..bbdb9144 --- /dev/null +++ b/packages/stream_chat_flutter/lib/src/visible_footnote.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +/// Widget for displaying a footnote +class VisibleFootnote extends StatelessWidget { + /// Constructor for creating a [VisibleFootnote] + const VisibleFootnote({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final chatThemeData = StreamChatTheme.of(context); + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + StreamSvgIcon.eye( + color: chatThemeData.colorTheme.textLowEmphasis, + size: 16, + ), + const SizedBox(width: 8), + Text( + 'Only visible to you', + style: chatThemeData.textTheme.footnote + .copyWith(color: chatThemeData.colorTheme.textLowEmphasis), + ), + ], + ); + } +} diff --git a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart index 12049fc6..8c3a6f8e 100644 --- a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart +++ b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart @@ -42,3 +42,4 @@ export 'src/user_item.dart'; export 'src/user_list_view.dart'; export 'src/user_list_view.dart'; export 'src/utils.dart'; +export 'src/visible_footnote.dart'; diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index d2004079..7d990182 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,10 +1,12 @@ ## Upcoming +🛑️ Breaking Changes from `2.0.0` +- Changed default message filter of `MessageListCore` + ✅ Added - Added `MessageListCore.paginationLimit` 🔄 Changed - - `StreamChatCore.of(context).user` is now deprecated in favor of `StreamChatCore.of(context).currentUser`. - `StreamChatCore.of(context).userStream` is now deprecated in favor of `StreamChatCore.of(context).currentUserStream`. diff --git a/packages/stream_chat_flutter_core/lib/src/message_list_core.dart b/packages/stream_chat_flutter_core/lib/src/message_list_core.dart index 45051db1..d3d69dfb 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_list_core.dart @@ -134,8 +134,7 @@ class MessageListCoreState extends State { bool defaultFilter(Message m) { final isMyMessage = m.user?.id == _currentUser?.id; - final isDeletedOrShadowed = m.isDeleted == true || m.shadowed == true; - if (isDeletedOrShadowed && !isMyMessage) return false; + if (m.shadowed && !isMyMessage) return false; return true; }