From fde2f8b2a89b6e3788ffeed1e01d10c43ae4d01f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 18 Jan 2021 10:43:00 +0100 Subject: [PATCH] fix: Send file --- lib/components/dialogs/send_file_dialog.dart | 24 ++++++++++++------- lib/components/list_items/chat_list_item.dart | 1 + lib/views/chat.dart | 9 ++++--- pubspec.lock | 11 ++------- pubspec.yaml | 2 +- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/components/dialogs/send_file_dialog.dart b/lib/components/dialogs/send_file_dialog.dart index 6b26225f..0eef681c 100644 --- a/lib/components/dialogs/send_file_dialog.dart +++ b/lib/components/dialogs/send_file_dialog.dart @@ -10,8 +10,14 @@ import '../../utils/resize_image.dart'; class SendFileDialog extends StatefulWidget { final Room room; final MatrixFile file; + final L10n l10n; - const SendFileDialog({this.room, this.file, Key key}) : super(key: key); + const SendFileDialog({ + this.room, + @required this.l10n, + this.file, + Key key, + }) : super(key: key); @override _SendFileDialogState createState() => _SendFileDialogState(); @@ -34,13 +40,13 @@ class _SendFileDialogState extends State { @override Widget build(BuildContext context) { - var sendStr = L10n.of(context).sendFile; + var sendStr = widget.l10n.sendFile; if (widget.file is MatrixImageFile) { - sendStr = L10n.of(context).sendImage; + sendStr = widget.l10n.sendImage; } else if (widget.file is MatrixAudioFile) { - sendStr = L10n.of(context).sendAudio; + sendStr = widget.l10n.sendAudio; } else if (widget.file is MatrixVideoFile) { - sendStr = L10n.of(context).sendVideo; + sendStr = widget.l10n.sendVideo; } Widget contentWidget; if (widget.file is MatrixImageFile) { @@ -60,8 +66,8 @@ class _SendFileDialogState extends State { ), InkWell( onTap: () => setState(() => origImage = !origImage), - child: Text(L10n.of(context).sendOriginal + - ' (${widget.file.sizeString})'), + child: Text( + widget.l10n.sendOriginal + ' (${widget.file.sizeString})'), ), ], ) @@ -74,14 +80,14 @@ class _SendFileDialogState extends State { content: contentWidget, actions: [ FlatButton( - child: Text(L10n.of(context).cancel), + child: Text(widget.l10n.cancel), onPressed: () { // just close the dialog Navigator.of(context).pop(); }, ), FlatButton( - child: Text(L10n.of(context).send), + child: Text(widget.l10n.send), onPressed: _isSending ? null : () async { diff --git a/lib/components/list_items/chat_list_item.dart b/lib/components/list_items/chat_list_item.dart index 5617f8a7..0ac9fd08 100644 --- a/lib/components/list_items/chat_list_item.dart +++ b/lib/components/list_items/chat_list_item.dart @@ -94,6 +94,7 @@ class ChatListItem extends StatelessWidget { builder: (c) => SendFileDialog( file: Matrix.of(context).shareContent['file'], room: room, + l10n: L10n.of(context), )); } else { unawaited(room.sendEvent(Matrix.of(context).shareContent)); diff --git a/lib/views/chat.dart b/lib/views/chat.dart index ed299840..87ec92b1 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -214,12 +214,13 @@ class _ChatState extends State { if (result == null) return; await showDialog( context: context, - builder: (context) => SendFileDialog( + builder: (c) => SendFileDialog( file: MatrixFile( bytes: result.toUint8List(), name: result.fileName, ).detectFileType, room: room, + l10n: L10n.of(context), ), ); } @@ -230,12 +231,13 @@ class _ChatState extends State { if (result == null) return; await showDialog( context: context, - builder: (context) => SendFileDialog( + builder: (c) => SendFileDialog( file: MatrixImageFile( bytes: result.toUint8List(), name: result.fileName, ), room: room, + l10n: L10n.of(context), ), ); } @@ -246,12 +248,13 @@ class _ChatState extends State { final bytes = await file.readAsBytes(); await showDialog( context: context, - builder: (context) => SendFileDialog( + builder: (c) => SendFileDialog( file: MatrixImageFile( bytes: bytes, name: file.path, ), room: room, + l10n: L10n.of(context), ), ); } diff --git a/pubspec.lock b/pubspec.lock index eae18350..abed182c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -247,21 +247,14 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "1.13.3" + version: "2.1.5+1" file_picker_cross: dependency: "direct main" description: name: file_picker_cross url: "https://pub.dartlang.org" source: hosted - version: "4.2.2" - file_picker_platform_interface: - dependency: transitive - description: - name: file_picker_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "4.2.7" firebase: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6bfa0a82..295dc17b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: ref: main localstorage: ^3.0.6+9 - file_picker_cross: 4.2.2 + file_picker_cross: ^4.2.7 image_picker: ^0.6.7+21 url_launcher: ^5.7.10 cached_network_image: ^2.5.0