Minor tweaks
This commit is contained in:
parent
01b1b56852
commit
4900137e2a
|
@ -59,65 +59,45 @@ class MessageContent extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
case MessageTypes.Audio:
|
||||
return Container(
|
||||
width: 200,
|
||||
child: RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(Icons.play_arrow, color: Colors.white),
|
||||
Text(
|
||||
I18n.of(context).play(event.body),
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () => launch(MxContent(event.content["url"])
|
||||
.getDownloadLink(event.room.client)),
|
||||
),
|
||||
);
|
||||
case MessageTypes.Video:
|
||||
case MessageTypes.File:
|
||||
return Container(
|
||||
width: 200,
|
||||
child: RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Row(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(Icons.play_arrow, color: Colors.white),
|
||||
Text(
|
||||
I18n.of(context).play(event.body),
|
||||
RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
I18n.of(context).downloadFile,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () => launch(
|
||||
MxContent(event.content["url"])
|
||||
.getDownloadLink(event.room.client),
|
||||
),
|
||||
),
|
||||
);
|
||||
case MessageTypes.File:
|
||||
return Container(
|
||||
width: 200,
|
||||
child: RaisedButton(
|
||||
color: Colors.blueGrey,
|
||||
child: Text(
|
||||
I18n.of(context).download(event.body),
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.white),
|
||||
if (event.sizeString != null)
|
||||
Text(
|
||||
event.sizeString,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
onPressed: () => launch(
|
||||
MxContent(event.content["url"])
|
||||
.getDownloadLink(Matrix.of(context).client),
|
||||
),
|
||||
Text(
|
||||
(event.content.containsKey("filename")
|
||||
? event.content["filename"]
|
||||
: event.body),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
case MessageTypes.BadEncrypted:
|
||||
|
|
|
@ -272,11 +272,7 @@ class I18n {
|
|||
String get displaynameHasBeenChanged =>
|
||||
Intl.message("Displayname has been changed");
|
||||
|
||||
String download(String fileName) => Intl.message(
|
||||
"Download $fileName",
|
||||
name: "download",
|
||||
args: [fileName],
|
||||
);
|
||||
String get downloadFile => Intl.message("Download file");
|
||||
|
||||
String get editDisplayname => Intl.message("Edit displayname");
|
||||
|
||||
|
@ -296,6 +292,10 @@ class I18n {
|
|||
|
||||
String get enterAUsername => Intl.message("Enter a username");
|
||||
|
||||
String get fileName => Intl.message("File name");
|
||||
|
||||
String get fileSize => Intl.message("File size");
|
||||
|
||||
String get fluffychat => Intl.message("FluffyChat");
|
||||
|
||||
String get forward => Intl.message('Forward');
|
||||
|
|
|
@ -260,4 +260,22 @@ extension LocalizedBody on Event {
|
|||
return Icons.done;
|
||||
}
|
||||
}
|
||||
|
||||
String get sizeString {
|
||||
if (content["info"] is Map<String, dynamic> &&
|
||||
content["info"].containsKey("size")) {
|
||||
num size = content["info"]["size"];
|
||||
if (size < 1000000) {
|
||||
size = size / 1000;
|
||||
return "${size.toString()}kb";
|
||||
} else if (size < 1000000000) {
|
||||
size = size / 1000000;
|
||||
return "${size.toString()}mb";
|
||||
} else {
|
||||
size = size / 1000000000;
|
||||
return "${size.toString()}gb";
|
||||
}
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue