@cometchat/chat-uikit-react-native 5.2.2 → 5.2.4

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 (79) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatConversations/CometChatConversations.tsx +170 -91
  3. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +312 -116
  4. package/src/CometChatMessageComposer/styles.tsx +2 -1
  5. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +83 -17
  6. package/src/CometChatMessageList/CometChatMessageList.tsx +603 -65
  7. package/src/CometChatMessageList/style.ts +47 -2
  8. package/src/CometChatSearch/CometChatSearch.tsx +1718 -0
  9. package/src/CometChatSearch/SearchConstants.ts +46 -0
  10. package/src/CometChatSearch/Skeleton.tsx +192 -0
  11. package/src/CometChatSearch/index.ts +1 -0
  12. package/src/CometChatSearch/style.ts +414 -0
  13. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +43 -7
  14. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +45 -7
  15. package/src/extensions/Polls/Polls.tsx +36 -2
  16. package/src/extensions/Polls/PollsBubble.tsx +13 -9
  17. package/src/extensions/Polls/PollsDecorator.tsx +13 -1
  18. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +50 -11
  19. package/src/extensions/Stickers/style.ts +0 -1
  20. package/src/index.ts +5 -0
  21. package/src/shared/base/Types.ts +8 -0
  22. package/src/shared/constants/UIKitConstants.ts +2 -0
  23. package/src/shared/events/CometChatMessageEvents/index.ts +8 -7
  24. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  25. package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
  26. package/src/shared/events/ListenerInitializer.ts +3 -0
  27. package/src/shared/events/messages.ts +1 -0
  28. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +158 -27
  29. package/src/shared/framework/DataSource.ts +7 -0
  30. package/src/shared/framework/DataSourceDecorator.tsx +12 -0
  31. package/src/shared/framework/MessageDataSource.tsx +182 -1
  32. package/src/shared/helper/functions.js +0 -67
  33. package/src/shared/helper/helperFunctions.ts +73 -0
  34. package/src/shared/icons/components/documents.tsx +23 -0
  35. package/src/shared/icons/components/empty-search.tsx +52 -0
  36. package/src/shared/icons/components/message-blocked.tsx +32 -0
  37. package/src/shared/icons/components/unread.tsx +29 -0
  38. package/src/shared/icons/icon-mapping.tsx +9 -0
  39. package/src/shared/index.ts +2 -1
  40. package/src/shared/modals/CometChatMessageTemplate.ts +23 -0
  41. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +4 -4
  42. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +22 -4
  43. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -36
  44. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +65 -27
  45. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +42 -4
  46. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +66 -27
  47. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +42 -4
  48. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -4
  49. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -4
  50. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -4
  51. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +45 -7
  52. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +42 -4
  53. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -4
  54. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +42 -4
  55. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +42 -4
  56. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -5
  57. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -4
  58. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +42 -4
  59. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +45 -7
  60. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +274 -23
  61. package/src/shared/utils/MessageReceiptUtils.ts +32 -0
  62. package/src/shared/utils/MessageUtils.tsx +106 -4
  63. package/src/shared/views/CometChatAudioBubble/style.ts +0 -2
  64. package/src/shared/views/CometChatFileBubble/style.ts +0 -4
  65. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
  66. package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
  67. package/src/shared/views/CometChatList/Header.tsx +79 -49
  68. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
  69. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +390 -0
  70. package/src/shared/views/CometChatReportDialog/index.ts +3 -0
  71. package/src/shared/views/CometChatReportDialog/style.ts +164 -0
  72. package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
  73. package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
  74. package/src/shared/views/CometChatStatusIndicator/styles.ts +2 -2
  75. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +18 -2
  76. package/src/shared/views/index.ts +6 -0
  77. package/src/theme/default/default.ts +3 -0
  78. package/src/theme/provider.tsx +7 -5
  79. package/src/theme/type.ts +21 -1
@@ -126,6 +126,14 @@ interface HeaderProps {
126
126
  * If true, hides the entire header.
127
127
  */
128
128
  hideHeader?: boolean;
129
+ /**
130
+ * Custom search view component to display instead of the default search input.
131
+ */
132
+ SearchView?: () => JSX.Element;
133
+ /**
134
+ * Callback triggered when the search bar is clicked or focused.
135
+ */
136
+ onSearchBarClicked?: () => void;
129
137
  }
130
138
 
