fluffychat/lib/components/message_download_content.dart

61 lines
1.8 KiB
Dart
Raw Normal View History

2020-05-03 11:56:53 +02:00
import 'package:famedlysdk/famedlysdk.dart';
2020-05-07 07:52:40 +02:00
import 'package:fluffychat/l10n/l10n.dart';
2020-05-03 11:56:53 +02:00
import 'package:flutter/material.dart';
import 'package:fluffychat/utils/matrix_file_extension.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'dialogs/simple_dialogs.dart';
class MessageDownloadContent extends StatelessWidget {
final Event event;
final Color textColor;
const MessageDownloadContent(this.event, this.textColor, {Key key})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
color: Colors.blueGrey,
child: Text(
2020-05-07 07:52:40 +02:00
L10n.of(context).downloadFile,
2020-05-03 11:56:53 +02:00
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
style: TextStyle(color: Colors.white),
),
onPressed: () async {
final MatrixFile matrixFile =
await SimpleDialogs(context).tryRequestWithLoadingDialog(
event.downloadAndDecryptAttachment(),
);
matrixFile.open();
}),
Text(
2020-05-13 15:58:59 +02:00
'- ' +
(event.content.containsKey('filename')
? event.content['filename']
2020-05-03 11:56:53 +02:00
: event.body),
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
),
),
if (event.sizeString != null)
Text(
2020-05-13 15:58:59 +02:00
'- ' + event.sizeString,
2020-05-03 11:56:53 +02:00
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
),
),
],
),
);
}
}