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
+62 -7
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,27 +29,47 @@ 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( SizedBox(
width: 6.0,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
attachment?.title ?? 'File', attachment?.title ?? 'File',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 14.0,
), ),
maxLines: 3, maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
subtitle: Text( SizedBox(
height: 3.0,
),
Text(
'${attachment.extraData['file_size'] ?? 'N/A'} bytes', '${attachment.extraData['file_size'] ?? 'N/A'} bytes',
style: TextStyle( style: TextStyle(
color: Colors.black.withOpacity(0.5), color: Colors.black.withOpacity(0.5),
fontSize: 14.0,
), ),
), ),
trailing: trailing ?? ],
),
),
Column(
children: [
trailing ??
IconButton( IconButton(
icon: StreamSvgIcon.cloud_download( icon: StreamSvgIcon.cloud_download(
color: Colors.black, color: Colors.black,
@@ -57,7 +78,41 @@ class FileAttachment extends StatelessWidget {
launchURL(context, attachment.assetUrl); 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);
// },
// ),
// ),
), ),
); );
} }
+13 -3
View File
@@ -1254,9 +1254,18 @@ 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(
child: CircleAvatar(
backgroundColor:
Colors.black.withOpacity(0.2),
maxRadius: 12.0,
child: StreamSvgIcon.close(
color: Colors.white,
),
),
onTap: () {
setState(() { setState(() {
_attachments.remove(e); _attachments.remove(e);
}); });
@@ -1264,6 +1273,7 @@ class MessageInputState extends State<MessageInput> {
), ),
), ),
), ),
),
) )
.toList(), .toList(),
), ),