added customisation options for attachment actions modal and related widgets
This commit is contained in:
@@ -24,6 +24,10 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
this.onShowMessage,
|
this.onShowMessage,
|
||||||
this.imageDownloader,
|
this.imageDownloader,
|
||||||
this.fileDownloader,
|
this.fileDownloader,
|
||||||
|
this.showReply = true,
|
||||||
|
this.showShowInChat = true,
|
||||||
|
this.showSave = true,
|
||||||
|
this.showDelete = true,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The message containing the attachments
|
/// The message containing the attachments
|
||||||
@@ -41,6 +45,18 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
/// Callback to provide download files
|
/// Callback to provide download files
|
||||||
final AttachmentDownloader? fileDownloader;
|
final AttachmentDownloader? fileDownloader;
|
||||||
|
|
||||||
|
/// Show reply option
|
||||||
|
final bool showReply;
|
||||||
|
|
||||||
|
/// Show show in chat option
|
||||||
|
final bool showShowInChat;
|
||||||
|
|
||||||
|
/// Show save option
|
||||||
|
final bool showSave;
|
||||||
|
|
||||||
|
/// Show delete option
|
||||||
|
final bool showDelete;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => GestureDetector(
|
Widget build(BuildContext context) => GestureDetector(
|
||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
@@ -67,82 +83,86 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildButton(
|
if (showReply)
|
||||||
context,
|
_buildButton(
|
||||||
context.translations.replyLabel,
|
context,
|
||||||
StreamSvgIcon.iconCurveLineLeftUp(
|
context.translations.replyLabel,
|
||||||
size: 24,
|
StreamSvgIcon.iconCurveLineLeftUp(
|
||||||
color: theme.colorTheme.textLowEmphasis,
|
size: 24,
|
||||||
|
color: theme.colorTheme.textLowEmphasis,
|
||||||
|
),
|
||||||
|
() {
|
||||||
|
Navigator.pop(context, ReturnActionType.reply);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
() {
|
if (showShowInChat)
|
||||||
Navigator.pop(context, ReturnActionType.reply);
|
_buildButton(
|
||||||
},
|
context,
|
||||||
),
|
context.translations.showInChatLabel,
|
||||||
_buildButton(
|
StreamSvgIcon.eye(
|
||||||
context,
|
size: 24,
|
||||||
context.translations.showInChatLabel,
|
color: theme.colorTheme.textHighEmphasis,
|
||||||
StreamSvgIcon.eye(
|
),
|
||||||
size: 24,
|
onShowMessage,
|
||||||
color: theme.colorTheme.textHighEmphasis,
|
|
||||||
),
|
),
|
||||||
onShowMessage,
|
if (showSave)
|
||||||
),
|
_buildButton(
|
||||||
_buildButton(
|
context,
|
||||||
context,
|
message.attachments[currentIndex].type == 'video'
|
||||||
message.attachments[currentIndex].type == 'video'
|
? context.translations.saveVideoLabel
|
||||||
? context.translations.saveVideoLabel
|
: context.translations.saveImageLabel,
|
||||||
: context.translations.saveImageLabel,
|
StreamSvgIcon.iconSave(
|
||||||
StreamSvgIcon.iconSave(
|
size: 24,
|
||||||
size: 24,
|
color: theme.colorTheme.textLowEmphasis,
|
||||||
color: theme.colorTheme.textLowEmphasis,
|
),
|
||||||
|
() {
|
||||||
|
final attachment = message.attachments[currentIndex];
|
||||||
|
final isImage = attachment.type == 'image';
|
||||||
|
final Future<String?> Function(
|
||||||
|
Attachment, {
|
||||||
|
void Function(int, int) progressCallback,
|
||||||
|
}) saveFile = fileDownloader ?? _downloadAttachment;
|
||||||
|
final Future<String?> Function(
|
||||||
|
Attachment, {
|
||||||
|
void Function(int, int) progressCallback,
|
||||||
|
}) saveImage = imageDownloader ?? _downloadAttachment;
|
||||||
|
final downloader = isImage ? saveImage : saveFile;
|
||||||
|
|
||||||
|
final progressNotifier =
|
||||||
|
ValueNotifier<_DownloadProgress?>(
|
||||||
|
_DownloadProgress.initial(),
|
||||||
|
);
|
||||||
|
|
||||||
|
downloader(
|
||||||
|
attachment,
|
||||||
|
progressCallback: (received, total) {
|
||||||
|
progressNotifier.value = _DownloadProgress(
|
||||||
|
total,
|
||||||
|
received,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).catchError((e, stk) {
|
||||||
|
progressNotifier.value = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Closing attachment actions modal before opening
|
||||||
|
// attachment download dialog
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
barrierColor: theme.colorTheme.overlay,
|
||||||
|
builder: (context) => _buildDownloadProgressDialog(
|
||||||
|
context,
|
||||||
|
progressNotifier,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
() {
|
|
||||||
final attachment = message.attachments[currentIndex];
|
|
||||||
final isImage = attachment.type == 'image';
|
|
||||||
final Future<String?> Function(
|
|
||||||
Attachment, {
|
|
||||||
void Function(int, int) progressCallback,
|
|
||||||
}) saveFile = fileDownloader ?? _downloadAttachment;
|
|
||||||
final Future<String?> Function(
|
|
||||||
Attachment, {
|
|
||||||
void Function(int, int) progressCallback,
|
|
||||||
}) saveImage = imageDownloader ?? _downloadAttachment;
|
|
||||||
final downloader = isImage ? saveImage : saveFile;
|
|
||||||
|
|
||||||
final progressNotifier =
|
|
||||||
ValueNotifier<_DownloadProgress?>(
|
|
||||||
_DownloadProgress.initial(),
|
|
||||||
);
|
|
||||||
|
|
||||||
downloader(
|
|
||||||
attachment,
|
|
||||||
progressCallback: (received, total) {
|
|
||||||
progressNotifier.value = _DownloadProgress(
|
|
||||||
total,
|
|
||||||
received,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).catchError((e, stk) {
|
|
||||||
progressNotifier.value = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Closing attachment actions modal before opening
|
|
||||||
// attachment download dialog
|
|
||||||
Navigator.pop(context);
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
barrierDismissible: false,
|
|
||||||
context: context,
|
|
||||||
barrierColor: theme.colorTheme.overlay,
|
|
||||||
builder: (context) => _buildDownloadProgressDialog(
|
|
||||||
context,
|
|
||||||
progressNotifier,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (StreamChat.of(context).currentUser?.id ==
|
if (StreamChat.of(context).currentUser?.id ==
|
||||||
message.user?.id)
|
message.user?.id &&
|
||||||
|
showDelete)
|
||||||
_buildButton(
|
_buildButton(
|
||||||
context,
|
context,
|
||||||
context.translations.deleteLabel.capitalize(),
|
context.translations.deleteLabel.capitalize(),
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class FullScreenMedia extends StatefulWidget {
|
|||||||
this.startIndex = 0,
|
this.startIndex = 0,
|
||||||
String? userName,
|
String? userName,
|
||||||
this.onShowMessage,
|
this.onShowMessage,
|
||||||
|
this.showReply = true,
|
||||||
|
this.showShowInChat = true,
|
||||||
|
this.showSave = true,
|
||||||
|
this.showDelete = true,
|
||||||
}) : userName = userName ?? '',
|
}) : userName = userName ?? '',
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@@ -51,6 +55,18 @@ class FullScreenMedia extends StatefulWidget {
|
|||||||
/// Callback for when show message is tapped
|
/// Callback for when show message is tapped
|
||||||
final ShowMessageCallback? onShowMessage;
|
final ShowMessageCallback? onShowMessage;
|
||||||
|
|
||||||
|
/// Show reply option
|
||||||
|
final bool showReply;
|
||||||
|
|
||||||
|
/// Show show in chat option
|
||||||
|
final bool showShowInChat;
|
||||||
|
|
||||||
|
/// Show save option
|
||||||
|
final bool showSave;
|
||||||
|
|
||||||
|
/// Show delete option
|
||||||
|
final bool showDelete;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_FullScreenMediaState createState() => _FullScreenMediaState();
|
_FullScreenMediaState createState() => _FullScreenMediaState();
|
||||||
}
|
}
|
||||||
@@ -196,6 +212,10 @@ class _FullScreenMediaState extends State<FullScreenMedia>
|
|||||||
StreamChannel.of(context).channel,
|
StreamChannel.of(context).channel,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
showReply: widget.showReply,
|
||||||
|
showShowInChat: widget.showShowInChat,
|
||||||
|
showSave: widget.showSave,
|
||||||
|
showDelete: widget.showDelete,
|
||||||
),
|
),
|
||||||
if (!widget.message.isEphemeral)
|
if (!widget.message.isEphemeral)
|
||||||
GalleryFooter(
|
GalleryFooter(
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
this.userName = '',
|
this.userName = '',
|
||||||
this.sentAt = '',
|
this.sentAt = '',
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
|
this.showReply = true,
|
||||||
|
this.showShowInChat = true,
|
||||||
|
this.showSave = true,
|
||||||
|
this.showDelete = true,
|
||||||
}) : preferredSize = const Size.fromHeight(kToolbarHeight),
|
}) : preferredSize = const Size.fromHeight(kToolbarHeight),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@@ -55,6 +59,18 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
/// The background color of this [GalleryHeader].
|
/// The background color of this [GalleryHeader].
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
|
|
||||||
|
/// Show reply option
|
||||||
|
final bool showReply;
|
||||||
|
|
||||||
|
/// Show show in chat option
|
||||||
|
final bool showShowInChat;
|
||||||
|
|
||||||
|
/// Show save option
|
||||||
|
final bool showSave;
|
||||||
|
|
||||||
|
/// Show delete option
|
||||||
|
final bool showDelete;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final galleryHeaderThemeData = GalleryHeaderTheme.of(context);
|
final galleryHeaderThemeData = GalleryHeaderTheme.of(context);
|
||||||
@@ -133,6 +149,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
message: message,
|
message: message,
|
||||||
currentIndex: currentIndex,
|
currentIndex: currentIndex,
|
||||||
onShowMessage: onShowMessage,
|
onShowMessage: onShowMessage,
|
||||||
|
showReply: showReply,
|
||||||
|
showShowInChat: showShowInChat,
|
||||||
|
showSave: showSave,
|
||||||
|
showDelete: showDelete,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user