[LLC, UI-KIT] Add support for custom attachment upload delegate

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-02-05 14:57:17 +05:30
parent f18d2c37bf
commit 628542f99b
12 changed files with 418 additions and 243 deletions
@@ -1,5 +1,7 @@
import 'package:characters/characters.dart';
import 'package:emojis/emoji.dart';
import 'package:http_parser/http_parser.dart' as http_parser;
import 'package:mime/mime.dart';
final _emojis = Emoji.all();
@@ -10,15 +12,27 @@ extension StringExtension on String {
return '${this[0].toUpperCase()}${substring(1)}';
}
// Emojis guidelines
// 1 to 3 emojis: big size with no text bubble.
// 4+ emojis or emojis+text: standard size with text bubble.
/// Returns whether the string contains only emoji's or not.
///
/// Emojis guidelines
/// 1 to 3 emojis: big size with no text bubble.
/// 4+ emojis or emojis+text: standard size with text bubble.
bool get isOnlyEmoji {
final characters = trim().characters;
if (characters.isEmpty) return false;
if (characters.length > 3) return false;
return characters.every((c) => _emojis.map((e) => e.char).contains(c));
}
/// Returns the mime type from the passed file name.
http_parser.MediaType get mimeType {
if (this == null) return null;
if (toLowerCase().endsWith('heic')) {
return http_parser.MediaType.parse('image/heic');
} else {
return http_parser.MediaType.parse(lookupMimeType(this));
}
}
}
/// List extension