feat(ui): add onAttachmentTap to ImageGroup

This commit is contained in:
Salvatore Giordano
2021-09-15 12:08:34 +02:00
parent 380e34450f
commit 33b9152d4f
2 changed files with 9 additions and 0 deletions
@@ -15,6 +15,7 @@ class ImageGroup extends StatelessWidget {
required this.size,
this.onReturnAction,
this.onShowMessage,
this.onAttachmentTap,
}) : super(key: key);
/// List of attachments to show
@@ -23,6 +24,9 @@ class ImageGroup extends StatelessWidget {
/// Callback when attachment is returned to from other screens
final ValueChanged<ReturnActionType>? onReturnAction;
/// Callback when attachment is tapped
final void Function(Message message, Attachment attachment)? onAttachmentTap;
/// Message which images are attached to
final Message message;
@@ -117,6 +121,10 @@ class ImageGroup extends StatelessWidget {
BuildContext context,
int index,
) async {
if (onAttachmentTap != null) {
return onAttachmentTap!(message, images[index]);
}
final channel = StreamChannel.of(context).channel;
final res = await Navigator.push(
@@ -133,6 +133,7 @@ class MessageWidget extends StatefulWidget {
messageTheme: messageTheme,
onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
onAttachmentTap: onAttachmentTap,
),
),
border,