feat: Save files images and videos

This commit is contained in:
Christian Pauly 2021-12-27 15:35:25 +01:00
parent 359c8db1ac
commit 7e442ec504
2 changed files with 19 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat/chat_view.dart';
import 'package:fluffychat/pages/chat/event_info_dialog.dart';
import 'package:fluffychat/pages/chat/recording_dialog.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/matrix.dart';
@ -83,6 +84,18 @@ class ChatController extends State<Chat> {
}
}
bool get canSaveSelectedEvent =>
selectedEvents.length == 1 &&
{
MessageTypes.Video,
MessageTypes.Image,
MessageTypes.Sticker,
MessageTypes.Audio,
MessageTypes.File,
}.contains(selectedEvents.single.messageType);
void saveSelectedEvent() => selectedEvents.single.saveFile(context);
List<Event> selectedEvents = [];
List<Event> filteredEvents;

View File

@ -49,6 +49,12 @@ class ChatView extends StatelessWidget {
tooltip: L10n.of(context).copy,
onPressed: controller.copyEventsAction,
),
if (controller.canSaveSelectedEvent)
IconButton(
icon: Icon(Icons.adaptive.share),
tooltip: L10n.of(context).share,
onPressed: controller.saveSelectedEvent,
),
if (controller.canRedactSelectedEvents)
IconButton(
icon: const Icon(Icons.delete_outlined),