Merge pull request #1461 from GetStream/ISSUE-1456/SendingMessageIndicatorFix
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
- [#1456](https://github.com/GetStream/stream-chat-flutter/issues/1456) Fixed logic for showing that a message was read using sending indicator.
|
||||
- [#1462](https://github.com/GetStream/stream-chat-flutter/issues/1462) Fixed support for iPad in the share button for images.
|
||||
- [#1475](https://github.com/GetStream/stream-chat-flutter/issues/1475) Fixed typo to fix compilation.
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:contextmenu/contextmenu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart';
|
||||
import 'package:stream_chat_flutter/src/dialogs/dialogs.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
/// {@template channelPreview}
|
||||
@@ -76,6 +77,7 @@ class ChannelPreview extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final channelPreviewTheme = StreamChannelPreviewTheme.of(context);
|
||||
final streamChatState = StreamChat.of(context);
|
||||
final streamChatTheme = StreamChatTheme.of(context);
|
||||
return BetterStreamBuilder<bool>(
|
||||
stream: channel.isMutedStream,
|
||||
initialData: channel.isMuted,
|
||||
@@ -292,20 +294,20 @@ class ChannelPreview extends StatelessWidget {
|
||||
stream: channel.state?.readStream,
|
||||
initialData: channel.state?.read,
|
||||
builder: (context, data) {
|
||||
final readList = data.where((it) =>
|
||||
it.user.id !=
|
||||
channel.client.state.currentUser?.id &&
|
||||
(it.lastRead
|
||||
.isAfter(lastMessage!.createdAt) ||
|
||||
it.lastRead.isAtSameMomentAs(
|
||||
lastMessage.createdAt,
|
||||
)));
|
||||
final isMessageRead = readList.length >=
|
||||
(channel.memberCount ?? 0) - 1;
|
||||
return StreamSendingIndicator(
|
||||
message: lastMessage!,
|
||||
size: channelPreviewTheme.indicatorIconSize,
|
||||
isMessageRead: isMessageRead,
|
||||
final hasNonUrlAttachments = lastMessage!
|
||||
.attachments
|
||||
.where((it) =>
|
||||
it.titleLink == null ||
|
||||
it.type == 'giphy')
|
||||
.isNotEmpty;
|
||||
|
||||
return SendingIndicatorBuilder(
|
||||
messageTheme: streamChatTheme.ownMessageTheme,
|
||||
message: lastMessage,
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
streamChat: streamChatState,
|
||||
streamChatTheme: streamChatTheme,
|
||||
channel: channel,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/thread_painter.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/thread_participants.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/username.dart';
|
||||
@@ -204,7 +204,7 @@ class BottomRow extends StatelessWidget {
|
||||
if (showSendingIndicator)
|
||||
WidgetSpan(
|
||||
child: sendingIndicatorBuilder?.call(context, message) ??
|
||||
SendingIndicatorWrapper(
|
||||
SendingIndicatorBuilder(
|
||||
messageTheme: messageTheme,
|
||||
message: message,
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
|
||||
+12
-6
@@ -6,15 +6,16 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// Used in [BottomRow]. Should not be used elsewhere.
|
||||
/// {@endtemplate}
|
||||
class SendingIndicatorWrapper extends StatelessWidget {
|
||||
class SendingIndicatorBuilder extends StatelessWidget {
|
||||
/// {@macro sendingIndicatorWrapper}
|
||||
const SendingIndicatorWrapper({
|
||||
const SendingIndicatorBuilder({
|
||||
super.key,
|
||||
required this.messageTheme,
|
||||
required this.message,
|
||||
required this.hasNonUrlAttachments,
|
||||
required this.streamChat,
|
||||
required this.streamChatTheme,
|
||||
this.channel,
|
||||
});
|
||||
|
||||
/// {@macro messageTheme}
|
||||
@@ -32,10 +33,14 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
/// {@macro streamChatThemeData}
|
||||
final StreamChatThemeData streamChatTheme;
|
||||
|
||||
/// {@macro channel}
|
||||
final Channel? channel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = messageTheme.createdAtStyle;
|
||||
final memberCount = StreamChannel.of(context).channel.memberCount ?? 0;
|
||||
final channel = this.channel ?? StreamChannel.of(context).channel;
|
||||
final memberCount = channel.memberCount ?? 0;
|
||||
|
||||
if (hasNonUrlAttachments &&
|
||||
(message.status == MessageSendingStatus.sending ||
|
||||
@@ -58,8 +63,6 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
|
||||
return BetterStreamBuilder<List<Read>>(
|
||||
stream: channel.state?.readStream,
|
||||
initialData: channel.state?.read,
|
||||
@@ -68,12 +71,14 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
it.user.id != streamChat.currentUser?.id &&
|
||||
(it.lastRead.isAfter(message.createdAt) ||
|
||||
it.lastRead.isAtSameMomentAs(message.createdAt)));
|
||||
final isMessageRead = readList.length >= (channel.memberCount ?? 0) - 1;
|
||||
|
||||
final isMessageRead = readList.isNotEmpty;
|
||||
Widget child = StreamSendingIndicator(
|
||||
message: message,
|
||||
isMessageRead: isMessageRead,
|
||||
size: style!.fontSize,
|
||||
);
|
||||
|
||||
if (isMessageRead) {
|
||||
child = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -90,6 +95,7 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return child;
|
||||
},
|
||||
);
|
||||
+13
-5
@@ -1,5 +1,6 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
/// A widget that displays a channel preview.
|
||||
@@ -145,6 +146,8 @@ class StreamChannelListTile extends StatelessWidget {
|
||||
final currentUser = channel.client.state.currentUser!;
|
||||
|
||||
final channelPreviewTheme = StreamChannelPreviewTheme.of(context);
|
||||
final streamChatTheme = StreamChatTheme.of(context);
|
||||
final streamChat = StreamChat.of(context);
|
||||
|
||||
final leading = this.leading ??
|
||||
StreamChannelAvatar(
|
||||
@@ -225,16 +228,21 @@ class StreamChannelListTile extends StatelessWidget {
|
||||
return const Offstage();
|
||||
}
|
||||
|
||||
final hasNonUrlAttachments = lastMessage.attachments
|
||||
.where((it) => it.titleLink == null || it.type == 'giphy')
|
||||
.isNotEmpty;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 4),
|
||||
child:
|
||||
sendingIndicatorBuilder?.call(context, lastMessage) ??
|
||||
StreamSendingIndicator(
|
||||
SendingIndicatorBuilder(
|
||||
messageTheme: streamChatTheme.ownMessageTheme,
|
||||
message: lastMessage,
|
||||
size: channelPreviewTheme.indicatorIconSize,
|
||||
isMessageRead: channelState
|
||||
.currentUserRead!.lastRead
|
||||
.isAfter(lastMessage.createdAt),
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
streamChat: streamChat,
|
||||
streamChatTheme: streamChatTheme,
|
||||
channel: channel,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user