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