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