getAIOptions method

  1. @override
List<CometChatMessageComposerAction> getAIOptions(
  1. User? user,
  2. Group? group,
  3. CometChatTheme theme,
  4. BuildContext context,
  5. Map<String, dynamic>? id,
  6. AIOptionsStyle? aiOptionStyle,
)
override

override this to alter attachment options in CometChatMessageComposer

Implementation

@override
List<CometChatMessageComposerAction> getAIOptions(
    User? user,
    Group? group,
    CometChatTheme theme,
    BuildContext context,
    Map<String, dynamic>? id,
    AIOptionsStyle? aiOptionStyle) {
  List<CometChatMessageComposerAction> actionList =
      super.getAIOptions(user, group, theme, context, id, aiOptionStyle);

  if (!(id?.containsKey(IDMapConstants.parentMessageId) ?? false)) {
    if (aiBots.isNotEmpty) {
      receiverUser = user;
      receiverGroup = group;
      CometChatMessageComposerAction action = CometChatMessageComposerAction(
          id: getId(),
          title: aiBots.length == 1
              ? " ${Translations.of(context).ask} ${aiBots[0].name} ${Translations.of(context).bot}"
              : Translations.of(context).askBot,
          onItemClick:
              (BuildContext context, User? user, Group? group) async {
            if (aiBots.length > 1) {
              showCometChatAiOptionSheet(
                  context: context,
                  theme: theme,
                  user: user,
                  group: group,
                  actionItems: createBotActions());
            } else {
              showAssistBot(context, aiBots[0], user, group);
            }
          });

      actionList.add(action);
    }
  }
  return actionList;
}