This commit is contained in:
Salvatore Giordano
2020-12-03 11:39:38 +01:00
parent 9918a4bfde
commit 3d92d5fc32
2 changed files with 63 additions and 74 deletions
+35 -40
View File
@@ -18,50 +18,45 @@ class FileAttachment extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Material( return Material(
child: InkWell( child: Container(
onTap: () { width: size?.width ?? 100,
//launchURL(context, attachment.assetUrl); margin: trailing != null ? EdgeInsets.only(top: 4.0) : null,
}, decoration: BoxDecoration(
child: Container( color: Colors.white,
width: size?.width ?? 100, borderRadius: trailing != null ? BorderRadius.circular(16.0) : null,
margin: trailing != null ? EdgeInsets.only(top: 4.0) : null, border: trailing != null
decoration: BoxDecoration( ? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6)))
color: Colors.white, : null,
borderRadius: trailing != null ? BorderRadius.circular(16.0) : null, ),
border: trailing != null child: ListTile(
? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6))) dense: true,
: null, leading: Container(
child: _getFileTypeImage(attachment.extraData['mime_type']),
height: 40.0,
width: 33.33,
), ),
child: ListTile( title: Text(
dense: true, attachment?.title ?? 'File',
leading: Container( style: TextStyle(
child: _getFileTypeImage(attachment.extraData['mime_type']), fontWeight: FontWeight.bold,
height: 40.0,
width: 33.33,
), ),
title: Text( maxLines: 3,
attachment?.title ?? 'File', ),
style: TextStyle( subtitle: Text(
fontWeight: FontWeight.bold, '${attachment.extraData['file_size'] ?? 'N/A'} bytes',
), style: TextStyle(
maxLines: 3, color: Colors.black.withOpacity(0.5),
), ),
subtitle: Text( ),
'${attachment.extraData['file_size'] ?? 'N/A'} bytes', trailing: trailing ??
style: TextStyle( IconButton(
color: Colors.black.withOpacity(0.5), icon: StreamSvgIcon.cloud_download(
), color: Colors.black,
),
trailing: trailing ??
IconButton(
icon: StreamSvgIcon.cloud_download(
color: Colors.black,
),
onPressed: () {
launchURL(context, attachment.assetUrl);
},
), ),
), onPressed: () {
launchURL(context, attachment.assetUrl);
},
),
), ),
), ),
); );
+28 -34
View File
@@ -668,46 +668,40 @@ class _MessageWidgetState extends State<MessageWidget> {
[]; [];
} }
Padding wrapAttachmentWidget( Widget wrapAttachmentWidget(
BuildContext context, BuildContext context,
Widget attachmentWidget, { Widget attachmentWidget, {
Attachment attachment, Attachment attachment,
}) { }) {
final attachmentShape = final attachmentShape =
widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context); widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context);
return Padding( return GestureDetector(
padding: EdgeInsets.only( onTap: () => retryMessage(context),
bottom: 4, onLongPress: () => onLongPress(context),
), child: Material(
child: GestureDetector( color:
onTap: () => retryMessage(context), attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(),
onLongPress: () => onLongPress(context), clipBehavior: Clip.hardEdge,
child: Material( shape: attachmentShape,
color: attachment?.type == 'giphy' child: Padding(
? Colors.white padding: widget.attachmentPadding,
: _getBackgroundColor(), child: Material(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
shape: attachmentShape, shape: attachmentShape,
child: Padding( type: MaterialType.transparency,
padding: widget.attachmentPadding, child: Transform(
child: Material( transform: Matrix4.rotationY(widget.reverse ? pi : 0),
clipBehavior: Clip.hardEdge, alignment: Alignment.center,
shape: attachmentShape, child: Column(
type: MaterialType.transparency, mainAxisSize: MainAxisSize.min,
child: Transform( crossAxisAlignment: CrossAxisAlignment.end,
transform: Matrix4.rotationY(widget.reverse ? pi : 0), children: <Widget>[
alignment: Alignment.center, getFailedMessageWidget(
child: Column( context,
mainAxisSize: MainAxisSize.min, padding: const EdgeInsets.all(8.0),
crossAxisAlignment: CrossAxisAlignment.end, ),
children: <Widget>[ attachmentWidget,
getFailedMessageWidget( ],
context,
padding: const EdgeInsets.all(8.0),
),
attachmentWidget,
],
),
), ),
), ),
), ),