@cometchat/chat-uikit-react-native 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +164 -0
  4. package/src/AI/AIAssistBot/AIAssistBotExtension.tsx +22 -0
  5. package/src/AI/AIAssistBot/AIAssistBotStyle.ts +43 -0
  6. package/src/AI/AIAssistBot/AIAssistBotView.tsx +294 -0
  7. package/src/AI/AIAssistBot/configuration.ts +22 -0
  8. package/src/AI/AIAssistBot/resources/index.ts +5 -0
  9. package/src/AI/{configuration.ts → AIBaseConfiguration.ts} +3 -6
  10. package/src/AI/AIBaseStyle.ts +58 -0
  11. package/src/AI/AIConversationStarter/AIConversationStarter.ts +5 -19
  12. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +144 -130
  13. package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +11 -6
  14. package/src/AI/AIConversationStarter/configuration.ts +10 -17
  15. package/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx +175 -0
  16. package/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts +21 -0
  17. package/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx +20 -0
  18. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +190 -0
  19. package/src/AI/AIConversationSummary/configuration.ts +14 -0
  20. package/src/AI/AIConversationSummary/resources/close.png +0 -0
  21. package/src/AI/AIConversationSummary/resources/index.ts +5 -0
  22. package/src/AI/AIExtensionDataSource.ts +17 -12
  23. package/src/AI/AIOptionsStyle.ts +14 -0
  24. package/src/AI/AISmartReplies/AISmartReplies.ts +6 -15
  25. package/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx +302 -0
  26. package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +1 -1
  27. package/src/AI/AISmartReplies/configuration.ts +4 -11
  28. package/src/AI/resources/index.ts +0 -2
  29. package/src/AI/utils.ts +3 -3
  30. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +118 -5
  31. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +3 -0
  32. package/src/CometChatMessageComposer/resources/index.ts +2 -0
  33. package/src/CometChatMessageComposer/styles.ts +1 -4
  34. package/src/CometChatMessageList/CometChatMessageList.tsx +33 -24
  35. package/src/CometChatMessages/CometChatMessages.tsx +4 -13
  36. package/src/CometChatMessages/MessagesConfiguration.ts +2 -2
  37. package/src/calls/CallUtils.ts +106 -45
  38. package/src/calls/CallingDetailsUtils.tsx +133 -15
  39. package/src/calls/CallingPackage.ts +16 -2
  40. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +9 -10
  41. package/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts +116 -0
  42. package/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts +36 -0
  43. package/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx +308 -0
  44. package/src/calls/CometChatCallLogDetails/index.ts +12 -0
  45. package/src/calls/CometChatCallLogDetails/resources/CloseIcon.png +0 -0
  46. package/src/calls/{CometChatCallDetails → CometChatCallLogDetails}/style.ts +1 -0
  47. package/src/calls/{CometChatCallHistory/CallHistoryConfiguration.ts → CometChatCallLogHistory/CallLogHistoryConfiguration.ts} +15 -27
  48. package/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts +46 -0
  49. package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +337 -0
  50. package/src/calls/CometChatCallLogHistory/index.ts +12 -0
  51. package/src/calls/CometChatCallLogHistory/resources/incomingcall.png +0 -0
  52. package/src/calls/CometChatCallLogHistory/resources/incomingvideo.png +0 -0
  53. package/src/calls/CometChatCallLogHistory/resources/index.ts +29 -0
  54. package/src/calls/CometChatCallLogHistory/resources/missedcall.png +0 -0
  55. package/src/calls/CometChatCallLogHistory/resources/missedvideo.png +0 -0
  56. package/src/calls/CometChatCallLogHistory/resources/outgoingcall.png +0 -0
  57. package/src/calls/CometChatCallLogHistory/resources/outgoingvideo.png +0 -0
  58. package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/style.ts +2 -1
  59. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts +61 -0
  60. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts +59 -0
  61. package/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx +220 -0
  62. package/src/calls/CometChatCallLogParticipants/index.ts +12 -0
  63. package/src/calls/CometChatCallLogParticipants/resources/Back.png +0 -0
  64. package/src/calls/CometChatCallLogParticipants/resources/index.ts +4 -0
  65. package/src/calls/CometChatCallLogParticipants/style.ts +24 -0
  66. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts +63 -0
  67. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts +63 -0
  68. package/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx +253 -0
  69. package/src/calls/CometChatCallLogRecordings/index.ts +12 -0
  70. package/src/calls/CometChatCallLogRecordings/resources/Back.png +0 -0
  71. package/src/calls/CometChatCallLogRecordings/resources/download.png +0 -0
  72. package/src/calls/CometChatCallLogRecordings/resources/index.ts +6 -0
  73. package/src/calls/CometChatCallLogRecordings/style.ts +24 -0
  74. package/src/calls/CometChatCallLogs/CallLogsConfiguration.ts +87 -0
  75. package/src/calls/CometChatCallLogs/CallLogsStyle.ts +95 -0
  76. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +482 -0
  77. package/src/calls/CometChatCallLogs/index.ts +12 -0
  78. package/src/calls/CometChatCallLogs/resources/Back.png +0 -0
  79. package/src/calls/CometChatCallLogs/resources/Info.png +0 -0
  80. package/src/calls/CometChatCallLogs/resources/Selection.png +0 -0
  81. package/src/calls/CometChatCallLogs/resources/Spinner.png +0 -0
  82. package/src/calls/CometChatCallLogs/resources/check.png +0 -0
  83. package/src/calls/CometChatCallLogs/resources/incomingcall.png +0 -0
  84. package/src/calls/CometChatCallLogs/resources/incomingvideo.png +0 -0
  85. package/src/calls/CometChatCallLogs/resources/index.ts +25 -0
  86. package/src/calls/CometChatCallLogs/resources/missedcall.png +0 -0
  87. package/src/calls/CometChatCallLogs/resources/missedvideo.png +0 -0
  88. package/src/calls/CometChatCallLogs/resources/outgoingcall.png +0 -0
  89. package/src/calls/CometChatCallLogs/resources/outgoingvideo.png +0 -0
  90. package/src/calls/CometChatCallLogs/style.ts +24 -0
  91. package/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts +9 -0
  92. package/src/calls/{CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx → CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx} +17 -16
  93. package/src/calls/CometChatCallLogsWithDetails/index.ts +7 -0
  94. package/src/calls/index.ts +40 -1
  95. package/src/calls/resources/index.ts +3 -1
  96. package/src/calls/resources/nextarrow.png +0 -0
  97. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +3 -5
  98. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +1 -1
  99. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +5 -3
  100. package/src/extensions/ThumbnailGeneration/resources/empty.png +0 -0
  101. package/src/extensions/ThumbnailGeneration/resources/index.ts +5 -0
  102. package/src/index.ts +79 -4
  103. package/src/shared/CometChatUiKit/CometChatUIKit.ts +154 -130
  104. package/src/shared/CometChatUiKit/UIKitSettings.ts +2 -2
  105. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +1 -1
  106. package/src/shared/framework/DataSource.ts +4 -0
  107. package/src/shared/framework/DataSourceDecorator.tsx +5 -0
  108. package/src/shared/framework/MessageDataSource.tsx +4 -1
  109. package/src/shared/index.ts +4 -0
  110. package/src/shared/modals/CometChatCallLogDetailsOptions.ts +23 -0
  111. package/src/shared/modals/CometChatCallLogDetailsTemplate.ts +16 -0
  112. package/src/shared/modals/index.ts +5 -1
  113. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +19 -5
  114. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +19 -5
  115. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +21 -7
  116. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +19 -5
  117. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +19 -5
  118. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +19 -5
  119. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +19 -5
  120. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +19 -5
  121. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +19 -5
  122. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +19 -5
  123. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +19 -5
  124. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +19 -4
  125. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +19 -5
  126. package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
  127. package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +1 -1
  128. package/src/shared/views/CometChatAICard/CometChatAICard.tsx +71 -0
  129. package/src/shared/views/CometChatAICard/resources/errormessage.png +0 -0
  130. package/src/shared/views/CometChatAICard/resources/index.ts +4 -0
  131. package/src/shared/views/CometChatAICard/resources/nomessage.png +0 -0
  132. package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +4 -0
  133. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +11 -7
  134. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +56 -47
  135. package/src/shared/views/CometChatBottomSheet/style.ts +0 -2
  136. package/src/shared/views/CometChatDate/CometChatDate.tsx +7 -3
  137. package/src/shared/views/CometChatDate/DateConfiguration.ts +4 -0
  138. package/src/shared/views/CometChatDate/style.ts +1 -1
  139. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +31 -19
  140. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -2
  141. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +51 -0
  142. package/src/shared/views/CometChatPanel/PanelStyle.tsx +43 -0
  143. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  144. package/src/shared/views/CometChatPanel/resources/index.ts +5 -0
  145. package/src/AI/AIEnabler.ts +0 -115
  146. package/src/AI/AIEnablerDecorator.tsx +0 -324
  147. package/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +0 -18
  148. package/src/calls/CometChatCallDetails/CallDetailsConfiguration.ts +0 -68
  149. package/src/calls/CometChatCallDetails/CallDetailsStyle.ts +0 -52
  150. package/src/calls/CometChatCallDetails/CometChatCallDetails.tsx +0 -268
  151. package/src/calls/CometChatCallDetails/index.ts +0 -9
  152. package/src/calls/CometChatCallHistory/CallHistoryStyle.ts +0 -34
  153. package/src/calls/CometChatCallHistory/CometChatCallHistory.tsx +0 -422
  154. package/src/calls/CometChatCallHistory/index.ts +0 -9
  155. package/src/calls/CometChatCallHistory/resources/index.ts +0 -17
  156. package/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts +0 -7
  157. package/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts +0 -3
  158. package/src/calls/CometChatCallHistoryWithDetails/index.ts +0 -8
  159. /package/src/{calls/CometChatCallDetails → AI/AIAssistBot}/resources/CloseIcon.png +0 -0
  160. /package/src/{AI → CometChatMessageComposer}/resources/ai.png +0 -0
  161. /package/src/calls/{CometChatCallDetails → CometChatCallLogDetails}/resources/index.ts +0 -0
  162. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Back.png +0 -0
  163. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Call.png +0 -0
  164. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Info.png +0 -0
  165. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Selection.png +0 -0
  166. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Spineer.png +0 -0
  167. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Video.png +0 -0
  168. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/check.png +0 -0
  169. /package/src/calls/{CometChatCallHistoryWithDetails → CometChatCallLogsWithDetails}/style.ts +0 -0
