feat: Better image sending experience

This commit is contained in:
Christian Pauly 2022-03-30 11:46:24 +02:00
parent 8f56687d43
commit 35a2f95eae
6 changed files with 17 additions and 18 deletions

View File

@ -414,10 +414,10 @@ class ChatController extends State<Chat> {
bytes: audioFile.readAsBytesSync(), bytes: audioFile.readAsBytesSync(),
name: audioFile.path, name: audioFile.path,
); );
await showFutureLoadingDialog( await room!.sendFileEvent(
context: context, file,
future: () => inReplyTo: replyEvent,
room!.sendFileEvent(file, inReplyTo: replyEvent, extraContent: { extraContent: {
'info': { 'info': {
...file.info, ...file.info,
'duration': result.duration, 'duration': result.duration,
@ -427,7 +427,7 @@ class ChatController extends State<Chat> {
'duration': result.duration, 'duration': result.duration,
'waveform': result.waveform, 'waveform': result.waveform,
}, },
}), },
); );
setState(() { setState(() {
replyEvent = null; replyEvent = null;

View File

@ -290,6 +290,8 @@ class Message extends StatelessWidget {
)), )),
), ),
row, row,
if (event.fileSendingStatus != null)
Text(event.fileSendingStatus!.name),
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction)) if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction))
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(

View File

@ -31,20 +31,16 @@ class _SendFileDialogState extends State<SendFileDialog> {
Future<void> _send() async { Future<void> _send() async {
var file = widget.file; var file = widget.file;
MatrixImageFile? thumbnail; MatrixImageFile? thumbnail;
if (file is MatrixImageFile &&
!origImage &&
file.bytes.length > minSizeToCompress) {
file = await MatrixImageFile.shrink(
bytes: file.bytes,
name: file.name,
compute: widget.room.client.runInBackground,
);
}
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) { if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
file = await file.resizeVideo(); file = await file.resizeVideo();
thumbnail = await file.getVideoThumbnail(); thumbnail = await file.getVideoThumbnail();
} }
await widget.room.sendFileEvent(file, thumbnail: thumbnail); widget.room.sendFileEvent(
file,
thumbnail: thumbnail,
shrinkImageMaxDimension: origImage ? null : 1600,
);
return;
} }
@override @override

View File

@ -76,7 +76,8 @@ extension LocalizedBody on Event {
Future<MatrixFile?> downloadAndDecryptAttachmentCached( Future<MatrixFile?> downloadAndDecryptAttachmentCached(
{bool getThumbnail = false}) async { {bool getThumbnail = false}) async {
final mxcUrl = final mxcUrl =
attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail).toString(); attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail)?.toString() ??
eventId;
_downloadAndDecryptFutures[mxcUrl] ??= downloadAndDecryptAttachment( _downloadAndDecryptFutures[mxcUrl] ??= downloadAndDecryptAttachment(
getThumbnail: getThumbnail, getThumbnail: getThumbnail,
downloadCallback: (Uri url) async { downloadCallback: (Uri url) async {

View File

@ -976,7 +976,7 @@ packages:
name: matrix name: matrix
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.14" version: "0.8.15"
matrix_api_lite: matrix_api_lite:
dependency: transitive dependency: transitive
description: description:

View File

@ -57,7 +57,7 @@ dependencies:
keyboard_shortcuts: ^0.1.4 keyboard_shortcuts: ^0.1.4
localstorage: ^4.0.0+1 localstorage: ^4.0.0+1
lottie: ^1.2.2 lottie: ^1.2.2
matrix: ^0.8.14 matrix: ^0.8.15
matrix_link_text: ^1.0.2 matrix_link_text: ^1.0.2
open_noti_settings: ^0.4.0 open_noti_settings: ^0.4.0
package_info_plus: ^1.3.0 package_info_plus: ^1.3.0