fix tests
This commit is contained in:
@@ -17,18 +17,22 @@ class ChannelBottomSheet extends StatefulWidget {
|
||||
class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
bool _showActions = true;
|
||||
|
||||
late StreamChannelState _streamChannelState;
|
||||
late StreamChatThemeData _streamChatThemeData;
|
||||
late StreamChatState _streamChatState;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
final channel = _streamChannelState.channel;
|
||||
|
||||
final members = channel.state?.members ?? [];
|
||||
|
||||
final userAsMember = members
|
||||
.firstWhere((e) => e.user?.id == StreamChat.of(context).user?.id);
|
||||
final userAsMember =
|
||||
members.firstWhere((e) => e.user?.id == _streamChatState.user?.id);
|
||||
final isOwner = userAsMember.role == 'owner';
|
||||
|
||||
return Material(
|
||||
color: StreamChatTheme.of(context).colorTheme.white,
|
||||
color: _streamChatThemeData.colorTheme.white,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
@@ -48,8 +52,7 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ChannelName(
|
||||
textStyle:
|
||||
StreamChatTheme.of(context).textTheme.headlineBold,
|
||||
textStyle: _streamChatThemeData.textTheme.headlineBold,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -59,10 +62,9 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
Center(
|
||||
child: ChannelInfo(
|
||||
showTypingIndicator: false,
|
||||
channel: StreamChannel.of(context).channel,
|
||||
textStyle: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.subtitle,
|
||||
channel: _streamChannelState.channel,
|
||||
textStyle:
|
||||
_streamChatThemeData.channelPreviewTheme.subtitle,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@@ -94,8 +96,7 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
.user
|
||||
?.name ??
|
||||
'',
|
||||
style:
|
||||
StreamChatTheme.of(context).textTheme.footnoteBold,
|
||||
style: _streamChatThemeData.textTheme.footnoteBold,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -128,9 +129,8 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
),
|
||||
Text(
|
||||
members[index].user?.name ?? '',
|
||||
style: StreamChatTheme.of(context)
|
||||
.textTheme
|
||||
.footnoteBold,
|
||||
style:
|
||||
_streamChatThemeData.textTheme.footnoteBold,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -146,7 +146,7 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: StreamSvgIcon.user(
|
||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||
color: _streamChatThemeData.colorTheme.grey,
|
||||
),
|
||||
),
|
||||
title: 'View Info',
|
||||
@@ -157,7 +157,7 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: StreamSvgIcon.userRemove(
|
||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||
color: _streamChatThemeData.colorTheme.grey,
|
||||
),
|
||||
),
|
||||
title: 'Leave Group',
|
||||
@@ -176,12 +176,11 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: StreamSvgIcon.delete(
|
||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||
color: _streamChatThemeData.colorTheme.accentRed,
|
||||
),
|
||||
),
|
||||
title: 'Delete Conversation',
|
||||
titleColor:
|
||||
StreamChatTheme.of(context).colorTheme.accentRed,
|
||||
titleColor: _streamChatThemeData.colorTheme.accentRed,
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
_showActions = false;
|
||||
@@ -196,7 +195,7 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: StreamSvgIcon.closeSmall(
|
||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||
color: _streamChatThemeData.colorTheme.grey,
|
||||
),
|
||||
),
|
||||
title: 'Cancel',
|
||||
@@ -209,6 +208,14 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_streamChannelState = StreamChannel.of(context);
|
||||
_streamChatThemeData = StreamChatTheme.of(context);
|
||||
_streamChatState = StreamChat.of(context);
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
Future<void> _showDeleteDialog() async {
|
||||
final res = await showConfirmationDialog(
|
||||
context,
|
||||
@@ -217,10 +224,10 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
question: 'Are you sure you want to delete this conversation?',
|
||||
cancelText: 'CANCEL',
|
||||
icon: StreamSvgIcon.delete(
|
||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||
color: _streamChatThemeData.colorTheme.accentRed,
|
||||
),
|
||||
);
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
final channel = _streamChannelState.channel;
|
||||
if (res == true) {
|
||||
await channel.delete();
|
||||
Navigator.pop(context);
|
||||
@@ -235,12 +242,12 @@ class _ChannelBottomSheetState extends State<ChannelBottomSheet> {
|
||||
question: 'Are you sure you want to leave this conversation?',
|
||||
cancelText: 'CANCEL',
|
||||
icon: StreamSvgIcon.userRemove(
|
||||
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||
color: _streamChatThemeData.colorTheme.accentRed,
|
||||
),
|
||||
);
|
||||
if (res == true) {
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
final user = StreamChat.of(context).user;
|
||||
final channel = _streamChannelState.channel;
|
||||
final user = _streamChatState.user;
|
||||
if (user != null) {
|
||||
await channel.removeMembers([user.id]);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:stream_chat_flutter/src/video_service.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:video_thumbnail/video_thumbnail.dart';
|
||||
import 'package:stream_chat_flutter/src/video_service.dart';
|
||||
|
||||
/// Widget for creating video thumbnail image
|
||||
class VideoThumbnailImage extends StatefulWidget {
|
||||
@@ -47,6 +47,7 @@ class VideoThumbnailImage extends StatefulWidget {
|
||||
|
||||
class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
|
||||
late Future<Uint8List?> thumbnailFuture;
|
||||
late StreamChatThemeData _streamChatTheme;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -57,6 +58,12 @@ class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_streamChatTheme = StreamChatTheme.of(context);
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant VideoThumbnailImage oldWidget) {
|
||||
if (oldWidget.video != widget.video || oldWidget.format != widget.format) {
|
||||
@@ -87,11 +94,8 @@ class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: widget.placeholderBuilder?.call(context) ??
|
||||
Shimmer.fromColors(
|
||||
baseColor: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.greyGainsboro,
|
||||
highlightColor:
|
||||
StreamChatTheme.of(context).colorTheme.whiteSmoke,
|
||||
baseColor: _streamChatTheme.colorTheme.greyGainsboro,
|
||||
highlightColor: _streamChatTheme.colorTheme.whiteSmoke,
|
||||
child: Image.asset(
|
||||
'images/placeholder.png',
|
||||
fit: BoxFit.cover,
|
||||
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
await tester.pumpWidget(channelListCore);
|
||||
|
||||
expect(find.byKey(channelListCoreKey), findsNothing);
|
||||
expect(tester.takeException(), isInstanceOf<Exception>());
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
|
||||
expect(find.byKey(channelsBlocKey), findsNothing);
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
expect(tester.takeException(), isInstanceOf<Exception>());
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
await tester.pumpWidget(messageListCore);
|
||||
|
||||
expect(find.byKey(messageListCoreKey), findsNothing);
|
||||
expect(tester.takeException(), isInstanceOf<Exception>());
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -35,27 +35,12 @@ void main() {
|
||||
'messageSearchBlocState.search() should throw if used where '
|
||||
'StreamChat is not present in the widget tree',
|
||||
(tester) async {
|
||||
const messageSearchBlocKey = Key('messageSearchBloc');
|
||||
const childKey = Key('child');
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
key: messageSearchBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(messageSearchBloc);
|
||||
|
||||
expect(find.byKey(messageSearchBlocKey), findsOneWidget);
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final usersBlocState = tester.state<MessageSearchBlocState>(
|
||||
find.byKey(messageSearchBlocKey),
|
||||
);
|
||||
|
||||
try {
|
||||
await usersBlocState.search(filter: testFilter);
|
||||
} catch (e) {
|
||||
expect(e, isInstanceOf<Exception>());
|
||||
}
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void main() {
|
||||
await tester.pumpWidget(messageSearchListCore);
|
||||
|
||||
expect(find.byKey(messageSearchListCoreKey), findsNothing);
|
||||
expect(tester.takeException(), isInstanceOf<Exception>());
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
await tester.pumpWidget(userListCore);
|
||||
|
||||
expect(find.byKey(userListCoreKey), findsNothing);
|
||||
expect(tester.takeException(), isInstanceOf<Exception>());
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -35,27 +35,12 @@ void main() {
|
||||
'usersBlocState.queryUsers() should throw if used where '
|
||||
'StreamChat is not present in the widget tree',
|
||||
(tester) async {
|
||||
const usersBlocKey = Key('usersBloc');
|
||||
const childKey = Key('child');
|
||||
final usersBloc = UsersBloc(
|
||||
key: usersBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(usersBloc);
|
||||
|
||||
expect(find.byKey(usersBlocKey), findsOneWidget);
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final usersBlocState = tester.state<UsersBlocState>(
|
||||
find.byKey(usersBlocKey),
|
||||
);
|
||||
|
||||
try {
|
||||
await usersBlocState.queryUsers();
|
||||
} catch (e) {
|
||||
expect(e, isInstanceOf<Exception>());
|
||||
}
|
||||
expect(tester.takeException(), isInstanceOf<AssertionError>());
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user