FurryChat/lib/utils/event_extension.dart

46 lines
1.2 KiB
Dart
Raw Normal View History

2020-01-19 14:07:42 +00:00
import 'package:famedlysdk/famedlysdk.dart';
2020-05-07 09:19:29 +00:00
import 'package:flutter/foundation.dart';
2020-01-19 14:07:42 +00:00
import 'package:flutter/material.dart';
extension LocalizedBody on Event {
2020-03-13 19:09:32 +00:00
IconData get statusIcon {
switch (this.status) {
case -1:
return Icons.error_outline;
case 0:
return Icons.timer;
case 1:
return Icons.done;
case 2:
return Icons.done_all;
default:
return Icons.done;
}
}
2020-03-13 20:58:48 +00:00
2020-05-07 09:19:29 +00:00
bool get showThumbnail =>
2020-05-10 11:26:52 +00:00
[MessageTypes.Image, MessageTypes.Sticker].contains(messageType) &&
(kIsWeb ||
2020-05-10 11:26:52 +00:00
(content['info'] is Map &&
content['info']['size'] < room.client.store.maxFileSize));
2020-05-07 09:19:29 +00:00
2020-03-13 20:58:48 +00:00
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";
}
2020-03-14 10:05:28 +00:00
} else {
2020-03-13 20:58:48 +00:00
return null;
2020-03-14 10:05:28 +00:00
}
2020-03-13 20:58:48 +00:00
}
2020-01-19 14:07:42 +00:00
}