diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 782dd772..9b4cab61 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -329,7 +329,6 @@ class _ChannelListViewState extends State color: Theme.of(context).brightness == Brightness.dark ? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.1), - margin: EdgeInsets.symmetric(horizontal: 16), ); } diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index d9b69705..40c2ee8e 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -74,13 +74,29 @@ class ChannelPreview extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible(child: _buildSubtitle(context)), + Builder( + builder: (context) { + final lastMessage = channel.state.messages.last; + if (channel.state?.messages?.isNotEmpty == true && + lastMessage.user.id == StreamChat.of(context).user.id) { + return Padding( + padding: const EdgeInsets.only(right: 4.0), + child: SendingIndicator( + message: lastMessage, + allRead: channel.state.read + .where((element) => + element.lastRead.isAfter(lastMessage.createdAt)) + .length == + channel.memberCount - 1, + ), + ); + } + return SizedBox(); + }, + ), _buildDate(context), ], ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [], - ), ); } diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 121109c4..d976896b 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -426,10 +426,8 @@ class _MessageListViewState extends State { final isNextUser = index - 1 >= 0 && message.user.id == messages[index - 1]?.user?.id; - final readList = StreamChannel.of(context) - .channel - .state - .read + var channel = StreamChannel.of(context).channel; + final readList = channel.state.read .where((element) => element.user.id != userId) .where((read) => read.lastRead.isAfter(message.createdAt) && @@ -437,6 +435,8 @@ class _MessageListViewState extends State { read.lastRead.isBefore(messages[index - 1].createdAt))) .toList(); + final allRead = readList.length == channel.memberCount - 1; + return MessageWidget( message: message, reverse: isMyMessage, @@ -470,6 +470,7 @@ class _MessageListViewState extends State { ? StreamChatTheme.of(context).ownMessageTheme : StreamChatTheme.of(context).otherMessageTheme, readList: readList, + allRead: allRead, ); } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 752c1b23..a833bb95 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -91,6 +91,8 @@ class MessageWidget extends StatefulWidget { /// If true the widget will show the reactions final bool showReactions; + final bool allRead; + /// If true the widget will show the reply indicator final bool showReplyIndicator; @@ -136,6 +138,7 @@ class MessageWidget extends StatefulWidget { this.padding, this.textPadding = const EdgeInsets.all(8.0), this.attachmentPadding = EdgeInsets.zero, + this.allRead = false, }) : attachmentBuilders = { 'image': (context, message, attachment) { return ImageAttachment( @@ -203,9 +206,6 @@ class _MessageWidgetState extends State { var leftPadding = widget.showUserAvatar != DisplayWidget.gone ? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0 : 6.0; - if (widget.showSendingIndicator == DisplayWidget.gone) { - leftPadding -= 7; - } return Portal( child: Padding( padding: widget.padding ?? EdgeInsets.all(8), @@ -614,11 +614,15 @@ class _MessageWidgetState extends State { } Widget _buildSendingIndicator() { - return Transform( - transform: Matrix4.rotationY(widget.reverse ? pi : 0), - alignment: Alignment.center, - child: SendingIndicator( - message: widget.message, + return Padding( + padding: const EdgeInsets.only(right: 4.0), + child: Transform( + transform: Matrix4.rotationY(widget.reverse ? pi : 0), + alignment: Alignment.center, + child: SendingIndicator( + message: widget.message, + allRead: widget.allRead, + ), ), ); } diff --git a/lib/src/sending_indicator.dart b/lib/src/sending_indicator.dart index b51f07ae..f92686c7 100644 --- a/lib/src/sending_indicator.dart +++ b/lib/src/sending_indicator.dart @@ -4,14 +4,22 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Used to show the sending status of the message class SendingIndicator extends StatelessWidget { final Message message; + final bool allRead; const SendingIndicator({ Key key, this.message, + this.allRead = false, }) : super(key: key); @override Widget build(BuildContext context) { + if (allRead) { + return Icon( + Icons.done_all, + size: 8, + ); + } if (message.status == MessageSendingStatus.SENT || message.status == null) { return Icon( Icons.done,