From dffad3d6bca6b94454f5af37083d9c32e5b383f4 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 3 Dec 2020 14:54:58 +0530 Subject: [PATCH] fix: fixed sizes of file attachment --- lib/src/file_attachment.dart | 107 ++++++++++++++++++++++++++--------- lib/src/message_input.dart | 24 +++++--- 2 files changed, 98 insertions(+), 33 deletions(-) diff --git a/lib/src/file_attachment.dart b/lib/src/file_attachment.dart index 168e7989..fff13bbe 100644 --- a/lib/src/file_attachment.dart +++ b/lib/src/file_attachment.dart @@ -20,6 +20,7 @@ class FileAttachment extends StatelessWidget { return Material( child: Container( width: size?.width ?? 100, + height: 56.0, margin: trailing != null ? EdgeInsets.only(top: 4.0) : null, decoration: BoxDecoration( color: Colors.white, @@ -28,36 +29,90 @@ class FileAttachment extends StatelessWidget { ? 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, - ), - title: Text( - attachment?.title ?? 'File', - style: TextStyle( - fontWeight: FontWeight.bold, + child: Row( + children: [ + Container( + child: _getFileTypeImage(attachment.extraData['mime_type']), + height: 40.0, + width: 33.33, + margin: EdgeInsets.all(8.0), ), - maxLines: 3, - ), - subtitle: Text( - '${attachment.extraData['file_size'] ?? 'N/A'} bytes', - style: TextStyle( - color: Colors.black.withOpacity(0.5), + SizedBox( + width: 6.0, ), - ), - trailing: trailing ?? - IconButton( - icon: StreamSvgIcon.cloud_download( - color: Colors.black, - ), - onPressed: () { - launchURL(context, attachment.assetUrl); - }, + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + attachment?.title ?? 'File', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + SizedBox( + height: 3.0, + ), + Text( + '${attachment.extraData['file_size'] ?? 'N/A'} bytes', + style: TextStyle( + color: Colors.black.withOpacity(0.5), + fontSize: 14.0, + ), + ), + ], ), + ), + Column( + children: [ + trailing ?? + IconButton( + icon: StreamSvgIcon.cloud_download( + color: Colors.black, + ), + onPressed: () { + launchURL(context, attachment.assetUrl); + }, + ), + ], + ), + ], ), + + // 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, + // ), + // maxLines: 3, + // ), + // 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); + // }, + // ), + // ), ), ); } diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 04c9b3d1..3ebcef21 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -1254,13 +1254,23 @@ class MessageInputState extends State { MediaQuery.of(context).size.width * 0.55, MediaQuery.of(context).size.height * 0.3, ), - trailing: IconButton( - icon: StreamSvgIcon.close_small(), - onPressed: () { - setState(() { - _attachments.remove(e); - }); - }, + trailing: Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + child: CircleAvatar( + backgroundColor: + Colors.black.withOpacity(0.2), + maxRadius: 12.0, + child: StreamSvgIcon.close( + color: Colors.white, + ), + ), + onTap: () { + setState(() { + _attachments.remove(e); + }); + }, + ), ), ), ),