2020-05-03 11:56:53 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
2021-05-22 09:24:39 +02:00
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
|
2021-11-15 07:59:51 +01:00
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2020-05-03 11:56:53 +02:00
|
|
|
|
|
|
|
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) {
|
2020-05-16 08:09:07 +02:00
|
|
|
final String filename = event.content.containsKey('filename')
|
|
|
|
? event.content['filename']
|
|
|
|
: event.body;
|
2021-10-14 18:09:30 +02:00
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
2021-11-14 18:57:48 +01:00
|
|
|
TextButton.icon(
|
2021-10-14 18:09:30 +02:00
|
|
|
onPressed: () => event.saveFile(context),
|
2021-11-14 18:57:48 +01:00
|
|
|
icon: const Icon(Icons.download_outlined),
|
|
|
|
label: Text(filename),
|
2021-11-15 07:59:51 +01:00
|
|
|
style: event.senderId == Matrix.of(context).client.userID
|
|
|
|
? TextButton.styleFrom(primary: textColor)
|
|
|
|
: null,
|
2021-10-14 18:09:30 +02:00
|
|
|
),
|
|
|
|
if (event.sizeString != null)
|
|
|
|
Text(
|
|
|
|
event.sizeString,
|
|
|
|
style: TextStyle(
|
|
|
|
color: textColor,
|
2020-05-03 11:56:53 +02:00
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
),
|
|
|
|
],
|
2020-05-03 11:56:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|