💄 Fixes and improvements
This commit is contained in:
		| @@ -32,7 +32,7 @@ class Sticker { | ||||
|     required this.account, | ||||
|   }); | ||||
|  | ||||
|   String get textPlaceholder => '${pack?.prefix}$alias'.camelCase!; | ||||
|   String get textPlaceholder => '${pack?.prefix}$alias'; | ||||
|   String get textWarpedPlaceholder => ':$textPlaceholder:'; | ||||
|  | ||||
|   String get imageUrl => ServiceFinder.buildUrl( | ||||
|   | ||||
| @@ -8,6 +8,9 @@ class StickerProvider extends GetxController { | ||||
|   final RxList<Sticker> availableStickers = RxList.empty(growable: true); | ||||
|  | ||||
|   Future<void> refreshAvailableStickers() async { | ||||
|     availableStickers.clear(); | ||||
|     aliasImageMapping.clear(); | ||||
|  | ||||
|     final client = ServiceFinder.configureClient('files'); | ||||
|     final resp = await client.get( | ||||
|       '/stickers/manifest?take=100', | ||||
| @@ -20,7 +23,7 @@ class StickerProvider extends GetxController { | ||||
|       for (final pack in out) { | ||||
|         for (final sticker in (pack.stickers ?? List<Sticker>.empty())) { | ||||
|           sticker.pack = pack; | ||||
|           aliasImageMapping['${pack.prefix}${sticker.alias}'.camelCase!] = | ||||
|           aliasImageMapping[sticker.textPlaceholder.toUpperCase()] = | ||||
|               sticker.imageUrl; | ||||
|           availableStickers.add(sticker); | ||||
|         } | ||||
|   | ||||
| @@ -70,7 +70,7 @@ class _StickerScreenState extends State<StickerScreen> { | ||||
|     ); | ||||
|     return ListTile( | ||||
|       title: Text(item.name), | ||||
|       subtitle: Text(':${'$prefix${item.alias}'.camelCase}:'), | ||||
|       subtitle: Text(item.textWarpedPlaceholder), | ||||
|       contentPadding: const EdgeInsets.only(left: 16, right: 14), | ||||
|       trailing: Row( | ||||
|         mainAxisSize: MainAxisSize.min, | ||||
| @@ -174,9 +174,10 @@ class _StickerScreenState extends State<StickerScreen> { | ||||
|                       maxLines: 1, | ||||
|                       overflow: TextOverflow.ellipsis, | ||||
|                     ), | ||||
|                     children: item.stickers | ||||
|                             ?.map((x) => _buildEmoteEntry(x, item.prefix)) | ||||
|                             .toList() ?? | ||||
|                     children: item.stickers?.map((x) { | ||||
|                           x.pack = item; | ||||
|                           return _buildEmoteEntry(x, item.prefix); | ||||
|                         }).toList() ?? | ||||
|                         List.empty(), | ||||
|                   ); | ||||
|                 }, | ||||
|   | ||||
| @@ -239,7 +239,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> { | ||||
|     if (suggestion.type == 'emotes') { | ||||
|       insertText = suggestion.content; | ||||
|       startText = replaceText.replaceFirstMapped( | ||||
|         RegExp(r':(?:([a-z0-9_+-]+)~)?([a-z0-9_+-]+)$'), | ||||
|         RegExp(r':(?:([-\w]+)~)?([-\w]+)$'), | ||||
|         (Match m) => insertText, | ||||
|       ); | ||||
|     } | ||||
| @@ -247,7 +247,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> { | ||||
|     if (suggestion.type == 'users') { | ||||
|       insertText = suggestion.content; | ||||
|       startText = replaceText.replaceFirstMapped( | ||||
|         RegExp(r'(?:\s|^)@([a-z0-9_+-]+)$'), | ||||
|         RegExp(r'(?:\s|^)@([-\w]+)$'), | ||||
|         (Match m) => insertText, | ||||
|       ); | ||||
|     } | ||||
| @@ -349,15 +349,17 @@ class _ChatMessageInputState extends State<ChatMessageInput> { | ||||
|                     final searchText = _textController.text | ||||
|                         .substring(0, _textController.selection.baseOffset); | ||||
|  | ||||
|                     final emojiMatch = | ||||
|                         RegExp(r':(?:([a-z0-9_+-]+)~)?([a-z0-9_+-]+)$') | ||||
|                     final emojiMatch = RegExp(r':(?:([-\w]+)~)?([-\w]+)$') | ||||
|                         .firstMatch(searchText); | ||||
|                     if (emojiMatch != null) { | ||||
|                       final StickerProvider stickers = Get.find(); | ||||
|                       final emoteSearch = emojiMatch[2]!; | ||||
|                       return stickers.availableStickers | ||||
|                           .where((x) => | ||||
|                               x.textWarpedPlaceholder.contains(emoteSearch)) | ||||
|                           .where( | ||||
|                             (x) => x.textWarpedPlaceholder | ||||
|                                 .toUpperCase() | ||||
|                                 .contains(emoteSearch.toUpperCase()), | ||||
|                           ) | ||||
|                           .map( | ||||
|                             (x) => ChatMessageSuggestion( | ||||
|                               type: 'emotes', | ||||
| @@ -379,8 +381,8 @@ class _ChatMessageInputState extends State<ChatMessageInput> { | ||||
|                           .toList(); | ||||
|                     } | ||||
|  | ||||
|                     final userMatch = RegExp(r'(?:\s|^)@([a-z0-9_+-]+)$') | ||||
|                         .firstMatch(searchText); | ||||
|                     final userMatch = | ||||
|                         RegExp(r'(?:\s|^)@([-\w]+)$').firstMatch(searchText); | ||||
|                     if (userMatch != null) { | ||||
|                       final userSearch = userMatch[1]!.toLowerCase(); | ||||
|                       final AuthProvider auth = Get.find(); | ||||
|   | ||||
| @@ -24,9 +24,9 @@ class MarkdownTextContent extends StatelessWidget { | ||||
|   }); | ||||
|  | ||||
|   Widget _buildContent(BuildContext context) { | ||||
|     final emojiMatch = RegExp(r':([a-z0-9_+-]+):').allMatches(content); | ||||
|     final isOnlyEmoji = | ||||
|         content.replaceAll(RegExp(r':([a-z0-9_+-]+):'), '').trim().isEmpty; | ||||
|     final emojiRegex = RegExp(r':([-\w]+):'); | ||||
|     final emojiMatch = emojiRegex.allMatches(content); | ||||
|     final isOnlyEmoji = content.replaceAll(emojiRegex, '').trim().isEmpty; | ||||
|  | ||||
|     return Markdown( | ||||
|       shrinkWrap: true, | ||||
| @@ -89,7 +89,7 @@ class MarkdownTextContent extends StatelessWidget { | ||||
|           switch (segments[0]) { | ||||
|             case 'stickers': | ||||
|               final StickerProvider sticker = Get.find(); | ||||
|               url = sticker.aliasImageMapping[segments[1]]!; | ||||
|               url = sticker.aliasImageMapping[segments[1].toUpperCase()]!; | ||||
|               if (emojiMatch.length <= 1 && isOnlyEmoji) { | ||||
|                 width = 112; | ||||
|                 height = 112; | ||||
| @@ -161,12 +161,12 @@ class _UserNameCardInlineSyntax extends InlineSyntax { | ||||
| } | ||||
|  | ||||
| class _CustomEmoteInlineSyntax extends InlineSyntax { | ||||
|   _CustomEmoteInlineSyntax() : super(r':([a-z0-9_+-]+):'); | ||||
|   _CustomEmoteInlineSyntax() : super(r':([-\w]+):'); | ||||
|  | ||||
|   @override | ||||
|   bool onMatch(markdown.InlineParser parser, Match match) { | ||||
|     final StickerProvider sticker = Get.find(); | ||||
|     final alias = match[1]!; | ||||
|     final alias = match[1]!.toUpperCase(); | ||||
|     if (sticker.aliasImageMapping[alias] == null) { | ||||
|       parser.advanceBy(1); | ||||
|       return false; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user