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