multi mention

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-09 18:29:03 +08:00
parent b32922af8f
commit dfb823c30c
10 changed files with 170 additions and 80 deletions

View File

@@ -240,24 +240,33 @@ abstract class CommonRichTextPubPageState<T extends CommonRichTextPubPage>
double _mentionOffset = 0;
Future<void> onMention([bool fromClick = false]) async {
controller.keepChatPanel();
await DynMentionPanel.onDynMention(
final res = await DynMentionPanel.onDynMention(
context,
offset: _mentionOffset,
callback: (offset) => _mentionOffset = offset,
).then((MentionItem? res) {
if (res != null) {
onInsertText(
'@${res.name} ',
RichTextType.at,
rawText: res.name,
id: res.uid,
fromClick: fromClick,
);
);
if (res != null) {
if (res is MentionItem) {
_onInsertUser(res, fromClick);
} else if (res is Iterable<MentionItem>) {
for (var e in res) {
_onInsertUser(e, fromClick);
}
}
});
}
controller.restoreChatPanel();
}
void _onInsertUser(MentionItem e, bool fromClick) {
onInsertText(
'@${e.name} ',
RichTextType.at,
rawText: e.name,
id: e.uid,
fromClick: fromClick,
);
}
void onInsertText(
String text,
RichTextType type, {