Merge branch 'develop' of https://github.com/GetStream/stream-chat-flutter into feat/capabilities
Conflicts: packages/stream_chat/CHANGELOG.md packages/stream_chat_flutter/CHANGELOG.md
This commit is contained in:
@@ -97,14 +97,20 @@ class MessageWidget extends StatefulWidget {
|
||||
this.deletedBottomRowBuilder,
|
||||
this.onReturnAction,
|
||||
this.customAttachmentBuilders,
|
||||
this.readList,
|
||||
this.padding,
|
||||
this.textPadding = const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
this.attachmentPadding = EdgeInsets.zero,
|
||||
this.allRead = false,
|
||||
@Deprecated('''
|
||||
allRead is now deprecated and it will be removed in future releases.
|
||||
The MessageWidget now listens for read events on its own.
|
||||
''') this.allRead = false,
|
||||
@Deprecated('''
|
||||
readList is now deprecated and it will be removed in future releases.
|
||||
The MessageWidget now listens for read events on its own.
|
||||
''') this.readList,
|
||||
this.onQuotedMessageTap,
|
||||
this.customActions = const [],
|
||||
this.onAttachmentTap,
|
||||
@@ -508,7 +514,6 @@ class MessageWidget extends StatefulWidget {
|
||||
showUserAvatar: showUserAvatar ?? this.showUserAvatar,
|
||||
showSendingIndicator: showSendingIndicator ?? this.showSendingIndicator,
|
||||
showReactions: showReactions ?? this.showReactions,
|
||||
allRead: allRead ?? this.allRead,
|
||||
showThreadReplyIndicator:
|
||||
showThreadReplyIndicator ?? this.showThreadReplyIndicator,
|
||||
showInChannelIndicator:
|
||||
@@ -517,7 +522,6 @@ class MessageWidget extends StatefulWidget {
|
||||
onLinkTap: onLinkTap ?? this.onLinkTap,
|
||||
showReactionPickerIndicator:
|
||||
showReactionPickerIndicator ?? this.showReactionPickerIndicator,
|
||||
readList: readList ?? this.readList,
|
||||
onShowMessage: onShowMessage ?? this.onShowMessage,
|
||||
onReturnAction: onReturnAction ?? this.onReturnAction,
|
||||
showUsername: showUsername ?? this.showUsername,
|
||||
@@ -558,8 +562,6 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
|
||||
bool get showTimeStamp => widget.showTimestamp;
|
||||
|
||||
bool get isMessageRead => widget.readList?.isNotEmpty == true;
|
||||
|
||||
bool get showInChannel => widget.showInChannelIndicator;
|
||||
|
||||
bool get hasQuotedMessage => widget.message.quotedMessage != null;
|
||||
@@ -1223,6 +1225,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
Widget _buildSendingIndicator() {
|
||||
final style = widget.messageTheme.createdAtStyle;
|
||||
final message = widget.message;
|
||||
final memberCount = StreamChannel.of(context).channel.memberCount ?? 0;
|
||||
|
||||
if (hasNonUrlAttachments &&
|
||||
(message.status == MessageSendingStatus.sending ||
|
||||
@@ -1245,27 +1248,40 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
);
|
||||
}
|
||||
|
||||
Widget child = SendingIndicator(
|
||||
message: message,
|
||||
isMessageRead: isMessageRead,
|
||||
size: style!.fontSize,
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
|
||||
return BetterStreamBuilder<List<Read>>(
|
||||
stream: channel.state?.readStream,
|
||||
initialData: channel.state?.read,
|
||||
builder: (context, data) {
|
||||
final readList = data.where((it) =>
|
||||
it.user.id != _streamChat.currentUser?.id &&
|
||||
(it.lastRead.isAfter(message.createdAt) ||
|
||||
it.lastRead.isAtSameMomentAs(message.createdAt)));
|
||||
final isMessageRead = readList.length >= (channel.memberCount ?? 0) - 1;
|
||||
Widget child = SendingIndicator(
|
||||
message: message,
|
||||
isMessageRead: isMessageRead,
|
||||
size: style!.fontSize,
|
||||
);
|
||||
if (isMessageRead) {
|
||||
child = Row(
|
||||
children: [
|
||||
if (memberCount > 2)
|
||||
Text(
|
||||
readList.length.toString(),
|
||||
style: style.copyWith(
|
||||
color: _streamChatTheme.colorTheme.accentPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
return child;
|
||||
},
|
||||
);
|
||||
if (isMessageRead) {
|
||||
child = Row(
|
||||
children: [
|
||||
if (StreamChannel.of(context).channel.memberCount! > 2)
|
||||
Text(
|
||||
widget.readList!.length.toString(),
|
||||
style: style.copyWith(
|
||||
color: _streamChatTheme.colorTheme.accentPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
Widget _buildUserAvatar() => Transform.translate(
|
||||
|
||||
Reference in New Issue
Block a user