Better download content design

This commit is contained in:
Christian Pauly 2020-05-16 08:09:07 +02:00
parent e25e5f7e06
commit cf70aa37cf
2 changed files with 17 additions and 18 deletions

View file

@ -12,38 +12,34 @@ class MessageDownloadContent extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String filename = event.content.containsKey('filename')
? event.content['filename']
: event.body;
return Container( return Container(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
RaisedButton( RaisedButton(
color: Colors.blueGrey, color: textColor,
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: Text( child: Text(
L10n.of(context).downloadFile, filename,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
softWrap: false, softWrap: false,
maxLines: 1, maxLines: 1,
style: TextStyle(color: Colors.white), style: TextStyle(color: Theme.of(context).primaryColor),
), ),
onPressed: () => event.openFile(context), onPressed: () => event.openFile(context),
), ),
Text(
'- ' +
(event.content.containsKey('filename')
? event.content['filename']
: event.body),
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
),
),
if (event.sizeString != null) if (event.sizeString != null)
Text( Text(
'- ' + event.sizeString, event.sizeString,
style: TextStyle( style: TextStyle(
color: textColor, color: textColor,
fontWeight: FontWeight.bold,
), ),
), ),
], ],

View file

@ -40,13 +40,16 @@ extension LocalizedBody on Event {
num size = content['info']['size']; num size = content['info']['size'];
if (size < 1000000) { if (size < 1000000) {
size = size / 1000; size = size / 1000;
return '${size.toString()}kb'; size = (size * 10).round() / 10;
return '${size.toString()} KB';
} else if (size < 1000000000) { } else if (size < 1000000000) {
size = size / 1000000; size = size / 1000000;
return '${size.toString()}mb'; size = (size * 10).round() / 10;
return '${size.toString()} MB';
} else { } else {
size = size / 1000000000; size = size / 1000000000;
return '${size.toString()}gb'; size = (size * 10).round() / 10;
return '${size.toString()} GB';
} }
} else { } else {
return null; return null;