Implemented StreamAttachmentPackage and fixed operations in widgets linked to full screen implementation, also fixed tests
This commit is contained in:
@@ -9,13 +9,16 @@ import 'mocks.dart';
|
||||
|
||||
class MockAttachmentDownloader extends Mock {
|
||||
ProgressCallback? progressCallback;
|
||||
DownloadedPathCallback? downloadedPathCallback;
|
||||
Completer<String> completer = Completer();
|
||||
|
||||
Future<String> call(
|
||||
Attachment attachment, {
|
||||
ProgressCallback? progressCallback,
|
||||
DownloadedPathCallback? downloadedPathCallback,
|
||||
}) {
|
||||
this.progressCallback = progressCallback;
|
||||
this.downloadedPathCallback = downloadedPathCallback;
|
||||
return completer.future;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +41,19 @@ void main() {
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'text.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: themeData,
|
||||
@@ -45,19 +61,8 @@ void main() {
|
||||
streamChatThemeData: streamTheme,
|
||||
client: client,
|
||||
child: AttachmentActionsModal(
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'text.jpg',
|
||||
),
|
||||
],
|
||||
),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -80,6 +85,19 @@ void main() {
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'text.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: themeData,
|
||||
@@ -87,19 +105,8 @@ void main() {
|
||||
streamChatThemeData: streamTheme,
|
||||
client: client,
|
||||
child: AttachmentActionsModal(
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'text.jpg',
|
||||
),
|
||||
],
|
||||
),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -122,6 +129,19 @@ void main() {
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
final attachment = Attachment(
|
||||
type: 'video',
|
||||
title: 'video.mp4',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: themeData,
|
||||
@@ -130,19 +150,8 @@ void main() {
|
||||
client: client,
|
||||
child: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'video',
|
||||
title: 'video.mp4',
|
||||
),
|
||||
],
|
||||
),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -166,16 +175,17 @@ void main() {
|
||||
|
||||
final mockObserver = MockNavigatorObserver();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
@@ -188,7 +198,7 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
message: message,
|
||||
currentIndex: 0,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -212,6 +222,20 @@ void main() {
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
final onShowMessage = MockVoidCallback();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: themeData,
|
||||
@@ -221,18 +245,8 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
onShowMessage: onShowMessage,
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
]),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -255,20 +269,22 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
final targetAttachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final remainingAttachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
targetAttachment,
|
||||
remainingAttachment,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -283,7 +299,7 @@ void main() {
|
||||
channel: mockChannel,
|
||||
child: AttachmentActionsModal(
|
||||
message: message,
|
||||
currentIndex: 0,
|
||||
attachment: targetAttachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -309,16 +325,17 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -333,7 +350,7 @@ void main() {
|
||||
channel: mockChannel,
|
||||
child: AttachmentActionsModal(
|
||||
message: message,
|
||||
currentIndex: 0,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -358,15 +375,16 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -381,7 +399,7 @@ void main() {
|
||||
channel: mockChannel,
|
||||
child: AttachmentActionsModal(
|
||||
message: message,
|
||||
currentIndex: 0,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -402,6 +420,20 @@ void main() {
|
||||
|
||||
final imageDownloader = MockAttachmentDownloader();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
@@ -411,18 +443,8 @@ void main() {
|
||||
home: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
imageDownloader: imageDownloader,
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
),
|
||||
]),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -457,6 +479,19 @@ void main() {
|
||||
|
||||
final fileDownloader = MockAttachmentDownloader();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'video',
|
||||
title: 'video.mp4',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
]);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
@@ -466,18 +501,8 @@ void main() {
|
||||
home: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
fileDownloader: fileDownloader,
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
Attachment(
|
||||
type: 'video',
|
||||
title: 'video.mp4',
|
||||
),
|
||||
]),
|
||||
currentIndex: 0,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -63,22 +63,29 @@ void main() {
|
||||
Event(type: EventType.typingStart),
|
||||
}));
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'demo image',
|
||||
imageUrl: '',
|
||||
);
|
||||
final message = Message(
|
||||
createdAt: DateTime.now(),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamFullScreenMedia(
|
||||
mediaAttachments: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'demo image',
|
||||
imageUrl: '',
|
||||
mediaAttachmentPackages: [
|
||||
StreamAttachmentPackage(
|
||||
attachment: attachment,
|
||||
message: message,
|
||||
),
|
||||
],
|
||||
message: Message(
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: StreamGalleryFooter(
|
||||
message: Message(),
|
||||
mediaAttachmentPackages: Message().getAttachmentPackageList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -75,7 +75,7 @@ void main() {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: StreamGalleryFooter(
|
||||
message: Message(),
|
||||
mediaAttachmentPackages: Message().getAttachmentPackageList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: StreamGalleryFooter(
|
||||
message: Message(),
|
||||
mediaAttachmentPackages: Message().getAttachmentPackageList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -66,9 +66,11 @@ void main() {
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
final _message = Message();
|
||||
return Scaffold(
|
||||
appBar: StreamGalleryHeader(
|
||||
message: Message(),
|
||||
message: _message,
|
||||
attachment: _message.attachments[0],
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -105,9 +107,11 @@ void main() {
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
final _message = Message();
|
||||
return Scaffold(
|
||||
appBar: StreamGalleryHeader(
|
||||
message: Message(),
|
||||
message: _message,
|
||||
attachment: _message.attachments[0],
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user