|
|
@ -1,5 +1,3 @@
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
@ -33,6 +31,8 @@ class SendFileDialogState extends State<SendFileDialog> {
|
|
|
|
static const int minSizeToCompress = 20 * 1024;
|
|
|
|
static const int minSizeToCompress = 20 * 1024;
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _send() async {
|
|
|
|
Future<void> _send() async {
|
|
|
|
|
|
|
|
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
|
|
|
|
|
|
|
final l10n = L10n.of(context)!;
|
|
|
|
for (var file in widget.files) {
|
|
|
|
for (var file in widget.files) {
|
|
|
|
MatrixImageFile? thumbnail;
|
|
|
|
MatrixImageFile? thumbnail;
|
|
|
|
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
|
|
|
|
if (file is MatrixVideoFile && file.bytes.length > minSizeToCompress) {
|
|
|
@ -44,20 +44,24 @@ class SendFileDialogState extends State<SendFileDialog> {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
widget.room
|
|
|
|
await widget.room.sendFileEvent(
|
|
|
|
.sendFileEvent(
|
|
|
|
file,
|
|
|
|
file,
|
|
|
|
thumbnail: thumbnail,
|
|
|
|
thumbnail: thumbnail,
|
|
|
|
shrinkImageMaxDimension: origImage ? null : 1600,
|
|
|
|
shrinkImageMaxDimension: origImage ? null : 1600,
|
|
|
|
);
|
|
|
|
)
|
|
|
|
} on IOException catch (_) {
|
|
|
|
.catchError(
|
|
|
|
} on FileTooBigMatrixException catch (_) {
|
|
|
|
(e, s) {
|
|
|
|
} catch (e, s) {
|
|
|
|
if (e is FileTooBigMatrixException) {
|
|
|
|
if (mounted) {
|
|
|
|
scaffoldMessenger.showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(content: Text(l10n.fileIsTooBigForServer)),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
ErrorReporter(context, 'Unable to send file').onErrorCallback(e, s);
|
|
|
|
ErrorReporter(context, 'Unable to send file').onErrorCallback(e, s);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
rethrow;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Navigator.of(context, rootNavigator: false).pop();
|
|
|
|
Navigator.of(context, rootNavigator: false).pop();
|
|
|
|
|
|
|
|
|
|
|
|