@cometchat/chat-uikit-react-native 5.3.10 → 5.4.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 (138) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +52 -0
  7. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  8. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +95 -8
  9. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +237 -6
  10. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +2 -1
  11. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +85 -47
  12. package/ios/CometChatClipboardModule.m +11 -0
  13. package/ios/CometChatClipboardModule.swift +41 -0
  14. package/ios/FileManager.m +201 -39
  15. package/ios/RichTextEditorView.swift +312 -4
  16. package/ios/RichTextEditorViewManager.m +1 -0
  17. package/ios/SoundPlayer.m +18 -6
  18. package/package.json +9 -7
  19. package/react-native-cometchat-ui-kit.podspec +1 -0
  20. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +692 -107
  21. package/src/CometChatConversations/CometChatConversations.tsx +19 -6
  22. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +649 -49
  23. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +23 -4
  24. package/src/CometChatMessageList/CometChatMessageList.tsx +463 -54
  25. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +154 -0
  26. package/src/CometChatMessageList/components/MessageListItem.tsx +30 -17
  27. package/src/CometChatMessageList/style.ts +33 -5
  28. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +13 -0
  29. package/src/CometChatRichTextEditor/index.tsx +25 -0
  30. package/src/CometChatSearch/CometChatSearch.tsx +296 -154
  31. package/src/calls/CallingExtension.tsx +19 -13
  32. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +20 -1
  33. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +20 -9
  34. package/src/index.ts +39 -0
  35. package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -34
  36. package/src/shared/base/Types.ts +3 -0
  37. package/src/shared/constants/UIKitConstants.ts +15 -1
  38. package/src/shared/framework/DataSource.ts +14 -4
  39. package/src/shared/framework/DataSourceDecorator.tsx +17 -8
  40. package/src/shared/framework/MessageDataSource.tsx +307 -60
  41. package/src/shared/helper/useToast.tsx +29 -0
  42. package/src/shared/icons/components/audio-file-type.tsx +11 -22
  43. package/src/shared/icons/components/document-file-type.tsx +11 -24
  44. package/src/shared/icons/components/image-file-type.tsx +12 -21
  45. package/src/shared/icons/components/link-file-type.tsx +25 -0
  46. package/src/shared/icons/components/pdf-file-type.tsx +11 -22
  47. package/src/shared/icons/components/presentation-file-type.tsx +11 -24
  48. package/src/shared/icons/components/spreadsheet-file-type.tsx +11 -24
  49. package/src/shared/icons/components/text-file-type.tsx +11 -21
  50. package/src/shared/icons/components/unknown-file-type.tsx +21 -25
  51. package/src/shared/icons/components/video-file-type.tsx +11 -24
  52. package/src/shared/icons/components/zip-file-type.tsx +11 -24
  53. package/src/shared/icons/icon-mapping.tsx +2 -0
  54. package/src/shared/index.ts +28 -0
  55. package/src/shared/modals/AttachmentPickerConfiguration.ts +13 -0
  56. package/src/shared/modals/SelectedAttachment.ts +65 -0
  57. package/src/shared/modals/UploadState.ts +10 -0
  58. package/src/shared/modals/index.ts +4 -0
  59. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +42 -1
  60. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +42 -1
  61. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +43 -2
  62. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +43 -2
  63. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +43 -2
  64. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +43 -2
  65. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -2
  66. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -2
  67. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -2
  68. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +43 -2
  69. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +43 -2
  70. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -2
  71. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +43 -2
  72. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +43 -2
  73. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -2
  74. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -2
  75. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +43 -2
  76. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +43 -2
  77. package/src/shared/services/UploadQueueService.ts +145 -0
  78. package/src/shared/services/index.ts +2 -0
  79. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +42 -18
  80. package/src/shared/utils/MessageUtils.tsx +13 -4
  81. package/src/shared/utils/attachmentLimits.ts +156 -0
  82. package/src/shared/utils/audioPlaybackCoordinator.ts +28 -0
  83. package/src/shared/utils/batchMediaContext.tsx +30 -0
  84. package/src/shared/utils/conversationUtils.ts +26 -4
  85. package/src/shared/utils/groupAttachments.ts +93 -0
  86. package/src/shared/utils/index.ts +8 -0
  87. package/src/shared/utils/openMultiFileChooser.ts +123 -0
  88. package/src/shared/utils/partitionAttachmentsByKind.ts +44 -0
  89. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +28 -0
  90. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +16 -0
  91. package/src/shared/views/ClipboardPasteHandler/index.ts +2 -0
  92. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  93. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +32 -0
  94. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.tsx +90 -0
  95. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +276 -0
  96. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +827 -0
  97. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTray.tsx +110 -0
  98. package/src/shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe.tsx +53 -0
  99. package/src/shared/views/CometChatAttachmentPreview/index.ts +8 -0
  100. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +305 -0
  101. package/src/shared/views/CometChatAttachmentViewer/index.ts +2 -0
  102. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +71 -74
  103. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +587 -0
  104. package/src/shared/views/CometChatAudiosBubble/index.ts +2 -0
  105. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -7
  106. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +182 -0
  107. package/src/shared/views/CometChatCaptionText/index.ts +2 -0
  108. package/src/shared/views/CometChatComposerErrorBanner.tsx +83 -0
  109. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +141 -0
  110. package/src/shared/views/CometChatConversationStarter/index.ts +2 -0
  111. package/src/shared/views/CometChatConversationSummary/CometChatConversationSummary.tsx +155 -0
  112. package/src/shared/views/CometChatConversationSummary/index.ts +2 -0
  113. package/src/shared/views/CometChatFileBubble/style.ts +6 -4
  114. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +316 -0
  115. package/src/shared/views/CometChatFilesBubble/index.ts +2 -0
  116. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +323 -0
  117. package/src/shared/views/CometChatImagesBubble/index.ts +2 -0
  118. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +425 -0
  119. package/src/shared/views/CometChatMediaViewer/index.ts +2 -0
  120. package/src/shared/views/CometChatMediaViewer/mediaViewerUtils.ts +30 -0
  121. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
  122. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +1 -0
  123. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +172 -0
  124. package/src/shared/views/CometChatSmartReplies/index.ts +2 -0
  125. package/src/shared/views/CometChatVideoBubble/style.ts +3 -3
  126. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +441 -0
  127. package/src/shared/views/CometChatVideosBubble/index.ts +2 -0
  128. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +78 -0
  129. package/src/shared/views/CometChatVoiceNoteBubble/index.ts +2 -0
  130. package/src/shared/views/index.ts +37 -1
  131. package/src/theme/CometChatThemeHelper.ts +8 -0
  132. package/src/theme/default/color/dark.ts +9 -0
  133. package/src/theme/default/color/light.ts +10 -0
  134. package/src/theme/type.ts +73 -0
  135. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  136. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  137. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  138. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
