fix: fixed sizes of file attachment

This commit is contained in:
Deven Joshi
2020-12-03 11:39:38 +01:00
committed by Salvatore Giordano
parent c4c0f97f34
commit dffad3d6bc
2 changed files with 98 additions and 33 deletions
+81 -26
View File
@@ -20,6 +20,7 @@ class FileAttachment extends StatelessWidget {
return Material( return Material(
child: Container( child: Container(
width: size?.width ?? 100, width: size?.width ?? 100,
height: 56.0,
margin: trailing != null ? EdgeInsets.only(top: 4.0) : null, margin: trailing != null ? EdgeInsets.only(top: 4.0) : null,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@@ -28,36 +29,90 @@ class FileAttachment extends StatelessWidget {
? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6))) ? Border.fromBorderSide(BorderSide(color: Color(0xFFE6E6E6)))
: null, : null,
), ),
child: ListTile( child: Row(
dense: true, children: [
leading: Container( Container(
child: _getFileTypeImage(attachment.extraData['mime_type']), child: _getFileTypeImage(attachment.extraData['mime_type']),
height: 40.0, height: 40.0,
width: 33.33, width: 33.33,
), margin: EdgeInsets.all(8.0),
title: Text(
attachment?.title ?? 'File',
style: TextStyle(
fontWeight: FontWeight.bold,
), ),
maxLines: 3, SizedBox(
), width: 6.0,
subtitle: Text(
'${attachment.extraData['file_size'] ?? 'N/A'} bytes',
style: TextStyle(
color: Colors.black.withOpacity(0.5),
), ),
), Expanded(
trailing: trailing ?? child: Column(
IconButton( mainAxisAlignment: MainAxisAlignment.center,
icon: StreamSvgIcon.cloud_download( crossAxisAlignment: CrossAxisAlignment.start,
color: Colors.black, children: [
), Text(
onPressed: () { attachment?.title ?? 'File',
launchURL(context, attachment.assetUrl); 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);
// },
// ),
// ),
), ),
); );
} }
+17 -7
View File
@@ -1254,13 +1254,23 @@ class MessageInputState extends State<MessageInput> {
MediaQuery.of(context).size.width * 0.55, MediaQuery.of(context).size.width * 0.55,
MediaQuery.of(context).size.height * 0.3, MediaQuery.of(context).size.height * 0.3,
), ),
trailing: IconButton( trailing: Padding(
icon: StreamSvgIcon.close_small(), padding: const EdgeInsets.all(8.0),
onPressed: () { child: InkWell(
setState(() { child: CircleAvatar(
_attachments.remove(e); backgroundColor:
}); Colors.black.withOpacity(0.2),
}, maxRadius: 12.0,
child: StreamSvgIcon.close(
color: Colors.white,
),
),
onTap: () {
setState(() {
_attachments.remove(e);
});
},
),
), ),
), ),
), ),