Using only SendingIndicatorBuilder (rename from SendingIndicatorWrapper)
This commit is contained in:
@@ -302,12 +302,13 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
it.type == 'giphy')
|
it.type == 'giphy')
|
||||||
.isNotEmpty;
|
.isNotEmpty;
|
||||||
|
|
||||||
return SendingIndicatorWrapper(
|
return SendingIndicatorBuilder(
|
||||||
messageTheme: streamChatTheme.ownMessageTheme,
|
messageTheme: streamChatTheme.ownMessageTheme,
|
||||||
message: lastMessage,
|
message: lastMessage,
|
||||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||||
streamChat: streamChatState,
|
streamChat: streamChatState,
|
||||||
streamChatTheme: streamChatTheme,
|
streamChatTheme: streamChatTheme,
|
||||||
|
channel: channel,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class BottomRow extends StatelessWidget {
|
|||||||
if (showSendingIndicator)
|
if (showSendingIndicator)
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
child: sendingIndicatorBuilder?.call(context, message) ??
|
child: sendingIndicatorBuilder?.call(context, message) ??
|
||||||
SendingIndicatorWrapper(
|
SendingIndicatorBuilder(
|
||||||
messageTheme: messageTheme,
|
messageTheme: messageTheme,
|
||||||
message: message,
|
message: message,
|
||||||
hasNonUrlAttachments: hasNonUrlAttachments,
|
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// Used in [BottomRow]. Should not be used elsewhere.
|
/// Used in [BottomRow]. Should not be used elsewhere.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class SendingIndicatorWrapper extends StatelessWidget {
|
class SendingIndicatorBuilder extends StatelessWidget {
|
||||||
/// {@macro sendingIndicatorWrapper}
|
/// {@macro sendingIndicatorWrapper}
|
||||||
const SendingIndicatorWrapper({
|
const SendingIndicatorBuilder({
|
||||||
super.key,
|
super.key,
|
||||||
required this.messageTheme,
|
required this.messageTheme,
|
||||||
required this.message,
|
required this.message,
|
||||||
required this.hasNonUrlAttachments,
|
required this.hasNonUrlAttachments,
|
||||||
required this.streamChat,
|
required this.streamChat,
|
||||||
required this.streamChatTheme,
|
required this.streamChatTheme,
|
||||||
|
this.channel,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// {@macro messageTheme}
|
/// {@macro messageTheme}
|
||||||
@@ -32,10 +33,13 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
|||||||
/// {@macro streamChatThemeData}
|
/// {@macro streamChatThemeData}
|
||||||
final StreamChatThemeData streamChatTheme;
|
final StreamChatThemeData streamChatTheme;
|
||||||
|
|
||||||
|
final Channel? channel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final style = messageTheme.createdAtStyle;
|
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 &&
|
if (hasNonUrlAttachments &&
|
||||||
(message.status == MessageSendingStatus.sending ||
|
(message.status == MessageSendingStatus.sending ||
|
||||||
@@ -58,11 +62,9 @@ class SendingIndicatorWrapper extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final channel = StreamChannel.of(context).channel;
|
|
||||||
|
|
||||||
return BetterStreamBuilder<List<Read>>(
|
return BetterStreamBuilder<List<Read>>(
|
||||||
stream: channel.state?.readStream,
|
stream: thisChannel.state?.readStream,
|
||||||
initialData: channel.state?.read,
|
initialData: thisChannel.state?.read,
|
||||||
builder: (context, data) {
|
builder: (context, data) {
|
||||||
final readList = data.where((it) =>
|
final readList = data.where((it) =>
|
||||||
it.user.id != streamChat.currentUser?.id &&
|
it.user.id != streamChat.currentUser?.id &&
|
||||||
|
|||||||
+13
-3
@@ -1,5 +1,6 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.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';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
/// A widget that displays a channel preview.
|
/// A widget that displays a channel preview.
|
||||||
@@ -145,6 +146,8 @@ class StreamChannelListTile extends StatelessWidget {
|
|||||||
final currentUser = channel.client.state.currentUser!;
|
final currentUser = channel.client.state.currentUser!;
|
||||||
|
|
||||||
final channelPreviewTheme = StreamChannelPreviewTheme.of(context);
|
final channelPreviewTheme = StreamChannelPreviewTheme.of(context);
|
||||||
|
final streamChatTheme = StreamChatTheme.of(context);
|
||||||
|
final streamChat = StreamChat.of(context);
|
||||||
|
|
||||||
final leading = this.leading ??
|
final leading = this.leading ??
|
||||||
StreamChannelAvatar(
|
StreamChannelAvatar(
|
||||||
@@ -234,14 +237,21 @@ class StreamChannelListTile extends StatelessWidget {
|
|||||||
readData.lastRead
|
readData.lastRead
|
||||||
.isAtSameMomentAs(lastMessage.createdAt));
|
.isAtSameMomentAs(lastMessage.createdAt));
|
||||||
|
|
||||||
|
final hasNonUrlAttachments = lastMessage.attachments
|
||||||
|
.where((it) => it.titleLink == null || it.type == 'giphy')
|
||||||
|
.isNotEmpty;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 4),
|
padding: const EdgeInsets.only(right: 4),
|
||||||
child:
|
child:
|
||||||
sendingIndicatorBuilder?.call(context, lastMessage) ??
|
sendingIndicatorBuilder?.call(context, lastMessage) ??
|
||||||
StreamSendingIndicator(
|
SendingIndicatorBuilder(
|
||||||
|
messageTheme: streamChatTheme.ownMessageTheme,
|
||||||
message: lastMessage,
|
message: lastMessage,
|
||||||
size: channelPreviewTheme.indicatorIconSize,
|
hasNonUrlAttachments: hasNonUrlAttachments,
|
||||||
isMessageRead: isLastMessageRead,
|
streamChat: streamChat,
|
||||||
|
streamChatTheme: streamChatTheme,
|
||||||
|
channel: channel,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user