allow sending emoji/stickers from emote packs
This commit is contained in:
parent
868023a4a1
commit
3754bc2feb
1 changed files with 701 additions and 74 deletions
29
lib/helpers/extensions/image_pack_emoji.dart
Normal file
29
lib/helpers/extensions/image_pack_emoji.dart
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:material_emoji_picker/material_emoji_picker.dart";
|
||||
import "package:nexus/models/content/image_pack.dart";
|
||||
import "package:nexus/models/image_pack.dart";
|
||||
import "package:nexus/widgets/mxc_emoji.dart";
|
||||
|
||||
extension ImagePackEmoji on ImagePack {
|
||||
EmojiCategory? get emojiCategory => _category(emoticons);
|
||||
EmojiCategory? get stickerCategory => _category(stickers);
|
||||
|
||||
EmojiCategory? _category(IMap<String, PackImage> images) => images.isEmpty
|
||||
? null
|
||||
: .new(
|
||||
icon: MxcEmoji(avatar ?? images.values.first.url),
|
||||
name: name,
|
||||
emojis: images
|
||||
.mapTo(
|
||||
(shortcode, image) => Emoji(
|
||||
widget: MxcEmoji(image.url, label: shortcode),
|
||||
value: image.url.toString(),
|
||||
aliases: .new([shortcode]),
|
||||
description: image.body ?? shortcode,
|
||||
tags: const .empty(),
|
||||
data: image,
|
||||
),
|
||||
)
|
||||
.toIList(),
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue