added custom actions
This commit is contained in:
@@ -28,6 +28,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
this.showShowInChat = true,
|
this.showShowInChat = true,
|
||||||
this.showSave = true,
|
this.showSave = true,
|
||||||
this.showDelete = true,
|
this.showDelete = true,
|
||||||
|
this.customActions = const [],
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The message containing the attachments
|
/// The message containing the attachments
|
||||||
@@ -57,6 +58,9 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
/// Show delete option
|
/// Show delete option
|
||||||
final bool showDelete;
|
final bool showDelete;
|
||||||
|
|
||||||
|
/// List of custom actions
|
||||||
|
final List<AttachmentAction> customActions;
|
||||||
|
|
||||||
/// Creates a copy of [MessageWidget] with specified attributes overridden.
|
/// Creates a copy of [MessageWidget] with specified attributes overridden.
|
||||||
AttachmentActionsModal copyWith({
|
AttachmentActionsModal copyWith({
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -69,6 +73,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
bool? showShowInChat,
|
bool? showShowInChat,
|
||||||
bool? showSave,
|
bool? showSave,
|
||||||
bool? showDelete,
|
bool? showDelete,
|
||||||
|
List<AttachmentAction>? customActions,
|
||||||
}) =>
|
}) =>
|
||||||
AttachmentActionsModal(
|
AttachmentActionsModal(
|
||||||
key: key ?? this.key,
|
key: key ?? this.key,
|
||||||
@@ -81,6 +86,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
showShowInChat: showShowInChat ?? this.showShowInChat,
|
showShowInChat: showShowInChat ?? this.showShowInChat,
|
||||||
showSave: showSave ?? this.showSave,
|
showSave: showSave ?? this.showSave,
|
||||||
showDelete: showDelete ?? this.showDelete,
|
showDelete: showDelete ?? this.showDelete,
|
||||||
|
customActions: customActions ?? this.customActions,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -217,6 +223,16 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
color: theme.colorTheme.accentError,
|
color: theme.colorTheme.accentError,
|
||||||
),
|
),
|
||||||
|
...customActions
|
||||||
|
.map(
|
||||||
|
(e) => _buildButton(
|
||||||
|
context,
|
||||||
|
e.actionTitle,
|
||||||
|
e.icon,
|
||||||
|
e.onTap,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
]
|
]
|
||||||
.map<Widget>((e) => Align(
|
.map<Widget>((e) => Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
@@ -239,7 +255,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
Widget _buildButton(
|
Widget _buildButton(
|
||||||
context,
|
context,
|
||||||
String title,
|
String title,
|
||||||
StreamSvgIcon icon,
|
Widget icon,
|
||||||
VoidCallback? onTap, {
|
VoidCallback? onTap, {
|
||||||
Color? color,
|
Color? color,
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -377,3 +393,15 @@ class _DownloadProgress {
|
|||||||
|
|
||||||
int get toPercentage => (received * 100) ~/ total;
|
int get toPercentage => (received * 100) ~/ total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AttachmentAction {
|
||||||
|
String actionTitle;
|
||||||
|
Widget icon;
|
||||||
|
VoidCallback onTap;
|
||||||
|
|
||||||
|
AttachmentAction({
|
||||||
|
required this.actionTitle,
|
||||||
|
required this.icon,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user