From 3d92d5fc32403eb01d300ac940a25b8f5da59ec6 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 2 Dec 2020 15:11:04 +0100 Subject: [PATCH] ui fix --- lib/src/file_attachment.dart | 75 +++++++++++++++++------------------- lib/src/message_widget.dart | 62 ++++++++++++++--------------- 2 files changed, 63 insertions(+), 74 deletions(-) diff --git a/lib/src/file_attachment.dart b/lib/src/file_attachment.dart index fd6f152a..168e7989 100644 --- a/lib/src/file_attachment.dart +++ b/lib/src/file_attachment.dart @@ -18,50 +18,45 @@ class FileAttachment extends StatelessWidget { @override Widget build(BuildContext context) { return Material( - child: InkWell( - onTap: () { - //launchURL(context, attachment.assetUrl); - }, - child: Container( - width: size?.width ?? 100, - margin: trailing != null ? EdgeInsets.only(top: 4.0) : null, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: trailing != null ? BorderRadius.circular(16.0) : null, - border: trailing != null - ? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6))) - : null, + child: Container( + width: size?.width ?? 100, + margin: trailing != null ? EdgeInsets.only(top: 4.0) : null, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: trailing != null ? BorderRadius.circular(16.0) : null, + border: trailing != null + ? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6))) + : null, + ), + child: ListTile( + dense: true, + leading: Container( + child: _getFileTypeImage(attachment.extraData['mime_type']), + height: 40.0, + width: 33.33, ), - child: ListTile( - dense: true, - leading: Container( - child: _getFileTypeImage(attachment.extraData['mime_type']), - height: 40.0, - width: 33.33, + title: Text( + attachment?.title ?? 'File', + style: TextStyle( + fontWeight: FontWeight.bold, ), - title: Text( - attachment?.title ?? 'File', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - maxLines: 3, + maxLines: 3, + ), + subtitle: Text( + '${attachment.extraData['file_size'] ?? 'N/A'} bytes', + style: TextStyle( + color: Colors.black.withOpacity(0.5), ), - subtitle: Text( - '${attachment.extraData['file_size'] ?? 'N/A'} bytes', - style: TextStyle( - color: Colors.black.withOpacity(0.5), - ), - ), - trailing: trailing ?? - IconButton( - icon: StreamSvgIcon.cloud_download( - color: Colors.black, - ), - onPressed: () { - launchURL(context, attachment.assetUrl); - }, + ), + trailing: trailing ?? + IconButton( + icon: StreamSvgIcon.cloud_download( + color: Colors.black, ), - ), + onPressed: () { + launchURL(context, attachment.assetUrl); + }, + ), ), ), ); diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 6a35648d..7c007735 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -668,46 +668,40 @@ class _MessageWidgetState extends State { []; } - Padding wrapAttachmentWidget( + Widget wrapAttachmentWidget( BuildContext context, Widget attachmentWidget, { Attachment attachment, }) { final attachmentShape = widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context); - return Padding( - padding: EdgeInsets.only( - bottom: 4, - ), - child: GestureDetector( - onTap: () => retryMessage(context), - onLongPress: () => onLongPress(context), - child: Material( - color: attachment?.type == 'giphy' - ? Colors.white - : _getBackgroundColor(), - clipBehavior: Clip.hardEdge, - shape: attachmentShape, - child: Padding( - padding: widget.attachmentPadding, - child: Material( - clipBehavior: Clip.hardEdge, - shape: attachmentShape, - type: MaterialType.transparency, - child: Transform( - transform: Matrix4.rotationY(widget.reverse ? pi : 0), - alignment: Alignment.center, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - getFailedMessageWidget( - context, - padding: const EdgeInsets.all(8.0), - ), - attachmentWidget, - ], - ), + return GestureDetector( + onTap: () => retryMessage(context), + onLongPress: () => onLongPress(context), + child: Material( + color: + attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(), + clipBehavior: Clip.hardEdge, + shape: attachmentShape, + child: Padding( + padding: widget.attachmentPadding, + child: Material( + clipBehavior: Clip.hardEdge, + shape: attachmentShape, + type: MaterialType.transparency, + child: Transform( + transform: Matrix4.rotationY(widget.reverse ? pi : 0), + alignment: Alignment.center, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + getFailedMessageWidget( + context, + padding: const EdgeInsets.all(8.0), + ), + attachmentWidget, + ], ), ), ),