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
Widget build(BuildContext context) {
final String filename = event.content.containsKey('filename')
? event.content['filename']
: event.body;
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
color: Colors.blueGrey,
color: textColor,
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
L10n.of(context).downloadFile,
filename,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
style: TextStyle(color: Colors.white),
style: TextStyle(color: Theme.of(context).primaryColor),
),
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)
Text(
'- ' + event.sizeString,
event.sizeString,
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
),
),
],

View file

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