@@ -49,6 +49,7 @@ import { CometChatContextType } from '../shared/base/Types';
49
49
  import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
50
50
  import { CometChatMessageComposerActionInterface } from '../shared/helper/types';
51
51
  import { CometChatMediaRecorder, MediaRecorderStyle } from '../shared/views/CometChatMediaRecorder';
52
+ import { AIOptionsStyle } from '../AI/AIOptionsStyle';
52
53
  const { FileManager } = NativeModules;
53
54
 
54
55
  const uiEventListenerShow = 'uiEvent_show_' + new Date().getTime();
@@ -175,6 +176,35 @@ const RecordAudio = (props: any) => {
175
176
  ) : null;
176
177
  }
177
178
 
179
+ const AIOptions = (props: any) => {
180
+ const {
181
+ aiStyle,
182
+ shouldShow = false,
183
+ onClose = () => { },
184
+ cometChatBottomSheetStyle = { backgroundColor: aiStyle.backgroundColor, paddingHorizontal: 0 },
185
+ sheetRef,
186
+ aiOptions,
187
+ ...otherProps
188
+ } = props;
189
+
190
+ return shouldShow ? (
191
+ <CometChatBottomSheet
192
+ ref={sheetRef}
193
+ onClose={onClose}
194
+ style={cometChatBottomSheetStyle}
195
+ >
196
+
197
+ <CometChatActionSheet
198
+ actions={aiOptions}
199
+ style={{ ...aiStyle, paddingHorizontal: 0 }}
200
+ {...otherProps}
201
+ onPress={props.onClick}
202
+ hideHeader={true}
203
+ />
204
+ </CometChatBottomSheet>
205
+ ) : null;
206
+ }
207
+
178
208
  const LiveReaction = (props: any) => {
179
209
  const { show = false, reaction } = props;
180
210
  if (show) {
@@ -464,6 +494,14 @@ export interface CometChatMessageComposerInterface {
464
494
  * @description callback(error)→ void
465
495
  */
466
496
  onError?: (error: any) => void;
497
+ /**
498
+ * AI Icon URL.
499
+ */
500
+ AIIconURL?: string;
501
+ /**
502
+ * AI Options Style.
503
+ */
504
+ aiOptionsStyle?: AIOptionsStyle;
467
505
  }
468
506
  export const CometChatMessageComposer = React.forwardRef(
469
507
  (props: CometChatMessageComposerInterface, ref) => {
@@ -505,20 +543,21 @@ export const CometChatMessageComposer = React.forwardRef(
505
543
  deleteIconUrl,
506
544
  stopIconUrl,
507
545
  submitIconUrl,
546
+ AIIconURL,
547
+ aiOptionsStyle
508
548
  } = props;
509
549
 
510
550
  const defaultAttachmentOptions =
511
551
  ChatConfigurator.dataSource.getAttachmentOptions(user, group, id);
512
552
 
513
553
  const composerIdMap = new Map().set('parentMessageId', parentMessageId);
514
- const defaultAuxiliaryButtonOptions =
554
+ const defaultAuxiliaryButtonOptions =
515
555
  ChatConfigurator.getDataSource().getAuxiliaryOptions(
516
556
  user,
517
557
  group,
518
558
  composerIdMap,
519
559
  theme
520
560
  );
521
-
522
561
 
523
562
  const loggedInUser = React.useRef<any>({});
524
563
  const chatWith = React.useRef<any>(null);
@@ -531,6 +570,9 @@ export const CometChatMessageComposer = React.forwardRef(
531
570
  const [showEmojiboard, setShowEmojiboard] = React.useState(false);
532
571
  const [showActionSheet, setShowActionSheet] = React.useState(false);
533
572
  const [showRecordAudio, setShowRecordAudio] = React.useState(false);
573
+ const [showAIOptions, setShowAIOptions] = React.useState(false);
574
+ const [AIOptionItems, setAIOptionItems] = React.useState([]);
575
+ const [rootAIOptionItems, setRootAIOptionItems] = React.useState([]);
534
576
  const [actionSheetItems, setActionSheetItems] = React.useState([]);
535
577
  const [messagePreview, setMessagePreview] = React.useState(null);
536
578
  const [CustomView, setCustomView] = React.useState(null);
@@ -540,6 +582,18 @@ export const CometChatMessageComposer = React.forwardRef(
540
582
 
541
583
  const bottomSheetRef = React.useRef<any>(null);
542
584
 
585
+ const AIStyles = new AIOptionsStyle({
586
+ //NEED TO ADD DEFAULT STYLE HERE
587
+ backgroundColor: theme.palette.getBackgroundColor(),
588
+ listItemBackground: theme.palette.getBackgroundColor(),
589
+ listItemTitleFont: theme.typography.subtitle1,
590
+ listItemTitleColor: theme.palette.getAccent(),
591
+ listItemBorderRadius: 0,
592
+ optionsSeparatorTint: theme.palette.getAccent200(),
593
+ borderRadius: 0,
594
+ ...aiOptionsStyle,
595
+ })
596
+
543
597
  let isTyping = null;
544
598
 
545
599
  /**
@@ -898,6 +952,10 @@ export const CometChatMessageComposer = React.forwardRef(
898
952
  );
899
953
  };
900
954
 
955
+ const shouldShowAIOptions = () => {
956
+ return AIOptionItems.length > 0;
957
+ }
958
+
901
959
  const AuxiliaryButtonViewElem = () => {
902
960
  if (AuxiliaryButtonView)
903
961
  return (
@@ -906,6 +964,7 @@ export const CometChatMessageComposer = React.forwardRef(
906
964
  else if (defaultAuxiliaryButtonOptions)
907
965
  return <View style={{ flexDirection: "row", alignItems: "center" }}>
908
966
  {defaultAuxiliaryButtonOptions}
967
+ {shouldShowAIOptions() && <AIOptionsButtonView />}
909
968
  {!hideVoiceRecording && <RecordAudioButtonView />}
910
969
  </View>;
911
970
 
@@ -976,6 +1035,16 @@ export const CometChatMessageComposer = React.forwardRef(
976
1035
  onClick={() => setShowRecordAudio(true)}
977
1036
  />
978
1037
  }
1038
+ const AIOptionsButtonView = () => {
1039
+ return <ImageButton
1040
+ image={AIIconURL || ICONS.AI}
1041
+ imageStyle={Style.imageStyle}
1042
+ onClick={() => {
1043
+ setShowAIOptions(true)
1044
+ setAIOptionItems(rootAIOptionItems)
1045
+ }}
1046
+ />
1047
+ }
979
1048
 
980
1049
  //fetch logged in user
981
1050
  useEffect(() => {
@@ -1059,21 +1128,55 @@ export const CometChatMessageComposer = React.forwardRef(
1059
1128
  };
1060
1129
  })
1061
1130
  );
1131
+
1132
+ const aiOptions = ChatConfigurator.dataSource.getAIOptions(user, group, theme, composerIdMap, AIStyles);
1133
+ let newAiOptions = _getAIOptions(aiOptions);
1134
+ setAIOptionItems(newAiOptions);
1135
+ setRootAIOptionItems(newAiOptions);
1062
1136
  }, [user, group, id, parentMessageId]);
1063
1137
 
1138
+ const _getAIOptions = (options) => {
1139
+ let newOptions = [...options];
1140
+ let newAiOptions = newOptions.map((item) => {
1141
+ if (typeof item.onPress === 'function')
1142
+ return {
1143
+ ...item,
1144
+ onPress: () => {
1145
+ setShowAIOptions(false)
1146
+ item.onPress(user)
1147
+ },
1148
+ };
1149
+ return {
1150
+ ...item,
1151
+ onPress: () => { },
1152
+ };
1153
+ })
1154
+ return newAiOptions;
1155
+
1156
+ }
1157
+
1064
1158
  useEffect(() => {
1065
1159
  CometChatUIEventHandler.addMessageListener(editMessageListenerID, {
1066
1160
  ccMessageEdited: (item) => previewMessage(item),
1067
1161
  });
1068
1162
  CometChatUIEventHandler.addUIListener(UiEventListenerID, {
1069
1163
  ccToggleBottomSheet: (item) => {
1164
+ if (item?.bots) {
1165
+ let newAiOptions = _getAIOptions(item.bots)
1166
+ setAIOptionItems(newAiOptions);
1167
+ setShowAIOptions(true)
1168
+ return;
1169
+ } else if (item?.botView) {
1170
+ setCustomView(() => item.child);
1171
+ return;
1172
+ }
1070
1173
  setIsVisible(false);
1071
1174
  bottomSheetRef.current?.togglePanel();
1072
1175
  },
1073
- ccComposeMessage: (text)=>{
1176
+ ccComposeMessage: (text) => {
1074
1177
  setIsVisible(false);
1075
1178
  bottomSheetRef.current?.togglePanel();
1076
-
1179
+
1077
1180
  setInputMessage(text?.text)
1078
1181
 
1079
1182
  }
@@ -1129,7 +1232,9 @@ export const CometChatMessageComposer = React.forwardRef(
1129
1232
 
1130
1233
  return (
1131
1234
  <>
1235
+ {!isVisible && CustomView && <CustomView />}
1132
1236
  <Modal
1237
+ animationType="slide"
1133
1238
  visible={isVisible}
1134
1239
  onRequestClose={() => {
1135
1240
  setIsVisible(false);
@@ -1147,7 +1252,6 @@ export const CometChatMessageComposer = React.forwardRef(
1147
1252
  style={[
1148
1253
  Style.container,
1149
1254
  {
1150
- backgroundColor: theme.palette.getAccent100(),
1151
1255
  paddingTop: CustomViewHeader ? 0 : 8
1152
1256
  },
1153
1257
  messageComposerStyle,
@@ -1218,6 +1322,15 @@ export const CometChatMessageComposer = React.forwardRef(
1218
1322
  stopIconUrl={stopIconUrl}
1219
1323
  submitIconUrl={submitIconUrl}
1220
1324
  />
1325
+ <AIOptions
1326
+ sheetRef={bottomSheetRef}
1327
+ shouldShow={showAIOptions}
1328
+ onClose={() => {
1329
+ setShowAIOptions(false)
1330
+ }}
1331
+ aiOptions={AIOptionItems}
1332
+ aiStyle={AIStyles}
1333
+ />
1221
1334
  {HeaderView ? (
1222
1335
  <HeaderView />
1223
1336
  ) : (
@@ -7,6 +7,7 @@ import {
7
7
  //@ts-ignore
8
8
  import { CometChat } from '@cometchat/chat-sdk-react-native';
9
9
  import { MediaRecorderStyle } from '../shared/views/CometChatMediaRecorder';
10
+ import { AIOptionsStyle } from '../AI/AIOptionsStyle';
10
11
  export interface MessageComposerConfigurationInterface
11
12
  extends Omit<
12
13
  CometChatMessageComposerInterface,
@@ -72,6 +73,8 @@ export class MessageComposerConfiguration {
72
73
  composerId: string | number;
73
74
  }) => JSX.Element;
74
75
  text?: string;
76
+ AIIconURL?: string;
77
+ AIOptionsStyle?: AIOptionsStyle;
75
78
  constructor(props: MessageComposerConfigurationInterface) {
76
79
  if (props)
77
80
  for (const [key, value] of Object.entries(props)) {
@@ -6,6 +6,7 @@ import IMAGE from './image.png'
6
6
  import CLOSE from './close.png';
7
7
  import STICKER from "./stickers.png";
8
8
  import MICROPHONE from "./microphone.png";
9
+ import AI from './ai.png'
9
10
 
10
11
  export const ICONS ={
11
12
  HEART,
@@ -16,4 +17,5 @@ export const ICONS ={
16
17
  CLOSE,
17
18
  STICKER,
18
19
  MICROPHONE,
20
+ AI
19
21
  }
@@ -1,11 +1,8 @@
1
- import React from 'react';
2
1
  import { StyleSheet } from 'react-native';
3
2
 
4
3
  export const Style = StyleSheet.create({
5
4
  container: {
6
- borderRadius: 8,
7
- paddingTop: 8,
8
- marginTop: 10,
5
+ paddingVertical: 8,
9
6
  },
10
7
  padding: {
11
8
  paddingStart: 8,
@@ -308,16 +308,16 @@ export const CometChatMessageList = forwardRef<
308
308
  .then(msgs => {
309
309
  let reversed = msgs.reverse();
310
310
  if (messagesList.length === 0 && msgs?.length > 0) {
311
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0],user:user,group:group,theme:theme,parentMessageId:parentMessageId });
311
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0], user: user, group: group, theme: theme, parentMessageId: parentMessageId });
312
312
  if (conversationId.current == null)
313
313
  conversationId.current = reversed[0].getConversationId();
314
-
314
+
315
315
  }
316
- else if(messagesList.length === 0 && !props?.parentMessageId){
317
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0],user:user,group:group,theme:theme,parentMessageId:parentMessageId });
316
+ else if (messagesList.length === 0 && !props?.parentMessageId) {
317
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0], user: user, group: group, theme: theme, parentMessageId: parentMessageId });
318
318
 
319
319
  }
320
-
320
+
321
321
  for (let index = 0; index < reversed.length; index++) {
322
322
  const message: CometChat.BaseMessage = reversed[index];
323
323
  if (message && !disableReceipt && !message.hasOwnProperty("readAt") && loggedInUser.current.getUid() != message['sender']['uid']) {
@@ -925,6 +925,7 @@ export const CometChatMessageList = forwardRef<
925
925
  style={messageBubbleDateStyle}
926
926
  pattern={"timeFormat"}
927
927
  customDateString={datePattern && datePattern(item)}
928
+ dateAlignment="center"
928
929
  />
929
930
  }
930
931
  </View>
@@ -954,6 +955,7 @@ export const CometChatMessageList = forwardRef<
954
955
  style={messageBubbleDateStyle}
955
956
  pattern={"timeFormat"}
956
957
  customDateString={datePattern && datePattern(item)}
958
+ dateAlignment="center"
957
959
  />
958
960
  {
959
961
  !disableReceipt && isSender ?
@@ -1101,7 +1103,7 @@ export const CometChatMessageList = forwardRef<
1101
1103
  // textMessage.setMuid(`${getUnixTimestamp()}`);
1102
1104
  // textMessage['_composedAt'] = getUnixTimestamp();
1103
1105
  // textMessage.setReceiverType(receiverType);
1104
- // CometChatUIKit.sendTextMessage(textMessage, resolve, reject)
1106
+ // CometChatUIKit.sendTextMessage(textMessage).then(resolve).catch(reject)
1105
1107
  // break;
1106
1108
  // case MessageTypeConstants.image:
1107
1109
  // case MessageTypeConstants.video:
@@ -1126,7 +1128,7 @@ export const CometChatMessageList = forwardRef<
1126
1128
 
1127
1129
  // mediaMessage.setData(messageToForward.current['data']);
1128
1130
 
1129
- // CometChatUIKit.sendMediaMessage(mediaMessage, resolve, reject)
1131
+ // CometChatUIKit.sendMediaMessage(mediaMessage).then(resolve).catch(reject);
1130
1132
  // break;
1131
1133
  // default:
1132
1134
  // break;
@@ -1239,7 +1241,7 @@ export const CometChatMessageList = forwardRef<
1239
1241
 
1240
1242
  const RenderMessageItem = ({ item, index }) => {
1241
1243
  let seperatorView = null;
1242
- const previousMessageDate = messagesList[index + 1] ? new Date(getSentAtTimestamp(messagesList[index + 1])) : null;
1244
+ const previousMessageDate = messagesList[index - 1] ? new Date(getSentAtTimestamp(messagesList[index - 1])) : null;
1243
1245
  const currentMessageDate = new Date(getSentAtTimestamp(item));
1244
1246
 
1245
1247
  const currentDate = isNaN(currentMessageDate.getDate()) ? undefined : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`;
@@ -1254,6 +1256,7 @@ export const CometChatMessageList = forwardRef<
1254
1256
  pattern={"dayDateFormat"}
1255
1257
  style={_dateSeperatorStyle}
1256
1258
  customDateString={dateSeperatorPattern ? dateSeperatorPattern(item['sentAt']) : undefined}
1259
+ dateAlignment="center"
1257
1260
  />
1258
1261
  </View>
1259
1262
  )
@@ -1261,8 +1264,8 @@ export const CometChatMessageList = forwardRef<
1261
1264
  lastMessageDate.current = getSentAtTimestamp(item);
1262
1265
 
1263
1266
  return <React.Fragment key={index}>
1264
- <MessageView message={item} />
1265
1267
  {seperatorView}
1268
+ <MessageView message={item} />
1266
1269
  </React.Fragment>
1267
1270
  };
1268
1271
 
@@ -1273,20 +1276,22 @@ export const CometChatMessageList = forwardRef<
1273
1276
  const getEmptyTextView = useCallback(() => {
1274
1277
  if (EmptyStateView)
1275
1278
  return <EmptyStateView />
1276
- return undefined;
1277
- // return (
1278
- // <View style={Style.msgContainerStyle}>
1279
- // <Text
1280
- // style={[
1281
- // Style.msgTxtStyle, {
1282
- // ...(messageListStyle?.emptyStateTextFont),
1283
- // color: messageListStyle?.emptyStateTextColor
1284
- // }]}
1285
- // >
1286
- // {emptyStateText}
1287
- // </Text>
1288
- // </View >
1289
- // )
1279
+ return (
1280
+ <>
1281
+ <View style={Style.msgContainerStyle}>
1282
+ <Text
1283
+ style={[
1284
+ Style.msgTxtStyle, {
1285
+ ...(messageListStyle?.emptyStateTextFont),
1286
+ color: messageListStyle?.emptyStateTextColor
1287
+ }]}
1288
+ >
1289
+ {emptyStateText}
1290
+ </Text>
1291
+ </View >
1292
+ {CustomListHeader && <CustomListHeader />}
1293
+ </>
1294
+ )
1290
1295
  }, [])
1291
1296
 
1292
1297
  const getErrorStateView = useCallback(() => {
@@ -1353,7 +1358,10 @@ export const CometChatMessageList = forwardRef<
1353
1358
  } = _messageListStyle;
1354
1359
 
1355
1360
  return (
1356
- <View style={{ height, width, backgroundColor, borderRadius, ...border }}>
1361
+ <View style={{
1362
+ height, width, backgroundColor, borderRadius, ...border,
1363
+ paddingStart: 8, paddingEnd: 8,
1364
+ }}>
1357
1365
  {
1358
1366
  listState == "loading" && messagesList.length == 0 ?
1359
1367
  getLoadingStateView() :
@@ -1410,6 +1418,7 @@ export const CometChatMessageList = forwardRef<
1410
1418
  )}
1411
1419
  </ScrollView>
1412
1420
  </SafeAreaView>
1421
+ {CustomListHeader && <CustomListHeader />}
1413
1422
  {
1414
1423
  FooterView && <View style={[Style.stickyHeaderFooterStyle, { bottom: 0 }]}>
1415
1424
  <FooterView
@@ -74,7 +74,7 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => {
74
74
  const { theme } = useContext(CometChatContext);
75
75
 
76
76
  //calcualted styles and configurations
77
- const _messageStyles = new MessageStyle({
77
+ const _messagesStyles = new MessageStyle({
78
78
  backgroundColor: theme.palette.getBackgroundColor(),
79
79
  ...messagesStyle
80
80
  });
@@ -210,10 +210,8 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => {
210
210
  return (
211
211
  <View style={Style.appBarStyle}>
212
212
  {
213
- ChatConfigurator.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, theme)
214
- }
215
- {
216
- AuxilaryAppBarOptions && <AuxilaryAppBarOptions group={groupObject} user={userObject} />
213
+ AuxilaryAppBarOptions ? <AuxilaryAppBarOptions group={groupObject} user={userObject} />
214
+ : ChatConfigurator.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, theme)
217
215
  }
218
216
  {
219
217
  !hideDetails && (
@@ -235,17 +233,10 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => {
235
233
  width,
236
234
  border,
237
235
  borderRadius
238
- } = _messageStyles;
236
+ } = _messagesStyles;
239
237
 
240
238
  return <View style={[
241
239
  Style.container,
242
- showComponent == ComponentNames.Details ||
243
- showComponent == ComponentNames.Thread
244
- ? {}
245
- : {
246
- paddingStart: 8,
247
- paddingEnd: 8
248
- },
249
240
  { backgroundColor, height, width, ...border, borderRadius }
250
241
  ]
251
242
  }>
@@ -21,7 +21,7 @@ export interface MessagesConfigurationInterface {
21
21
  disableSoundForMessages?: boolean,
22
22
  customSoundForIncomingMessage?: string,
23
23
  customSoundForOutgoingMessage?: string,
24
- messageStyle?: MessageStyleInterface,
24
+ messagesStyle?: MessageStyleInterface,
25
25
  AuxilaryAppBarOptions?: (props:{user?: CometChat.User, group?: CometChat.Group}) => JSX.Element
26
26
  }
27
27
 
@@ -41,7 +41,7 @@ export class MessagesConfiguration implements MessagesConfigurationInterface {
41
41
  disableSoundForMessages?: boolean
42
42
  customSoundForIncomingMessage?: string
43
43
  customSoundForOutgoingMessage?: string
44
- messageStyle?: MessageStyleInterface
44
+ messagesStyle?: MessageStyleInterface
45
45
  AuxilaryAppBarOptions?: (props:{user?: CometChat.User, group?: CometChat.Group}) => JSX.Element
46
46
 
47
47
  constructor(props: MessagesConfigurationInterface) {
@@ -15,57 +15,118 @@ export class CallUtils {
15
15
  initiator: CometChat.User,
16
16
  loggedInUser: CometChat.User
17
17
  ): boolean {
18
- return initiator.getUid() == loggedInUser.getUid();
18
+ return initiator.getUid() == loggedInUser?.getUid();
19
19
  }
20
20
 
21
21
  static getCallStatus(
22
22
  message: CometChat.BaseMessage,
23
23
  loggedInUser: CometChat.User
24
24
  ): string {
25
- if (!(message instanceof CometChat.Call)) return '';
26
- let call = message as CometChat.Call;
27
- let callMessageText = '';
28
- let initiator = call.getCallInitiator();
29
- switch (call.getStatus()) {
30
- case CALL_INITIATED:
31
- if (this.isInitiator(initiator, loggedInUser)) {
32
- callMessageText = `${localize('OUTGOING_CALL')}`;
33
- } else {
34
- callMessageText = `${localize('INCOMING_CALL')}`;
35
- }
36
- break;
37
- case CALL_ONGOING:
38
- callMessageText = `${localize('CALL_ACCEPTED')}`;
39
- break;
40
- case CALL_ENDED:
41
- callMessageText = `${localize('CALL_ENDED')}`;
42
- break;
43
- case CALL_UNANSWERED:
44
- if (this.isInitiator(initiator, loggedInUser)) {
45
- callMessageText = `${localize('CALL_UNANSWERED')}`;
46
- } else {
47
- callMessageText = `${localize('CALL_MISSED')}`;
48
- }
49
- break;
50
- case CALL_CANCELLED:
51
- if (this.isInitiator(initiator, loggedInUser)) {
52
- callMessageText = `${localize('CALL_CANCELLED')}`;
53
- } else {
54
- callMessageText = `${localize('CALL_MISSED')}`;
55
- }
56
- break;
57
- case CALL_REJECTED:
58
- case CALL_BUSY:
59
- if (this.isInitiator(initiator, loggedInUser)) {
60
- callMessageText = `${localize('CALL_REJECTED')}`;
61
- } else {
62
- callMessageText = `${localize('CALL_MISSED')}`;
63
- }
64
- break;
65
- }
66
- if (callMessageText == undefined || callMessageText == "undefined")
25
+ try {
26
+ // if (!(message instanceof CometChat.Call)) return '';
27
+ let call = message as CometChat.Call;
28
+ let callMessageText = '';
29
+ let initiator = (call?.getCallInitiator && call?.getCallInitiator()) || call.getInitiator();
30
+ switch (call.getStatus()) {
31
+ case CALL_INITIATED:
32
+ if (this.isInitiator(initiator, loggedInUser)) {
33
+ callMessageText = `${localize(`OUTGOING_CALL`)}`;
34
+ } else {
35
+ callMessageText = `${localize(`INCOMING_CALL`)}`;
36
+ }
37
+ break;
38
+ case CALL_ONGOING:
39
+ callMessageText = `${localize(`ONGOING_CALL`)}`;
40
+ break;
41
+ case CALL_ENDED:
42
+ if (this.isInitiator(initiator, loggedInUser)) {
43
+ callMessageText = `${localize(`OUTGOING_CALL`)}`;
44
+ } else {
45
+ callMessageText = `${localize(`INCOMING_CALL`)}`;
46
+ }
47
+ break;
48
+ case CALL_BUSY:
49
+ case CALL_UNANSWERED:
50
+ if (this.isInitiator(initiator, loggedInUser)) {
51
+ callMessageText = `${localize('UNANSWERED_CALL')}`;
52
+ } else {
53
+ callMessageText = `${localize('MISSED_CALL')}`;
54
+ }
55
+ break;
56
+ case CALL_CANCELLED:
57
+ if (this.isInitiator(initiator, loggedInUser)) {
58
+ callMessageText = `${localize('CANCELLED_CALL')}`;
59
+ } else {
60
+ callMessageText = `${localize('MISSED_CALL')}`;
61
+ }
62
+ break;
63
+ case CALL_REJECTED:
64
+ if (this.isInitiator(initiator, loggedInUser)) {
65
+ callMessageText = `${localize('REJECTED_CALL')}`;
66
+ } else {
67
+ callMessageText = `${localize('MISSED_CALL')}`;
68
+ }
69
+ break;
70
+ }
71
+ if (callMessageText == undefined || callMessageText == "undefined")
67
72
  console.log(message, loggedInUser);
68
-
69
- return callMessageText;
73
+
74
+ return callMessageText;
75
+ } catch (e) {
76
+ console.log("__CATCH", e)
77
+ return "";
78
+ }
79
+ }
80
+
81
+ static isMissedCall(call: CometChat.Call, loggedInUser: CometChat.User) {
82
+ const callStatus: any = call.getStatus();
83
+ if (this.isInitiator(call.getInitiator(), loggedInUser)) {
84
+ return callStatus === CALL_UNANSWERED;
85
+ } else {
86
+ return [
87
+ CALL_BUSY,
88
+ CALL_UNANSWERED,
89
+ CALL_REJECTED,
90
+ CALL_CANCELLED,
91
+ ].includes(callStatus);
92
+ }
93
+ }
94
+
95
+ static convertMinutesToHoursMinutesSeconds(minutes: number): string {
96
+ const hours = Math.floor(minutes / 60);
97
+ const remainingMinutes = Math.floor(minutes % 60);
98
+ const seconds = Math.floor((minutes - Math.floor(minutes)) * 60);
99
+ let hoursString = "";
100
+ let minutesString = "";
101
+ let secondsString = "";
102
+ if (hours > 0) {
103
+ hoursString = `${hours}h`;
104
+ }
105
+ if (remainingMinutes > 0) {
106
+ minutesString = `${remainingMinutes}m`;
107
+ }
108
+ if (seconds >= 0) {
109
+ secondsString = `${seconds}s`;
110
+ }
111
+ return hoursString ? `${hoursString} ${minutesString} ${secondsString}` : minutesString ? `${minutesString} ${secondsString}` : secondsString;
112
+ }
113
+ static convertSecondsToHoursMinutesSeconds(seconds: number): string {
114
+ const hours = Math.floor(seconds / 3600);
115
+ const remainingMinutes = Math.floor((seconds % 3600) / 60);
116
+ const remainingSeconds = Math.floor((seconds % 3600) % 60);
117
+ let hoursString = "";
118
+ let minutesString = "";
119
+ let secondsString = "";
120
+ if (hours > 0) {
121
+ hoursString = `${hours}h`;
122
+ }
123
+ if (remainingMinutes > 0) {
124
+ minutesString = `${remainingMinutes}m`;
125
+ }
126
+ if (remainingSeconds >= 0) {
127
+ secondsString = `${remainingSeconds}s`;
128
+ }
129
+ return hoursString ? `${hoursString} ${minutesString} ${secondsString}` : minutesString ? `${minutesString} ${secondsString}` : secondsString;
70
130
  }
131
+
71
132
  }