2020-01-19 15:07:42 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-05-07 11:19:29 +02:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-01-19 15:07:42 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
extension LocalizedBody on Event {
|
2020-03-13 20:09:32 +01:00
|
|
|
IconData get statusIcon {
|
2020-05-13 15:58:59 +02:00
|
|
|
switch (status) {
|
2020-03-13 20:09:32 +01:00
|
|
|
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 21:58:48 +01:00
|
|
|
|
2020-05-07 11:19:29 +02:00
|
|
|
bool get showThumbnail =>
|
2020-05-10 13:26:52 +02:00
|
|
|
[MessageTypes.Image, MessageTypes.Sticker].contains(messageType) &&
|
2020-05-09 16:38:27 +02:00
|
|
|
(kIsWeb ||
|
2020-05-10 13:26:52 +02:00
|
|
|
(content['info'] is Map &&
|
2020-05-13 15:58:59 +02:00
|
|
|
content['info']['size'] < room.client.database.maxFileSize));
|
2020-05-07 11:19:29 +02:00
|
|
|
|
2020-03-13 21:58:48 +01:00
|
|
|
String get sizeString {
|
2020-05-13 15:58:59 +02:00
|
|
|
if (content['info'] is Map<String, dynamic> &&
|
|
|
|
content['info'].containsKey('size')) {
|
|
|
|
num size = content['info']['size'];
|
2020-03-13 21:58:48 +01:00
|
|
|
if (size < 1000000) {
|
|
|
|
size = size / 1000;
|
2020-05-13 15:58:59 +02:00
|
|
|
return '${size.toString()}kb';
|
2020-03-13 21:58:48 +01:00
|
|
|
} else if (size < 1000000000) {
|
|
|
|
size = size / 1000000;
|
2020-05-13 15:58:59 +02:00
|
|
|
return '${size.toString()}mb';
|
2020-03-13 21:58:48 +01:00
|
|
|
} else {
|
|
|
|
size = size / 1000000000;
|
2020-05-13 15:58:59 +02:00
|
|
|
return '${size.toString()}gb';
|
2020-03-13 21:58:48 +01:00
|
|
|
}
|
2020-03-14 11:05:28 +01:00
|
|
|
} else {
|
2020-03-13 21:58:48 +01:00
|
|
|
return null;
|
2020-03-14 11:05:28 +01:00
|
|
|
}
|
2020-03-13 21:58:48 +01:00
|
|
|
}
|
2020-01-19 15:07:42 +01:00
|
|
|
}
|