mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 14:32:37 +01:00
fix: Send file
This commit is contained in:
parent
913f3cfa70
commit
fde2f8b2a8
@ -10,8 +10,14 @@ import '../../utils/resize_image.dart';
|
|||||||
class SendFileDialog extends StatefulWidget {
|
class SendFileDialog extends StatefulWidget {
|
||||||
final Room room;
|
final Room room;
|
||||||
final MatrixFile file;
|
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
|
@override
|
||||||
_SendFileDialogState createState() => _SendFileDialogState();
|
_SendFileDialogState createState() => _SendFileDialogState();
|
||||||
@ -34,13 +40,13 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var sendStr = L10n.of(context).sendFile;
|
var sendStr = widget.l10n.sendFile;
|
||||||
if (widget.file is MatrixImageFile) {
|
if (widget.file is MatrixImageFile) {
|
||||||
sendStr = L10n.of(context).sendImage;
|
sendStr = widget.l10n.sendImage;
|
||||||
} else if (widget.file is MatrixAudioFile) {
|
} else if (widget.file is MatrixAudioFile) {
|
||||||
sendStr = L10n.of(context).sendAudio;
|
sendStr = widget.l10n.sendAudio;
|
||||||
} else if (widget.file is MatrixVideoFile) {
|
} else if (widget.file is MatrixVideoFile) {
|
||||||
sendStr = L10n.of(context).sendVideo;
|
sendStr = widget.l10n.sendVideo;
|
||||||
}
|
}
|
||||||
Widget contentWidget;
|
Widget contentWidget;
|
||||||
if (widget.file is MatrixImageFile) {
|
if (widget.file is MatrixImageFile) {
|
||||||
@ -60,8 +66,8 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => setState(() => origImage = !origImage),
|
onTap: () => setState(() => origImage = !origImage),
|
||||||
child: Text(L10n.of(context).sendOriginal +
|
child: Text(
|
||||||
' (${widget.file.sizeString})'),
|
widget.l10n.sendOriginal + ' (${widget.file.sizeString})'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -74,14 +80,14 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||||||
content: contentWidget,
|
content: contentWidget,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(L10n.of(context).cancel),
|
child: Text(widget.l10n.cancel),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// just close the dialog
|
// just close the dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(L10n.of(context).send),
|
child: Text(widget.l10n.send),
|
||||||
onPressed: _isSending
|
onPressed: _isSending
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
|
@ -94,6 +94,7 @@ class ChatListItem extends StatelessWidget {
|
|||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
file: Matrix.of(context).shareContent['file'],
|
file: Matrix.of(context).shareContent['file'],
|
||||||
room: room,
|
room: room,
|
||||||
|
l10n: L10n.of(context),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
unawaited(room.sendEvent(Matrix.of(context).shareContent));
|
unawaited(room.sendEvent(Matrix.of(context).shareContent));
|
||||||
|
@ -214,12 +214,13 @@ class _ChatState extends State<Chat> {
|
|||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
file: MatrixFile(
|
file: MatrixFile(
|
||||||
bytes: result.toUint8List(),
|
bytes: result.toUint8List(),
|
||||||
name: result.fileName,
|
name: result.fileName,
|
||||||
).detectFileType,
|
).detectFileType,
|
||||||
room: room,
|
room: room,
|
||||||
|
l10n: L10n.of(context),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -230,12 +231,13 @@ class _ChatState extends State<Chat> {
|
|||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
file: MatrixImageFile(
|
file: MatrixImageFile(
|
||||||
bytes: result.toUint8List(),
|
bytes: result.toUint8List(),
|
||||||
name: result.fileName,
|
name: result.fileName,
|
||||||
),
|
),
|
||||||
room: room,
|
room: room,
|
||||||
|
l10n: L10n.of(context),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -246,12 +248,13 @@ class _ChatState extends State<Chat> {
|
|||||||
final bytes = await file.readAsBytes();
|
final bytes = await file.readAsBytes();
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
file: MatrixImageFile(
|
file: MatrixImageFile(
|
||||||
bytes: bytes,
|
bytes: bytes,
|
||||||
name: file.path,
|
name: file.path,
|
||||||
),
|
),
|
||||||
room: room,
|
room: room,
|
||||||
|
l10n: L10n.of(context),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
11
pubspec.lock
11
pubspec.lock
@ -247,21 +247,14 @@ packages:
|
|||||||
name: file_picker
|
name: file_picker
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.13.3"
|
version: "2.1.5+1"
|
||||||
file_picker_cross:
|
file_picker_cross:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: file_picker_cross
|
name: file_picker_cross
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.2"
|
version: "4.2.7"
|
||||||
file_picker_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_picker_platform_interface
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
firebase:
|
firebase:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -16,7 +16,7 @@ dependencies:
|
|||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
localstorage: ^3.0.6+9
|
localstorage: ^3.0.6+9
|
||||||
file_picker_cross: 4.2.2
|
file_picker_cross: ^4.2.7
|
||||||
image_picker: ^0.6.7+21
|
image_picker: ^0.6.7+21
|
||||||
url_launcher: ^5.7.10
|
url_launcher: ^5.7.10
|
||||||
cached_network_image: ^2.5.0
|
cached_network_image: ^2.5.0
|
||||||
|
Loading…
Reference in New Issue
Block a user