added customisation options for attachment actions modal and related widgets

This commit is contained in:
Deven Joshi
2021-11-15 17:18:30 +05:30
parent a3cce7ffff
commit 3a04e4f390
3 changed files with 132 additions and 72 deletions
@@ -24,6 +24,10 @@ class AttachmentActionsModal extends StatelessWidget {
this.onShowMessage,
this.imageDownloader,
this.fileDownloader,
this.showReply = true,
this.showShowInChat = true,
this.showSave = true,
this.showDelete = true,
}) : super(key: key);
/// The message containing the attachments
@@ -41,6 +45,18 @@ class AttachmentActionsModal extends StatelessWidget {
/// Callback to provide download files
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
Widget build(BuildContext context) => GestureDetector(
behavior: HitTestBehavior.translucent,
@@ -67,6 +83,7 @@ class AttachmentActionsModal extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
if (showReply)
_buildButton(
context,
context.translations.replyLabel,
@@ -78,6 +95,7 @@ class AttachmentActionsModal extends StatelessWidget {
Navigator.pop(context, ReturnActionType.reply);
},
),
if (showShowInChat)
_buildButton(
context,
context.translations.showInChatLabel,
@@ -87,6 +105,7 @@ class AttachmentActionsModal extends StatelessWidget {
),
onShowMessage,
),
if (showSave)
_buildButton(
context,
message.attachments[currentIndex].type == 'video'
@@ -142,7 +161,8 @@ class AttachmentActionsModal extends StatelessWidget {
},
),
if (StreamChat.of(context).currentUser?.id ==
message.user?.id)
message.user?.id &&
showDelete)
_buildButton(
context,
context.translations.deleteLabel.capitalize(),
@@ -33,6 +33,10 @@ class FullScreenMedia extends StatefulWidget {
this.startIndex = 0,
String? userName,
this.onShowMessage,
this.showReply = true,
this.showShowInChat = true,
this.showSave = true,
this.showDelete = true,
}) : userName = userName ?? '',
super(key: key);
@@ -51,6 +55,18 @@ class FullScreenMedia extends StatefulWidget {
/// Callback for when show message is tapped
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
_FullScreenMediaState createState() => _FullScreenMediaState();
}
@@ -196,6 +212,10 @@ class _FullScreenMediaState extends State<FullScreenMedia>
StreamChannel.of(context).channel,
);
},
showReply: widget.showReply,
showShowInChat: widget.showShowInChat,
showSave: widget.showSave,
showDelete: widget.showDelete,
),
if (!widget.message.isEphemeral)
GalleryFooter(
@@ -21,6 +21,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
this.userName = '',
this.sentAt = '',
this.backgroundColor,
this.showReply = true,
this.showShowInChat = true,
this.showSave = true,
this.showDelete = true,
}) : preferredSize = const Size.fromHeight(kToolbarHeight),
super(key: key);
@@ -55,6 +59,18 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
/// The background color of this [GalleryHeader].
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
Widget build(BuildContext context) {
final galleryHeaderThemeData = GalleryHeaderTheme.of(context);
@@ -133,6 +149,10 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
message: message,
currentIndex: currentIndex,
onShowMessage: onShowMessage,
showReply: showReply,
showShowInChat: showShowInChat,
showSave: showSave,
showDelete: showDelete,
),
),
);