131
139
  /**
@@ -161,13 +169,16 @@ export default function Header({
161
169
  searchStyle,
162
170
  hideHeader = false,
163
171
  backButtonIconContainerStyle = { marginLeft: 10 },
172
+ SearchView,
173
+ onSearchBarClicked,
164
174
  }: HeaderProps) {
165
175
  const theme = useTheme();
166
176
  const inputRef = useRef<TextInput>(null);
167
177
  return (
168
- <View style={[styles.listBaseHeaderStyle, containerStyle]}>
178
+ <View style={[styles.listBaseHeaderStyle, { width: '100%' }]}>
179
+ {/* Header section with border */}
169
180
  {!hideHeader && (
170
- <View style={styles.upperContainer}>
181
+ <View style={[styles.upperContainer, containerStyle]}>
171
182
  <View style={{ flexDirection: "row", ...titleSeparatorStyle }}>
172
183
  {/* Render back button and title if not in selection mode */}
173
184
  {!shouldSelect && (!hideBackButton || title.length !== 0) && (
@@ -250,54 +261,73 @@ export default function Header({
250
261
  </View>
251
262
  )}
252
263
 
253
- {/* Render search box */}
264
+ {/* Render search box without border */}
254
265
  {!hideSearch && (
255
- <View
256
- style={[
257
- {
258
- backgroundColor: theme.color.background3,
259
- borderRadius: theme.spacing.radius.max,
260
- paddingHorizontal: theme.spacing.spacing.s3,
261
- marginVertical: theme.spacing.spacing.s2,
262
- gap: theme.spacing.spacing.s1,
263
- },
264
- searchStyle?.containerStyle,
265
- ]}
266
- >
267
- <Icon
268
- name='search-fill'
269
- size={searchStyle?.iconStyle?.width || 24}
270
- height={searchStyle?.iconStyle?.height || 24}
271
- width={searchStyle?.iconStyle?.width || 24}
272
- color={searchStyle?.iconStyle?.tintColor || theme.color.iconSecondary}
273
- icon={searchStyle?.icon}
274
- imageStyle={searchStyle?.iconStyle}
275
- />
276
- <TextInput
277
- ref={inputRef}
278
- placeholder={searchPlaceholderText}
279
- placeholderTextColor={
280
- searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
281
- }
282
- onChangeText={searchHandler}
283
- returnKeyType='search'
284
- value={searchInput}
285
- onSubmitEditing={() => {
286
- onSubmitEditing?.();
287
- // optional defensive focus if a re-render briefly steals focus
288
- inputRef.current?.focus();
289
- }}
290
- submitBehavior='submit'
291
- numberOfLines={1}
292
- style={[
293
- {
294
- flex: 1,
295
- color: theme.color.textPrimary,
296
- ...theme.typography.heading4.regular,
297
- },
298
- searchStyle?.textStyle,
299
- ]}
300
- />
266
+ <View style={{
267
+ alignSelf: 'stretch',
268
+ width: '100%',
269
+ paddingVertical: theme.spacing.spacing.s3
270
+ }}>
271
+ {SearchView ? (
272
+ <View >
273
+ <SearchView />
274
+ </View>
275
+ ) : (
276
+ <View
277
+ style={[
278
+ {
279
+ backgroundColor: theme.color.background3,
280
+ borderRadius: theme.spacing.radius.max,
281
+ paddingHorizontal: theme.spacing.spacing.s3,
282
+ paddingVertical: theme.spacing.spacing.s3,
283
+ marginTop: theme.spacing.spacing.s2,
284
+ flexDirection: 'row' as const,
285
+ alignItems: 'center' as const,
286
+ gap: theme.spacing.spacing.s2,
287
+ height: 48,
288
+ alignSelf: 'stretch',
289
+ },
290
+ searchStyle?.containerStyle,
291
+ ]}
292
+ >
293
+ <Icon
294
+ name='search-fill'
295
+ size={searchStyle?.iconStyle?.width || 24}
296
+ height={searchStyle?.iconStyle?.height || 24}
297
+ width={searchStyle?.iconStyle?.width || 24}
298
+ color={searchStyle?.iconStyle?.tintColor || theme.color.iconSecondary}
299
+ icon={searchStyle?.icon}
300
+ imageStyle={searchStyle?.iconStyle}
301
+ />
302
+ <TextInput
303
+ ref={inputRef}
304
+ placeholder={searchPlaceholderText}
305
+ placeholderTextColor={
306
+ searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
307
+ }
308
+ onChangeText={searchHandler}
309
+ onFocus={onSearchBarClicked}
310
+ returnKeyType='search'
311
+ value={searchInput}
312
+ onSubmitEditing={() => {
313
+ onSubmitEditing?.();
314
+ inputRef.current?.focus();
315
+ }}
316
+ submitBehavior='submit'
317
+ numberOfLines={1}
318
+ style={[
319
+ {
320
+ flex: 1,
321
+ color: theme.color.textPrimary,
322
+ fontSize: 16,
323
+ paddingVertical: 4,
324
+ ...theme.typography.heading4.regular,
325
+ },
326
+ searchStyle?.textStyle,
327
+ ]}
328
+ />
329
+ </View>
330
+ )}
301
331
  </View>
302
332
  )}
303
333
  </View>
@@ -130,11 +130,21 @@ export const CometChatMessageBubble = memo(
130
130
  {LeadingView && LeadingView}
131
131
  <View style={{ marginStart: 4, maxWidth: "80%" } as ViewProps}>
132
132
  {HeaderView && HeaderView}
133
- <View style={{ ...style?.containerStyle }} onLayout={handleLayout}>
133
+ <View style={{ ...style?.containerStyle, padding: 0, paddingHorizontal: 0, paddingVertical: 0, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }} onLayout={handleLayout}>
134
134
  {ReplyView && ReplyView}
135
- {ContentView && ContentView}
136
- {StatusInfoView && StatusInfoView}
137
- {BottomView && BottomView}
135
+ <View style={{
136
+ padding: style?.containerStyle?.padding,
137
+ paddingHorizontal: style?.containerStyle?.paddingHorizontal,
138
+ paddingVertical: style?.containerStyle?.paddingVertical,
139
+ paddingTop: style?.containerStyle?.paddingTop,
140
+ paddingBottom: style?.containerStyle?.paddingBottom,
141
+ paddingLeft: style?.containerStyle?.paddingLeft,
142
+ paddingRight: style?.containerStyle?.paddingRight
143
+ }}>
144
+ {ContentView && ContentView}
145
+ {StatusInfoView && StatusInfoView}
146
+ {BottomView && BottomView}
147
+ </View>
138
148
  </View>
139
149
  {_width && (
140
150
  <View style={{ maxWidth: _width }}>
@@ -0,0 +1,390 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import {
3
+ Modal,
4
+ View,
5
+ Text,
6
+ TouchableOpacity,
7
+ StyleSheet,
8
+ TextInput,
9
+ StyleProp,
10
+ ViewStyle,
11
+ TextStyle,
12
+ KeyboardAvoidingView,
13
+ Platform,
14
+ ScrollView,
15
+ } from "react-native";
16
+ import { useTheme } from "../../../theme";
17
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
18
+ import { Icon } from "../../icons/Icon";
19
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
20
+ import { useKeyboard } from "../../helper/useKeyboard";
21
+
22
+ export interface CometChatReportDialogInterface {
23
+ /** Controls modal visibility */
24
+ isOpen?: boolean;
25
+ /** Message object to be flagged */
26
+ message?: CometChat.BaseMessage;
27
+ /** Hide remark input field */
28
+ hideFlagRemarkField?: boolean;
29
+ /** Callback for cancel */
30
+ onCancel?: () => void;
31
+ /** Modal dismiss callback */
32
+ onDismiss?: () => void;
33
+ /** Optional custom handler after successful flag (receives SDK payload incl. original message) */
34
+ onReport?: (payload: {
35
+ message: CometChat.BaseMessage;
36
+ reason: CometChat.FlagReason;
37
+ description: string;
38
+ }) => void | Promise<void>;
39
+ /** Override reasons instead of fetching (mainly for testing) */
40
+ reasons?: CometChat.FlagReason[];
41
+ /** Text overrides / translations */
42
+ titleText?: string;
43
+ messageText?: string;
44
+ descriptionPlaceholder?: string;
45
+ cancelButtonText?: string;
46
+ reportButtonText?: string;
47
+ /** Styling overrides */
48
+ containerStyle?: StyleProp<ViewStyle>;
49
+ titleContainerStyle?: StyleProp<ViewStyle>;
50
+ titleTextStyle?: StyleProp<TextStyle>;
51
+ messageTextStyle?: StyleProp<TextStyle>;
52
+ pillsContainerStyle?: StyleProp<ViewStyle>;
53
+ pillStyle?: StyleProp<ViewStyle>;
54
+ pillTextStyle?: StyleProp<TextStyle>;
55
+ textInputContainerStyle?: StyleProp<ViewStyle>;
56
+ sectionTitle?: StyleProp<TextStyle>;
57
+ descriptionTextStyle?: StyleProp<TextStyle>;
58
+ buttonContainerStyle?: StyleProp<ViewStyle>;
59
+ cancelButtonStyle?: StyleProp<ViewStyle>;
60
+ cancelButtonTextStyle?: StyleProp<TextStyle>;
61
+ reportButtonStyle?: StyleProp<ViewStyle>;
62
+ reportButtonTextStyle?: StyleProp<TextStyle>;
63
+ /** Error callback */
64
+ onError?: (error: CometChat.CometChatException) => void;
65
+ }
66
+
67
+ export const CometChatReportDialog = (props: CometChatReportDialogInterface) => {
68
+ const { t } = useCometChatTranslation();
69
+ const keyboardHeight = useKeyboard();
70
+ const {
71
+ isOpen,
72
+ message,
73
+ hideFlagRemarkField = false,
74
+ onCancel,
75
+ onDismiss = () => null,
76
+ onReport,
77
+ reasons,
78
+ titleText = t("Flag_Message_Title"),
79
+ messageText = t("Flag_Message_Subtitle"),
80
+ descriptionPlaceholder = t("Flag_Message_Remark_Placeholder"),
81
+ cancelButtonText = t("Flag_Message_Confirm_No"),
82
+ reportButtonText = t("Flag_Message_Confirm_Yes"),
83
+ containerStyle = {},
84
+ titleContainerStyle = {},
85
+ titleTextStyle = {},
86
+ messageTextStyle = {},
87
+ pillsContainerStyle = {},
88
+ pillStyle = {},
89
+ pillTextStyle = {},
90
+ buttonContainerStyle = {},
91
+ textInputContainerStyle = {},
92
+ sectionTitle = {},
93
+ descriptionTextStyle = {},
94
+ cancelButtonStyle = {},
95
+ cancelButtonTextStyle = {},
96
+ reportButtonStyle = {},
97
+ reportButtonTextStyle = {},
98
+ onError,
99
+ } = props;
100
+
101
+ const theme = useTheme();
102
+ const [flagReasons, setFlagReasons] = useState<CometChat.FlagReason[]>(reasons || []);
103
+ const [isFetchingReasons, setIsFetchingReasons] = useState<boolean>(false);
104
+ const [selectedReason, setSelectedReason] = useState<CometChat.FlagReason | null>(null);
105
+ const [description, setDescription] = useState<string>("");
106
+ const [errorMessage, setErrorMessage] = useState<string>("");
107
+ const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
108
+ const [errorTimeoutId, setErrorTimeoutId] = useState<ReturnType<typeof setTimeout> | null>(null);
109
+ const [isTextInputFocused, setIsTextInputFocused] = useState<boolean>(false);
110
+
111
+ const resetStates = () => {
112
+ setSelectedReason(null);
113
+ setDescription("");
114
+ setErrorMessage("");
115
+ setIsSubmitting(false);
116
+ };
117
+
118
+ useEffect(() => {
119
+ if (isOpen && !reasons) {
120
+ (async () => {
121
+ try {
122
+ setIsFetchingReasons(true);
123
+ const list = await CometChat.getFlagReasons();
124
+ setFlagReasons(list);
125
+ } catch (e: any) {
126
+ onError?.(e);
127
+ showError(t("Flag_Error_Text"));
128
+ } finally {
129
+ setIsFetchingReasons(false);
130
+ }
131
+ })();
132
+ } else if (reasons) {
133
+ setFlagReasons(reasons);
134
+ }
135
+ if (!isOpen) {
136
+ resetStates();
137
+ }
138
+ }, [isOpen, reasons, onError, t]);
139
+
140
+ const handleCancel = () => {
141
+ resetStates();
142
+ onCancel?.();
143
+ };
144
+
145
+ const showError = (message: string) => {
146
+ // Clear any existing timer
147
+ if (errorTimeoutId) {
148
+ clearTimeout(errorTimeoutId);
149
+ }
150
+ setErrorMessage(message);
151
+ const id = setTimeout(() => {
152
+ setErrorMessage("");
153
+ }, 3500); // auto clear after 3.5 seconds
154
+ setErrorTimeoutId(id);
155
+ };
156
+
157
+ const handleReport = async () => {
158
+ // Validation: missing reason
159
+ if (!selectedReason) {
160
+ return;
161
+ }
162
+ if (!message) {
163
+ showError(t("Flag_Error_Text"));
164
+ return;
165
+ }
166
+ setIsSubmitting(true);
167
+ try {
168
+ // Trim remark length (max 100 similar to web)
169
+ const remark = description.trim().substring(0, 100);
170
+ const messageId = String((message as any).getId?.() ?? "");
171
+ if (!messageId) {
172
+ throw new Error("Invalid message id");
173
+ }
174
+ // SDK call
175
+ const sdkResult = await CometChat.flagMessage(messageId, {
176
+ reasonId: selectedReason.id,
177
+ remark: remark.trim().length > 0 ? remark.trim() : undefined,
178
+ });
179
+ console.log("[ReportDialog] flagMessage() success:", sdkResult);
180
+ // Fire optional external callback
181
+ const result = onReport?.({ message, reason: selectedReason, description: remark });
182
+ if (result && typeof (result as Promise<any>).then === "function") {
183
+ await (result as Promise<any>);
184
+ }
185
+ // Show success toast then auto-close after 3s
186
+ setErrorMessage("");
187
+ } catch (e: any) {
188
+ onError?.(e);
189
+ showError(t("Flag_Error_Text"));
190
+ console.log("[ReportDialog] flagMessage() error:", e);
191
+ } finally {
192
+ setIsSubmitting(false);
193
+ }
194
+ };
195
+
196
+ useEffect(() => {
197
+ return () => {
198
+ if (errorTimeoutId) clearTimeout(errorTimeoutId);
199
+ };
200
+ }, [errorTimeoutId]);
201
+
202
+ return (
203
+ <Modal
204
+ animationType='fade'
205
+ transparent
206
+ visible={isOpen}
207
+ onRequestClose={handleCancel}
208
+ onDismiss={onDismiss}
209
+ >
210
+ <KeyboardAvoidingView
211
+ style={styles.keyboardAvoidingView}
212
+ behavior={Platform.OS === "ios" ? "padding" : "height"}
213
+ >
214
+ <ScrollView
215
+ contentContainerStyle={[
216
+ styles.wrapper,
217
+ (keyboardHeight > 0 || isTextInputFocused) && styles.wrapperWithKeyboard,
218
+ ]}
219
+ keyboardShouldPersistTaps='handled'
220
+ showsVerticalScrollIndicator={false}
221
+ >
222
+ <View style={[theme.reportDialogStyles.containerStyle, containerStyle]}>
223
+ <View style={[theme.reportDialogStyles.titleContainerStyle, titleContainerStyle]}>
224
+ <View style={{ flexDirection: "row", justifyContent: "space-between" }}>
225
+ <Text style={[theme.reportDialogStyles.titleTextStyle, titleTextStyle]}>
226
+ {titleText}
227
+ </Text>
228
+ <TouchableOpacity
229
+ onPress={(e) => {
230
+ e.stopPropagation();
231
+ handleCancel();
232
+ }}
233
+ >
234
+ <Icon name='close' size={24} color={theme.color.iconPrimary} />
235
+ </TouchableOpacity>
236
+ </View>
237
+ <Text style={[theme.reportDialogStyles.messageTextStyle, messageTextStyle]}>
238
+ {messageText}
239
+ </Text>
240
+ </View>
241
+
242
+ <View style={[theme.reportDialogStyles.pillsContainerStyle, pillsContainerStyle]}>
243
+ {isFetchingReasons && (
244
+ <Text style={[theme.reportDialogStyles.messageTextStyle, { marginBottom: 8 }]}>
245
+ {"Loading..."}
246
+ </Text>
247
+ )}
248
+ {!isFetchingReasons &&
249
+ flagReasons.map((r) => {
250
+ const active = r.id === selectedReason?.id;
251
+ return (
252
+ <TouchableOpacity
253
+ key={r.id}
254
+ disabled={isSubmitting}
255
+ onPress={(e) => {
256
+ e.stopPropagation();
257
+ // Toggle selection: if already selected, deselect
258
+ setSelectedReason((prev) => (prev?.id === r.id ? null : r));
259
+ setErrorMessage("");
260
+ }}
261
+ style={[
262
+ theme.reportDialogStyles.pillsStyle,
263
+ {
264
+ backgroundColor: active
265
+ ? theme.color.extendedPrimary100
266
+ : theme.color.background1,
267
+ borderColor: active
268
+ ? theme.color.extendedPrimary200
269
+ : theme.color.borderDefault,
270
+ opacity: isSubmitting ? 0.6 : 1,
271
+ },
272
+ pillStyle,
273
+ ]}
274
+ >
275
+ <Text
276
+ numberOfLines={2}
277
+ style={[
278
+ theme.reportDialogStyles.pillsTextStyle,
279
+ pillTextStyle,
280
+ {
281
+ color: active ? theme.color.textHighlight : theme.color.textPrimary,
282
+ },
283
+ ]}
284
+ >
285
+ {r.name}
286
+ </Text>
287
+ </TouchableOpacity>
288
+ );
289
+ })}
290
+ </View>
291
+
292
+ {!hideFlagRemarkField && (
293
+ <View
294
+ style={[theme.reportDialogStyles.textInputContainerStyle, textInputContainerStyle]}
295
+ >
296
+ <Text style={[theme.reportDialogStyles.sectionTitle, sectionTitle]}>
297
+ {t("Flag_Message_Remark_Label")}{" "}
298
+ <Text style={{ color: theme.color.textTertiary }}>
299
+ ({t("Flag_Message_Remark_Optional")})
300
+ </Text>
301
+ </Text>
302
+ <View>
303
+ <TextInput
304
+ placeholder={descriptionPlaceholder}
305
+ placeholderTextColor={theme.color.textTertiary}
306
+ multiline
307
+ value={description}
308
+ onFocus={() => setIsTextInputFocused(true)}
309
+ onBlur={() => setIsTextInputFocused(false)}
310
+ onChangeText={(val) => setDescription(val.substring(0, 100))}
311
+ editable={!isSubmitting}
312
+ style={[theme.reportDialogStyles.descriptionTextStyle, descriptionTextStyle]}
313
+ />
314
+ </View>
315
+ </View>
316
+ )}
317
+
318
+ {!!errorMessage && (
319
+ <Text style={{ color: theme.color.error, marginBottom: 16 }}>{errorMessage}</Text>
320
+ )}
321
+
322
+ <View style={[theme.reportDialogStyles.buttonContainer, buttonContainerStyle]}>
323
+ <TouchableOpacity
324
+ style={[theme.reportDialogStyles.cancelButtonStyle, cancelButtonStyle]}
325
+ disabled={isSubmitting}
326
+ onPress={(e) => {
327
+ e.stopPropagation();
328
+ handleCancel();
329
+ }}
330
+ >
331
+ <Text
332
+ numberOfLines={1}
333
+ style={[theme.reportDialogStyles.cancelButtonTextStyle, cancelButtonTextStyle]}
334
+ >
335
+ {cancelButtonText}
336
+ </Text>
337
+ </TouchableOpacity>
338
+ <TouchableOpacity
339
+ style={[
340
+ theme.reportDialogStyles.confirmButtonStyle,
341
+ {
342
+ backgroundColor:
343
+ !selectedReason || isSubmitting
344
+ ? theme.color.background4
345
+ : theme.color.primary,
346
+ opacity: isSubmitting ? 0.7 : 1,
347
+ },
348
+ reportButtonStyle,
349
+ ]}
350
+ // Allow press even if no reason to surface error
351
+ disabled={!selectedReason || isSubmitting}
352
+ onPress={(e) => {
353
+ e.stopPropagation();
354
+ handleReport();
355
+ }}
356
+ >
357
+ <Text
358
+ numberOfLines={1}
359
+ style={[theme.reportDialogStyles.confirmButtonTextStyle, reportButtonTextStyle]}
360
+ >
361
+ {reportButtonText}
362
+ </Text>
363
+ </TouchableOpacity>
364
+ </View>
365
+ </View>
366
+ </ScrollView>
367
+ </KeyboardAvoidingView>
368
+ </Modal>
369
+ );
370
+ };
371
+
372
+ const styles = StyleSheet.create({
373
+ keyboardAvoidingView: {
374
+ flex: 1,
375
+ },
376
+ wrapper: {
377
+ flexGrow: 1,
378
+ justifyContent: "center",
379
+ alignItems: "center",
380
+ backgroundColor: "#141414CC",
381
+ paddingHorizontal: 20,
382
+ minHeight: "100%",
383
+ },
384
+ wrapperWithKeyboard: {
385
+ justifyContent: "flex-start",
386
+ paddingTop: Platform.OS === "ios" ? 50 : 20,
387
+ },
388
+ });
389
+
390
+ export default CometChatReportDialog;
@@ -0,0 +1,3 @@
1
+ import { CometChatReportDialog, CometChatReportDialogInterface } from "./CometChatReportDialog";
2
+ export { CometChatReportDialog };
3
+ export type { CometChatReportDialogInterface };