2022-01-02 10:12:03 +01:00
|
|
|
//@dart=2.12
|
|
|
|
|
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';
|
2020-05-03 11:56:53 +02:00
|
|
|
|
|
|
|
class MessageDownloadContent extends StatelessWidget {
|
|
|
|
final Event event;
|
|
|
|
final Color textColor;
|
|
|
|
|
2022-01-02 10:12:03 +01:00
|
|
|
const MessageDownloadContent(this.event, this.textColor, {Key? key})
|
2020-05-03 11:56:53 +02:00
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-01-02 10:12:03 +01:00
|
|
|
final filename = event.content.tryGet<String>('filename') ?? event.body;
|
|
|
|
final filetype = (filename.contains('.')
|
|
|
|
? filename.split('.').last.toUpperCase()
|
|
|
|
: event.content
|
|
|
|
.tryGetMap<String, dynamic>('info')
|
|
|
|
?.tryGet<String>('mimetype')
|
|
|
|
?.toUpperCase() ??
|
|
|
|
'UNKNOWN');
|
|
|
|
final sizeString = event.sizeString;
|
|
|
|
return InkWell(
|
|
|
|
onTap: () => event.saveFile(context),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.file_download_outlined,
|
2022-01-02 12:31:10 +01:00
|
|
|
color: textColor,
|
2022-01-02 10:12:03 +01:00
|
|
|
),
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
filename,
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
2022-01-02 12:31:10 +01:00
|
|
|
color: textColor,
|
2022-01-02 10:12:03 +01:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
filetype,
|
|
|
|
style: TextStyle(
|
2022-01-02 12:31:10 +01:00
|
|
|
color: textColor.withAlpha(150),
|
2022-01-02 10:12:03 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
if (sizeString != null)
|
|
|
|
Text(
|
|
|
|
sizeString,
|
|
|
|
style: TextStyle(
|
2022-01-02 12:31:10 +01:00
|
|
|
color: textColor.withAlpha(150),
|
2022-01-02 10:12:03 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2021-10-14 18:09:30 +02:00
|
|
|
),
|
2022-01-02 10:12:03 +01:00
|
|
|
],
|
|
|
|
),
|
2020-05-03 11:56:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|