Using only SendingIndicatorBuilder (rename from SendingIndicatorWrapper)
This commit is contained in:
@@ -302,12 +302,13 @@ class ChannelPreview extends StatelessWidget {
|
||||
it.type == 'giphy')
|
||||
.isNotEmpty;
|
||||
|
||||
return SendingIndicatorWrapper(
|
||||
return SendingIndicatorBuilder(
|
||||
messageTheme: streamChatTheme.ownMessageTheme,
|
||||
message: lastMessage,
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
streamChat: streamChatState,
|
||||
streamChatTheme: streamChatTheme,
|
||||
channel: channel,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -204,7 +204,7 @@ class BottomRow extends StatelessWidget {
|
||||
if (showSendingIndicator)
|
||||
WidgetSpan(
|
||||
child: sendingIndicatorBuilder?.call(context, message) ??
|
||||
SendingIndicatorWrapper(
|
||||
SendingIndicatorBuilder(
|
||||
messageTheme: messageTheme,
|
||||
message: message,
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
|
||||
@@ -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,13 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
/// {@macro streamChatThemeData}
|
||||
final StreamChatThemeData streamChatTheme;
|
||||
|
||||
final Channel? channel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = messageTheme.createdAtStyle;
|
||||
final memberCount = StreamChannel.of(context).channel.memberCount ?? 0;
|
||||
final thisChannel = channel ?? StreamChannel.of(context).channel;
|
||||
final memberCount = thisChannel.memberCount ?? 0;
|
||||
|
||||
if (hasNonUrlAttachments &&
|
||||
(message.status == MessageSendingStatus.sending ||
|
||||
@@ -58,11 +62,9 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
|
||||
return BetterStreamBuilder<List<Read>>(
|
||||
stream: channel.state?.readStream,
|
||||
initialData: channel.state?.read,
|
||||
stream: thisChannel.state?.readStream,
|
||||
initialData: thisChannel.state?.read,
|
||||
builder: (context, data) {
|
||||
final readList = data.where((it) =>
|
||||
it.user.id != streamChat.currentUser?.id &&
|
||||
|
||||
+13
-3
@@ -1,5 +1,6 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.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(
|
||||
@@ -234,14 +237,21 @@ class StreamChannelListTile extends StatelessWidget {
|
||||
readData.lastRead
|
||||
.isAtSameMomentAs(lastMessage.createdAt));
|
||||
|
||||
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: isLastMessageRead,
|
||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||
streamChat: streamChat,
|
||||
streamChatTheme: streamChatTheme,
|
||||
channel: channel,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user