@@ -0,0 +1,182 @@
1
+ import React, { useMemo } from "react";
2
+ import { Platform, StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
4
+ import { CometChatTheme } from "../../../theme/type";
5
+ import { AdditionalParams } from "../../base/Types";
6
+ import { CometChatTextBubble } from "../CometChatTextBubble";
7
+ import {
8
+ CometChatTextFormatter,
9
+ CometChatMentionsFormatter,
10
+ CometChatUrlsFormatter,
11
+ CometChatRichTextFormatter,
12
+ } from "../../formatters";
13
+ import { CommonUtils } from "../../utils/CommonUtils";
14
+ import { CometChatUIKit } from "../../CometChatUiKit";
15
+ import { MentionsTargetElement } from "../../constants/UIKitConstants";
16
+
17
+ export interface CometChatCaptionTextProps {
18
+ /** The media message the caption belongs to (drives mentions + sent/received styling). */
19
+ message: CometChat.BaseMessage;
20
+ /** The caption text to render. */
21
+ caption: string;
22
+ theme: CometChatTheme;
23
+ /** Visible text color/typography — the bubble keeps control of this. */
24
+ textStyle?: StyleProp<TextStyle>;
25
+ /** Padding around the caption — the bubble keeps control of this. */
26
+ containerStyle?: StyleProp<ViewStyle>;
27
+ additionalParams?: AdditionalParams;
28
+ }
29
+
30
+ /**
31
+ * Renders a media caption with the SAME rich-text support as the text bubble
32
+ * (bold / italic / strikethrough, ordered + bullet lists, inline code + code blocks,
33
+ * blockquotes, links, mentions). The caption is fed through the same formatter chain
34
+ * `getTextMessageBubble` builds; the host bubble keeps control of the visible color/padding
35
+ * via `textStyle` / `containerStyle`.
36
+ */
37
+ export function CometChatCaptionText({
38
+ message,
39
+ caption,
40
+ theme,
41
+ textStyle,
42
+ containerStyle,
43
+ additionalParams,
44
+ }: CometChatCaptionTextProps) {
45
+ const formatters = useMemo(
46
+ () => buildCaptionFormatters(message, theme, additionalParams),
47
+ [message, theme, additionalParams]
48
+ );
49
+ return (
50
+ <CometChatTextBubble
51
+ text={caption}
52
+ textStyle={textStyle}
53
+ textContainerStyle={containerStyle}
54
+ textFormatters={formatters}
55
+ />
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Mirrors the formatter setup in `MessageDataSource.getTextMessageBubble` so captions format
61
+ * identically to text messages. No decorator overrides `getUrlsFormatter`/`getMentionsFormatter`,
62
+ * so we construct the formatters directly here — this keeps the util free of a `ChatConfigurator`
63
+ * import, which would otherwise create a module-load cycle (bubble → this → ChatConfigurator →
64
+ * MessageDataSource → bubble).
65
+ */
66
+ export function buildCaptionFormatters(
67
+ message: CometChat.BaseMessage,
68
+ theme: CometChatTheme,
69
+ additionalParams?: AdditionalParams
70
+ ): CometChatTextFormatter[] {
71
+ const loggedInUser = CometChatUIKit.loggedInUser;
72
+ const mentionedUsers = (message as CometChat.TextMessage).getMentionedUsers?.() ?? [];
73
+ const textFormatters = [...(additionalParams?.textFormatters || [])];
74
+ const isMessageSentByLoggedInUser = message.getSender()?.getUid() === loggedInUser?.getUid();
75
+
76
+ const linksTextFormatter = new CometChatUrlsFormatter(loggedInUser ?? undefined);
77
+ const mentionsTextFormatter = new CometChatMentionsFormatter(theme, loggedInUser ?? undefined);
78
+
79
+ // Rich text formatter — parses markdown (bold/italic/lists/code/blockquotes/links).
80
+ const richTextFormatter = new CometChatRichTextFormatter(loggedInUser ?? undefined);
81
+ richTextFormatter.setMessage(message);
82
+ richTextFormatter.setId("ccDefaultRichTextFormatterId");
83
+ richTextFormatter.setStyle({
84
+ linkStyle: {
85
+ color: isMessageSentByLoggedInUser ? theme.color.sendBubbleLink : theme.color.receiveBubbleLink,
86
+ textDecorationLine: "underline",
87
+ },
88
+ inlineCodeStyle: isMessageSentByLoggedInUser
89
+ ? {
90
+ fontSize: theme.typography.body.regular.fontSize,
91
+ fontWeight: "400",
92
+ lineHeight: ((theme.typography.body.regular.fontSize as number) ?? 14) * 1.2,
93
+ color: theme.color.sendBubbleTextHighlight,
94
+ }
95
+ : {
96
+ fontSize: theme.typography.body.regular.fontSize,
97
+ fontWeight: "400",
98
+ lineHeight: ((theme.typography.body.regular.fontSize as number) ?? 14) * 1.2,
99
+ color: theme.color.receiveBubbleTextHighlight,
100
+ },
101
+ inlineCodeContainerStyle: isMessageSentByLoggedInUser
102
+ ? {
103
+ backgroundColor: `${String(theme.color.extendedPrimary50)}33`,
104
+ borderRadius: 2,
105
+ paddingHorizontal: 2,
106
+ paddingVertical: 0,
107
+ }
108
+ : {
109
+ backgroundColor: theme.color.background3,
110
+ borderRadius: 2,
111
+ paddingHorizontal: 2,
112
+ paddingVertical: 0,
113
+ },
114
+ codeBlockStyle: {
115
+ fontFamily: Platform.OS === "ios" ? "Menlo" : "monospace",
116
+ fontSize: 13,
117
+ color: isMessageSentByLoggedInUser ? theme.color.sendBubbleText : theme.color.receiveBubbleText,
118
+ },
119
+ codeBlockContainerStyle: isMessageSentByLoggedInUser
120
+ ? {
121
+ backgroundColor: "rgba(255,255,255,0.1)",
122
+ borderRadius: 4,
123
+ borderWidth: 1,
124
+ borderColor: "rgba(255,255,255,0.2)",
125
+ padding: 12,
126
+ }
127
+ : {
128
+ backgroundColor: theme.color.background2,
129
+ borderRadius: 4,
130
+ borderWidth: 1,
131
+ borderColor: theme.color.borderDefault,
132
+ padding: 12,
133
+ },
134
+ blockquoteContainerStyle: isMessageSentByLoggedInUser
135
+ ? { backgroundColor: "rgba(255,255,255,0.2)", borderRadius: theme.spacing.radius.r2 }
136
+ : { backgroundColor: theme.color.background3, borderRadius: theme.spacing.radius.r2 },
137
+ blockquoteBarStyle: isMessageSentByLoggedInUser
138
+ ? { backgroundColor: "rgba(255,255,255,0.6)" }
139
+ : { backgroundColor: theme.color.primary },
140
+ });
141
+
142
+ mentionsTextFormatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
143
+ linksTextFormatter.setMessage(message);
144
+ linksTextFormatter.setId("ccDefaultUrlsFormatterId");
145
+ linksTextFormatter.setStyle({ linkTextColor: theme.color.receiveBubbleLink });
146
+ if (isMessageSentByLoggedInUser) {
147
+ linksTextFormatter.setStyle({ linkTextColor: theme.color.sendBubbleText });
148
+ }
149
+
150
+ if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
151
+ if (loggedInUser) mentionsTextFormatter.setLoggedInUser(loggedInUser);
152
+ mentionsTextFormatter.setMessage(message);
153
+ mentionsTextFormatter.setId("ccDefaultMentionFormatterId");
154
+ }
155
+
156
+ const finalFormatters: CometChatTextFormatter[] = [];
157
+ let urlFormatterExists = false;
158
+ let mentionsFormatterExists = false;
159
+ let richTextFormatterExists = false;
160
+
161
+ for (const formatter of textFormatters) {
162
+ if (formatter instanceof CometChatUrlsFormatter) urlFormatterExists = true;
163
+ if (formatter instanceof CometChatMentionsFormatter) {
164
+ mentionsFormatterExists = true;
165
+ formatter.setMessage(message);
166
+ formatter.setTargetElement(MentionsTargetElement.textbubble);
167
+ if (loggedInUser) formatter.setLoggedInUser(loggedInUser);
168
+ formatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
169
+ }
170
+ if (formatter instanceof CometChatRichTextFormatter) richTextFormatterExists = true;
171
+ formatter.setMessage(message);
172
+ finalFormatters.push(CommonUtils.clone(formatter));
173
+ if (urlFormatterExists && mentionsFormatterExists && richTextFormatterExists) break;
174
+ }
175
+
176
+ // Rich text goes first so markdown is parsed before links/mentions run.
177
+ if (!richTextFormatterExists) finalFormatters.unshift(richTextFormatter);
178
+ if (!urlFormatterExists) finalFormatters.push(linksTextFormatter);
179
+ if (!mentionsFormatterExists) finalFormatters.push(mentionsTextFormatter);
180
+
181
+ return finalFormatters;
182
+ }
@@ -0,0 +1,2 @@
1
+ export { CometChatCaptionText, buildCaptionFormatters } from "./CometChatCaptionText";
2
+ export type { CometChatCaptionTextProps } from "./CometChatCaptionText";
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { ImageStyle, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native';
3
+ import { useTheme, useCompTheme } from '../../theme/hook';
4
+ import { CometChatTheme } from '../../theme/type';
5
+ import { deepMerge } from '../helper/helperFunctions';
6
+ import { Icon } from '../icons/Icon';
7
+
8
+ export interface CometChatComposerErrorBannerProps {
9
+ /** Message to show; `null`/empty hides the banner. */
10
+ message: string | null;
11
+ /** Called when the ✕ is tapped. */
12
+ onDismiss: () => void;
13
+ /** Per-instance style overrides (applied over the tokenized defaults) — same pattern as the
14
+ * bubbles (e.g. CometChatFilesBubble / CometChatAudiosBubble). A developer can also override
15
+ * globally via `theme.composerErrorBannerStyles` or at the component level via the theme provider. */
16
+ style?: CometChatTheme["composerErrorBannerStyles"];
17
+ }
18
+
19
+ /**
20
+ * A red error/info bar shown just ABOVE the composer's attachment tray — e.g. "File exceeds 100 MB"
21
+ * when an oversized file is rejected. Lives inside the composer (not a screen-bottom toast) so it
22
+ * reads as part of the compose surface. The composer owns the message + auto-dismiss timer; the ✕
23
+ * dismisses it immediately.
24
+ *
25
+ * Styling follows the standard component pattern: tokenized defaults are computed inline, then the
26
+ * merged overrides (theme → component theme → per-instance `style`) are layered on top.
27
+ */
28
+ export function CometChatComposerErrorBanner({ message, onDismiss, style }: CometChatComposerErrorBannerProps) {
29
+ const theme = useTheme();
30
+ const compTheme = useCompTheme();
31
+ const s = deepMerge(
32
+ theme.composerErrorBannerStyles ?? {},
33
+ compTheme.composerErrorBannerStyles ?? {},
34
+ style ?? {}
35
+ );
36
+
37
+ if (!message) return null;
38
+
39
+ const S = theme.spacing;
40
+ return (
41
+ <View
42
+ testID="composer-error-banner"
43
+ accessibilityRole="alert"
44
+ style={[
45
+ {
46
+ flexDirection: 'row',
47
+ alignItems: 'center',
48
+ gap: S.spacing.s2,
49
+ backgroundColor: theme.color.error,
50
+ borderRadius: S.radius.r2,
51
+ paddingVertical: S.padding.p3,
52
+ paddingHorizontal: S.padding.p3,
53
+ // No outer margins — the composer's floating wrapper owns the horizontal inset (to match the
54
+ // composer width) and the bottom gap (space above the composer's top edge).
55
+ },
56
+ s.containerStyle as ViewStyle,
57
+ ]}
58
+ >
59
+ <Text
60
+ numberOfLines={2}
61
+ style={[
62
+ { flex: 1, color: theme.color.staticWhite, ...theme.typography.body.regular },
63
+ s.textStyle as TextStyle,
64
+ ]}
65
+ >
66
+ {message}
67
+ </Text>
68
+ <TouchableOpacity
69
+ onPress={onDismiss}
70
+ hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
71
+ accessibilityRole="button"
72
+ accessibilityLabel="Dismiss"
73
+ >
74
+ <Icon
75
+ name="close"
76
+ size={S.spacing.s5}
77
+ color={(s.closeIconStyle?.tintColor as string) ?? theme.color.staticWhite}
78
+ imageStyle={s.closeIconStyle as ImageStyle}
79
+ />
80
+ </TouchableOpacity>
81
+ </View>
82
+ );
83
+ }
@@ -0,0 +1,141 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import {
3
+ Animated,
4
+ ScrollView,
5
+ StyleSheet,
6
+ Text,
7
+ TouchableOpacity,
8
+ View,
9
+ } from 'react-native';
10
+ import { useTheme } from '../../../theme';
11
+ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
12
+
13
+ export interface CometChatConversationStarterProps {
14
+ getConversationStarters: () => Promise<string[]>;
15
+ onSuggestionClicked?: (reply: string) => void;
16
+ }
17
+
18
+ type State = 'loading' | 'loaded' | 'empty' | 'error';
19
+
20
+ const CometChatConversationStarter: React.FC<CometChatConversationStarterProps> = ({
21
+ getConversationStarters,
22
+ onSuggestionClicked,
23
+ }) => {
24
+ const theme = useTheme();
25
+ const { t } = useCometChatTranslation();
26
+ const [state, setState] = useState<State>('loading');
27
+ const [starters, setStarters] = useState<string[]>([]);
28
+ const shimmer = useRef(new Animated.Value(0.4)).current;
29
+
30
+ useEffect(() => {
31
+ const loop = Animated.loop(
32
+ Animated.sequence([
33
+ Animated.timing(shimmer, { toValue: 1, duration: 800, useNativeDriver: true }),
34
+ Animated.timing(shimmer, { toValue: 0.4, duration: 800, useNativeDriver: true }),
35
+ ])
36
+ );
37
+ loop.start();
38
+
39
+ getConversationStarters()
40
+ .then((res) => {
41
+ if (res && res.length > 0) {
42
+ setStarters(res);
43
+ setState('loaded');
44
+ } else {
45
+ setState('empty');
46
+ }
47
+ })
48
+ .catch(() => setState('error'))
49
+ .finally(() => loop.stop());
50
+
51
+ return () => loop.stop();
52
+ }, []);
53
+
54
+ const s = styles(theme);
55
+
56
+ if (state === 'loading') {
57
+ return (
58
+ <View style={s.container}>
59
+ {[120, 90, 150].map((w, i) => (
60
+ <Animated.View key={i} style={[s.shimmerChip, { width: w, opacity: shimmer }]} />
61
+ ))}
62
+ </View>
63
+ );
64
+ }
65
+
66
+ if (state === 'error') {
67
+ return (
68
+ <View style={s.container}>
69
+ <Text style={s.stateText}>{t('ai_conversation_starter_error')}</Text>
70
+ </View>
71
+ );
72
+ }
73
+
74
+ if (state === 'empty') {
75
+ return null;
76
+ }
77
+
78
+ return (
79
+ <View style={s.container}>
80
+ <ScrollView
81
+ horizontal
82
+ showsHorizontalScrollIndicator={false}
83
+ contentContainerStyle={s.scrollContent}
84
+ >
85
+ {starters.map((starter, i) => (
86
+ <TouchableOpacity
87
+ key={i}
88
+ style={s.chip}
89
+ onPress={() => onSuggestionClicked?.(starter)}
90
+ activeOpacity={0.7}
91
+ accessibilityRole="button"
92
+ accessibilityLabel={starter}
93
+ >
94
+ <Text style={s.chipText} numberOfLines={2}>{starter}</Text>
95
+ </TouchableOpacity>
96
+ ))}
97
+ </ScrollView>
98
+ </View>
99
+ );
100
+ };
101
+
102
+ const styles = (theme: ReturnType<typeof useTheme>) =>
103
+ StyleSheet.create({
104
+ container: {
105
+ paddingHorizontal: 12,
106
+ paddingVertical: 8,
107
+ gap: 8,
108
+ },
109
+ scrollContent: {
110
+ gap: 8,
111
+ paddingRight: 8,
112
+ },
113
+ shimmerChip: {
114
+ height: 36,
115
+ borderRadius: 18,
116
+ backgroundColor: theme.color.background4,
117
+ marginRight: 8,
118
+ },
119
+ chip: {
120
+ paddingHorizontal: 16,
121
+ paddingVertical: 8,
122
+ borderRadius: 18,
123
+ borderWidth: 1,
124
+ borderColor: theme.color.primary,
125
+ backgroundColor: theme.color.background1,
126
+ maxWidth: 240,
127
+ },
128
+ chipText: {
129
+ color: theme.color.primary,
130
+ fontSize: theme.typography.body.regular.fontSize,
131
+ fontFamily: theme.typography.body.regular.fontFamily,
132
+ },
133
+ stateText: {
134
+ color: theme.color.textSecondary,
135
+ fontSize: theme.typography.caption1.regular.fontSize,
136
+ fontFamily: theme.typography.caption1.regular.fontFamily,
137
+ paddingHorizontal: 4,
138
+ },
139
+ });
140
+
141
+ export default CometChatConversationStarter;
@@ -0,0 +1,2 @@
1
+ export { default as CometChatConversationStarter } from './CometChatConversationStarter';
2
+ export type { CometChatConversationStarterProps } from './CometChatConversationStarter';
@@ -0,0 +1,155 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import {
3
+ Animated,
4
+ ScrollView,
5
+ StyleSheet,
6
+ Text,
7
+ TouchableOpacity,
8
+ View,
9
+ } from 'react-native';
10
+ import { useTheme } from '../../../theme';
11
+ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
12
+
13
+ export interface CometChatConversationSummaryProps {
14
+ getConversationSummary: () => Promise<string>;
15
+ closeCallback?: () => void;
16
+ }
17
+
18
+ type State = 'loading' | 'loaded' | 'empty' | 'error';
19
+
20
+ const CometChatConversationSummary: React.FC<CometChatConversationSummaryProps> = ({
21
+ getConversationSummary,
22
+ closeCallback,
23
+ }) => {
24
+ const theme = useTheme();
25
+ const { t } = useCometChatTranslation();
26
+ const [state, setState] = useState<State>('loading');
27
+ const [summary, setSummary] = useState('');
28
+ const shimmer = useRef(new Animated.Value(0.4)).current;
29
+
30
+ useEffect(() => {
31
+ const loop = Animated.loop(
32
+ Animated.sequence([
33
+ Animated.timing(shimmer, { toValue: 1, duration: 800, useNativeDriver: true }),
34
+ Animated.timing(shimmer, { toValue: 0.4, duration: 800, useNativeDriver: true }),
35
+ ])
36
+ );
37
+ loop.start();
38
+
39
+ getConversationSummary()
40
+ .then((res) => {
41
+ if (res) {
42
+ setSummary(res);
43
+ setState('loaded');
44
+ } else {
45
+ setState('empty');
46
+ }
47
+ })
48
+ .catch(() => setState('error'))
49
+ .finally(() => loop.stop());
50
+
51
+ return () => loop.stop();
52
+ }, []);
53
+
54
+ const s = styles(theme);
55
+
56
+ const renderBody = () => {
57
+ if (state === 'loading') {
58
+ return (
59
+ <View style={s.shimmerContainer}>
60
+ {[200, 160, 220, 140].map((w, i) => (
61
+ <Animated.View key={i} style={[s.shimmerLine, { width: w, opacity: shimmer }]} />
62
+ ))}
63
+ </View>
64
+ );
65
+ }
66
+ if (state === 'error') {
67
+ return <Text style={s.stateText}>{t('ai_conversation_summary_error')}</Text>;
68
+ }
69
+ if (state === 'empty') {
70
+ return <Text style={s.stateText}>{t('ai_conversation_summary_empty')}</Text>;
71
+ }
72
+ return (
73
+ <ScrollView showsVerticalScrollIndicator={false} style={s.summaryScroll}>
74
+ <Text style={s.summaryText}>{summary}</Text>
75
+ </ScrollView>
76
+ );
77
+ };
78
+
79
+ return (
80
+ <View style={s.wrapper}>
81
+ <View style={s.header}>
82
+ <Text style={s.title}>{t('ai_conversation_summary_title')}</Text>
83
+ <TouchableOpacity
84
+ onPress={closeCallback}
85
+ hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
86
+ accessibilityRole="button"
87
+ accessibilityLabel={t('CLOSE')}
88
+ >
89
+ <Text style={s.closeIcon}>✕</Text>
90
+ </TouchableOpacity>
91
+ </View>
92
+ <View style={s.body}>{renderBody()}</View>
93
+ </View>
94
+ );
95
+ };
96
+
97
+ const styles = (theme: ReturnType<typeof useTheme>) =>
98
+ StyleSheet.create({
99
+ wrapper: {
100
+ backgroundColor: theme.color.background2,
101
+ borderRadius: 12,
102
+ marginHorizontal: 12,
103
+ marginVertical: 8,
104
+ overflow: 'hidden',
105
+ borderWidth: 1,
106
+ borderColor: theme.color.borderDefault,
107
+ },
108
+ header: {
109
+ flexDirection: 'row',
110
+ alignItems: 'center',
111
+ justifyContent: 'space-between',
112
+ paddingHorizontal: 16,
113
+ paddingTop: 12,
114
+ paddingBottom: 8,
115
+ borderBottomWidth: 1,
116
+ borderBottomColor: theme.color.borderLight,
117
+ },
118
+ title: {
119
+ color: theme.color.textPrimary,
120
+ fontSize: theme.typography.body.medium?.fontSize || theme.typography.body.regular.fontSize,
121
+ fontFamily: theme.typography.body.medium?.fontFamily || theme.typography.body.regular.fontFamily,
122
+ },
123
+ closeIcon: {
124
+ color: theme.color.textSecondary,
125
+ fontSize: 14,
126
+ },
127
+ body: {
128
+ padding: 16,
129
+ maxHeight: 200,
130
+ },
131
+ shimmerContainer: {
132
+ gap: 10,
133
+ },
134
+ shimmerLine: {
135
+ height: 12,
136
+ borderRadius: 6,
137
+ backgroundColor: theme.color.background4,
138
+ },
139
+ summaryScroll: {
140
+ flexGrow: 0,
141
+ },
142
+ summaryText: {
143
+ color: theme.color.textPrimary,
144
+ fontSize: theme.typography.body.regular.fontSize,
145
+ fontFamily: theme.typography.body.regular.fontFamily,
146
+ lineHeight: 22,
147
+ },
148
+ stateText: {
149
+ color: theme.color.textSecondary,
150
+ fontSize: theme.typography.body.regular.fontSize,
151
+ fontFamily: theme.typography.body.regular.fontFamily,
152
+ },
153
+ });
154
+
155
+ export default CometChatConversationSummary;
@@ -0,0 +1,2 @@
1
+ export { default as CometChatConversationSummary } from './CometChatConversationSummary';
2
+ export type { CometChatConversationSummaryProps } from './CometChatConversationSummary';
@@ -12,7 +12,7 @@ export const getFileBubbleStyleLight = (
12
12
  incomingFileBubbleStyle: {
13
13
  containerStyle: {
14
14
  paddingTop: spacing.padding.p3,
15
- paddingHorizontal: spacing.padding.p2,
15
+ paddingHorizontal: spacing.padding.p3,
16
16
  paddingBottom: spacing.padding.p0,
17
17
  borderRadius: spacing.radius.r3,
18
18
  alignSelf: "flex-start",
@@ -36,8 +36,9 @@ export const getFileBubbleStyleLight = (
36
36
  },
37
37
  outgoingFileBubbleStyle: {
38
38
  containerStyle: {
39
+ backgroundColor: color.primary,
39
40
  paddingTop: spacing.padding.p3,
40
- paddingHorizontal: spacing.padding.p2,
41
+ paddingHorizontal: spacing.padding.p3,
41
42
  borderRadius: spacing.radius.r3,
42
43
  width: 240,
43
44
  },
@@ -72,7 +73,7 @@ export const getFileBubbleStyleDark = (
72
73
  incomingFileBubbleStyle: {
73
74
  containerStyle: {
74
75
  paddingTop: spacing.padding.p3,
75
- paddingHorizontal: spacing.padding.p2,
76
+ paddingHorizontal: spacing.padding.p3,
76
77
  paddingBottom: spacing.padding.p0,
77
78
  borderRadius: spacing.radius.r3,
78
79
  alignSelf: "flex-start",
@@ -96,8 +97,9 @@ export const getFileBubbleStyleDark = (
96
97
  },
97
98
  outgoingFileBubbleStyle: {
98
99
  containerStyle: {
100
+ backgroundColor: color.primary,
99
101
  paddingTop: spacing.padding.p3,
100
- paddingHorizontal: spacing.padding.p2,
102
+ paddingHorizontal: spacing.padding.p3,
101
103
  borderRadius: spacing.radius.r3,
102
104
  width: 240,
103
105
  },