TLA Line data Source code
1 : // Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
2 : //
3 : // This file is part of Flipdare's proprietary software and contains
4 : // confidential and copyrighted material. Unauthorised copying,
5 : // modification, distribution, or use of this file is strictly
6 : // prohibited without prior written permission from Flipdare Pty Ltd.
7 : //
8 : // This software includes third-party components licensed under MIT,
9 : // BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
10 : //
11 :
12 : import 'package:core/admin/logging.dart' show LOG;
13 : import 'package:emoji_extension/emoji_extension.dart';
14 :
15 : class EmojiString {
16 : final String raw;
17 :
18 HIT 1 : const EmojiString(this.raw);
19 :
20 : /// Encodes emojis in the raw string to their corresponding shortcodes.
21 1 : String get encode {
22 : // check if raw already contains encoded emojis
23 3 : if (!raw.emojis.contains) {
24 4 : LOG.d('encode: no emojis found or emojis already encoded in $raw');
25 1 : return raw;
26 : }
27 :
28 3 : return raw.emojis.toShortcodes();
29 : }
30 :
31 : /// Decodes shortcodes in the raw string back to their corresponding emojis.
32 1 : String get decode {
33 3 : return raw.emojis.fromShortcodes();
34 : }
35 : }
|