fix review
This commit is contained in:
@@ -86,11 +86,11 @@ class ChannelImage extends StatelessWidget {
|
|||||||
return BetterStreamBuilder<Map<String, dynamic>>(
|
return BetterStreamBuilder<Map<String, dynamic>>(
|
||||||
stream: channel.extraDataStream,
|
stream: channel.extraDataStream,
|
||||||
initialData: channel.extraData,
|
initialData: channel.extraData,
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
String? image;
|
String? image;
|
||||||
final chatThemeData = StreamChatTheme.of(context);
|
final chatThemeData = StreamChatTheme.of(context);
|
||||||
if (snapshot.containsKey('image') == true) {
|
if (data.containsKey('image') == true) {
|
||||||
image = snapshot['image'];
|
image = data['image'];
|
||||||
} else if (channel.state?.members.length == 2) {
|
} else if (channel.state?.members.length == 2) {
|
||||||
final otherMember = channel.state?.members
|
final otherMember = channel.state?.members
|
||||||
.firstWhere((member) => member.user?.id != streamChat.user?.id);
|
.firstWhere((member) => member.user?.id != streamChat.user?.id);
|
||||||
@@ -100,11 +100,11 @@ class ChannelImage extends StatelessWidget {
|
|||||||
users[otherMember?.userId] ?? otherMember!.user!)
|
users[otherMember?.userId] ?? otherMember!.user!)
|
||||||
.distinct(),
|
.distinct(),
|
||||||
initialData: otherMember!.user,
|
initialData: otherMember!.user,
|
||||||
builder: (context, snapshot) => UserAvatar(
|
builder: (context, user) => UserAvatar(
|
||||||
borderRadius: borderRadius ??
|
borderRadius: borderRadius ??
|
||||||
chatThemeData
|
chatThemeData
|
||||||
.channelPreviewTheme.avatarTheme?.borderRadius,
|
.channelPreviewTheme.avatarTheme?.borderRadius,
|
||||||
user: snapshot ?? otherMember.user!,
|
user: user ?? otherMember.user!,
|
||||||
constraints: constraints ??
|
constraints: constraints ??
|
||||||
chatThemeData
|
chatThemeData
|
||||||
.channelPreviewTheme.avatarTheme?.constraints,
|
.channelPreviewTheme.avatarTheme?.constraints,
|
||||||
@@ -155,7 +155,7 @@ class ChannelImage extends StatelessWidget {
|
|||||||
imageUrl: image,
|
imageUrl: image,
|
||||||
errorWidget: (_, __, ___) => Center(
|
errorWidget: (_, __, ___) => Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
snapshot.containsKey('name') ? snapshot['name'][0] : '',
|
data.containsKey('name') ? data['name'][0] : '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: chatThemeData.colorTheme.white,
|
color: chatThemeData.colorTheme.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ class ChannelInfo extends StatelessWidget {
|
|||||||
return BetterStreamBuilder<List<Member>>(
|
return BetterStreamBuilder<List<Member>>(
|
||||||
stream: channel.state!.membersStream,
|
stream: channel.state!.membersStream,
|
||||||
initialData: channel.state!.members,
|
initialData: channel.state!.members,
|
||||||
builder: (context, snapshot) => ConnectionStatusBuilder(
|
builder: (context, data) => ConnectionStatusBuilder(
|
||||||
statusBuilder: (context, status) {
|
statusBuilder: (context, status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case ConnectionStatus.connected:
|
case ConnectionStatus.connected:
|
||||||
return _buildConnectedTitleState(context, snapshot);
|
return _buildConnectedTitleState(context, data);
|
||||||
case ConnectionStatus.connecting:
|
case ConnectionStatus.connecting:
|
||||||
return _buildConnectingTitleState(context);
|
return _buildConnectingTitleState(context);
|
||||||
case ConnectionStatus.disconnected:
|
case ConnectionStatus.disconnected:
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
builder: (context, snapshot) => snapshot
|
builder: (context, data) => data
|
||||||
? const Center(
|
? const Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ class ChannelName extends StatelessWidget {
|
|||||||
return BetterStreamBuilder<Map<String, Object?>>(
|
return BetterStreamBuilder<Map<String, Object?>>(
|
||||||
stream: channel.extraDataStream,
|
stream: channel.extraDataStream,
|
||||||
initialData: channel.extraData,
|
initialData: channel.extraData,
|
||||||
builder: (context, snapshot) => _buildName(
|
builder: (context, data) => _buildName(
|
||||||
snapshot,
|
data,
|
||||||
channel.state?.members,
|
channel.state?.members,
|
||||||
client,
|
client,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
return BetterStreamBuilder<bool>(
|
return BetterStreamBuilder<bool>(
|
||||||
stream: channel.isMutedStream,
|
stream: channel.isMutedStream,
|
||||||
initialData: channel.isMuted,
|
initialData: channel.isMuted,
|
||||||
builder: (context, snapshot) => AnimatedOpacity(
|
builder: (context, data) => AnimatedOpacity(
|
||||||
opacity: snapshot ? 0.5 : 1,
|
opacity: data ? 0.5 : 1,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
@@ -108,9 +108,9 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
stream: channel.state?.membersStream,
|
stream: channel.state?.membersStream,
|
||||||
initialData: channel.state?.members,
|
initialData: channel.state?.members,
|
||||||
comparator: const ListEquality().equals,
|
comparator: const ListEquality().equals,
|
||||||
builder: (context, snapshot) {
|
builder: (context, members) {
|
||||||
if (snapshot?.isEmpty == true ||
|
if (members?.isEmpty == true ||
|
||||||
snapshot?.any((Member e) =>
|
members?.any((Member e) =>
|
||||||
e.user!.id ==
|
e.user!.id ==
|
||||||
channel.client.state.user?.id) !=
|
channel.client.state.user?.id) !=
|
||||||
true) {
|
true) {
|
||||||
@@ -165,11 +165,11 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
Widget _buildDate(BuildContext context) => BetterStreamBuilder<DateTime?>(
|
Widget _buildDate(BuildContext context) => BetterStreamBuilder<DateTime?>(
|
||||||
stream: channel.lastMessageAtStream,
|
stream: channel.lastMessageAtStream,
|
||||||
initialData: channel.lastMessageAt,
|
initialData: channel.lastMessageAt,
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
if (snapshot == null) {
|
if (data == null) {
|
||||||
return const Offstage();
|
return const Offstage();
|
||||||
}
|
}
|
||||||
final lastMessageAt = snapshot.toLocal();
|
final lastMessageAt = data.toLocal();
|
||||||
|
|
||||||
String stringDate;
|
String stringDate;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
@@ -225,9 +225,9 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
BetterStreamBuilder<List<Message>?>(
|
BetterStreamBuilder<List<Message>?>(
|
||||||
stream: channel.state!.messagesStream,
|
stream: channel.state!.messagesStream,
|
||||||
initialData: channel.state!.messages,
|
initialData: channel.state!.messages,
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
final lastMessage = snapshot
|
final lastMessage =
|
||||||
?.lastWhereOrNull((m) => m.shadowed != true && !m.isDeleted);
|
data?.lastWhereOrNull((m) => m.shadowed != true && !m.isDeleted);
|
||||||
if (lastMessage == null) {
|
if (lastMessage == null) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||||
@@ -8,20 +7,16 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
|||||||
///
|
///
|
||||||
/// The widget will use the closest [StreamChatClient.wsConnectionStatusStream]
|
/// The widget will use the closest [StreamChatClient.wsConnectionStatusStream]
|
||||||
/// in case no stream is provided.
|
/// in case no stream is provided.
|
||||||
class ConnectionStatusBuilder extends StatefulWidget {
|
class ConnectionStatusBuilder extends StatelessWidget {
|
||||||
/// Creates a new ConnectionStatusBuilder
|
/// Creates a new ConnectionStatusBuilder
|
||||||
const ConnectionStatusBuilder({
|
const ConnectionStatusBuilder({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.statusBuilder,
|
required this.statusBuilder,
|
||||||
this.initialStatus,
|
|
||||||
this.connectionStatusStream,
|
this.connectionStatusStream,
|
||||||
this.errorBuilder,
|
this.errorBuilder,
|
||||||
this.loadingBuilder,
|
this.loadingBuilder,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The connection status that will be used to create the initial snapshot.
|
|
||||||
final ConnectionStatus? initialStatus;
|
|
||||||
|
|
||||||
/// The asynchronous computation to which this builder is currently connected.
|
/// The asynchronous computation to which this builder is currently connected.
|
||||||
final Stream<ConnectionStatus>? connectionStatusStream;
|
final Stream<ConnectionStatus>? connectionStatusStream;
|
||||||
|
|
||||||
@@ -36,32 +31,21 @@ class ConnectionStatusBuilder extends StatefulWidget {
|
|||||||
statusBuilder;
|
statusBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ConnectionStatusBuilderState createState() =>
|
Widget build(BuildContext context) {
|
||||||
_ConnectionStatusBuilderState();
|
final stream = connectionStatusStream ??
|
||||||
}
|
StreamChat.of(context).client.wsConnectionStatusStream;
|
||||||
|
final client = StreamChat.of(context).client;
|
||||||
class _ConnectionStatusBuilderState extends State<ConnectionStatusBuilder> {
|
return BetterStreamBuilder<ConnectionStatus>(
|
||||||
late StreamChatClient client;
|
initialData: client.wsConnectionStatus,
|
||||||
late Stream<ConnectionStatus> stream;
|
stream: stream,
|
||||||
|
loadingBuilder: loadingBuilder,
|
||||||
@override
|
errorBuilder: (context, error) {
|
||||||
Widget build(BuildContext context) => BetterStreamBuilder<ConnectionStatus>(
|
if (errorBuilder != null) {
|
||||||
initialData: widget.initialStatus ?? client.wsConnectionStatus,
|
return errorBuilder!(context, error);
|
||||||
stream: stream,
|
}
|
||||||
loadingBuilder: widget.loadingBuilder,
|
return const Offstage();
|
||||||
errorBuilder: (context, error) {
|
},
|
||||||
if (widget.errorBuilder != null) {
|
builder: statusBuilder,
|
||||||
return widget.errorBuilder!(context, error);
|
);
|
||||||
}
|
|
||||||
return const Offstage();
|
|
||||||
},
|
|
||||||
builder: widget.statusBuilder,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
client = StreamChat.of(context).client;
|
|
||||||
stream = widget.connectionStatusStream ?? client.wsConnectionStatusStream;
|
|
||||||
super.didChangeDependencies();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ class InfoTile extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final chatThemeData = StreamChatTheme.of(context);
|
final chatThemeData = StreamChatTheme.of(context);
|
||||||
if (!showMessage) {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
return PortalEntry(
|
return PortalEntry(
|
||||||
visible: showMessage,
|
visible: showMessage,
|
||||||
portalAnchor: tileAnchor ?? Alignment.topCenter,
|
portalAnchor: tileAnchor ?? Alignment.topCenter,
|
||||||
|
|||||||
@@ -1170,9 +1170,9 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
(messages) =>
|
(messages) =>
|
||||||
messages!.firstWhere((m) => m.id == message.id)),
|
messages!.firstWhere((m) => m.id == message.id)),
|
||||||
initialData: message,
|
initialData: message,
|
||||||
builder: (_, snapshot) => StreamChannel(
|
builder: (_, data) => StreamChannel(
|
||||||
channel: streamChannel!.channel,
|
channel: streamChannel!.channel,
|
||||||
child: widget.threadBuilder!(context, snapshot),
|
child: widget.threadBuilder!(context, data),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1220,8 +1220,8 @@ class _LoadingIndicator extends StatelessWidget {
|
|||||||
child: Text('Error loading messages'),
|
child: Text('Error loading messages'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
if (!snapshot) {
|
if (!data) {
|
||||||
if (!isThreadConversation && direction == QueryDirection.top) {
|
if (!isThreadConversation && direction == QueryDirection.top) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 52,
|
height: 52,
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ class _TypingIndicatorState extends State<TypingIndicator> {
|
|||||||
return BetterStreamBuilder<List<User>>(
|
return BetterStreamBuilder<List<User>>(
|
||||||
initialData: channelState.typingEvents,
|
initialData: channelState.typingEvents,
|
||||||
stream: channelState.typingEventsStream,
|
stream: channelState.typingEventsStream,
|
||||||
builder: (context, snapshot) => AnimatedSwitcher(
|
builder: (context, data) => AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: snapshot.isNotEmpty == true
|
child: data.isNotEmpty == true
|
||||||
? Padding(
|
? Padding(
|
||||||
key: const Key('main'),
|
key: const Key('main'),
|
||||||
padding: widget.padding,
|
padding: widget.padding,
|
||||||
@@ -68,7 +68,7 @@ class _TypingIndicatorState extends State<TypingIndicator> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
// ignore: lines_longer_than_80_chars
|
// ignore: lines_longer_than_80_chars
|
||||||
' ${snapshot[0].name}${snapshot.length == 1 ? '' : ' and ${snapshot.length - 1} more'} ${snapshot.length == 1 ? 'is' : 'are'} typing',
|
' ${data[0].name}${data.length == 1 ? '' : ' and ${data.length - 1} more'} ${data.length == 1 ? 'is' : 'are'} typing',
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: widget.style,
|
style: widget.style,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class UnreadIndicator extends StatelessWidget {
|
|||||||
initialData: cid != null
|
initialData: cid != null
|
||||||
? client.state.channels[cid]?.state?.unreadCount
|
? client.state.channels[cid]?.state?.unreadCount
|
||||||
: client.state.totalUnreadCount,
|
: client.state.totalUnreadCount,
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
if (snapshot == null || snapshot == 0) {
|
if (data == null || data == 0) {
|
||||||
return const Offstage();
|
return const Offstage();
|
||||||
}
|
}
|
||||||
return Material(
|
return Material(
|
||||||
@@ -42,7 +42,7 @@ class UnreadIndicator extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${snapshot > 99 ? '99+' : snapshot}',
|
'${data > 99 ? '99+' : data}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ class MessageListCoreState extends State<MessageListCore> {
|
|||||||
),
|
),
|
||||||
errorBuilder: widget.errorWidgetBuilder,
|
errorBuilder: widget.errorWidgetBuilder,
|
||||||
loadingBuilder: widget.loadingBuilder,
|
loadingBuilder: widget.loadingBuilder,
|
||||||
builder: (context, snapshot) {
|
builder: (context, data) {
|
||||||
final messageList = snapshot?.reversed.toList(growable: false) ?? [];
|
final messageList = data?.reversed.toList(growable: false) ?? [];
|
||||||
if (messageList.isEmpty && !_isThreadConversation) {
|
if (messageList.isEmpty && !_isThreadConversation) {
|
||||||
if (_upToDate) {
|
if (_upToDate) {
|
||||||
return widget.emptyBuilder(context);
|
return widget.emptyBuilder(context);
|
||||||
|
|||||||
Reference in New Issue
Block a user