@cometchat/chat-uikit-react-native 5.1.1 → 5.1.2

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 (37) hide show
  1. package/package.json +4 -4
  2. package/src/CometChatMessageList/CometChatMessageList.tsx +103 -45
  3. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +13 -29
  4. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +8 -5
  5. package/src/extensions/Polls/Polls.tsx +50 -22
  6. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -1
  7. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
  8. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +57 -45
  9. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +121 -74
  10. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  11. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  12. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  13. package/android/.gradle/7.4/gc.properties +0 -0
  14. package/android/.gradle/vcs-1/gc.properties +0 -0
  15. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +0 -79
  16. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.js +0 -152
  17. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.js.map +0 -1
  18. package/lib/shared/resources/CometChatLocalize/index.d.ts +0 -2
  19. package/lib/shared/resources/CometChatLocalize/index.js +0 -3
  20. package/lib/shared/resources/CometChatLocalize/index.js.map +0 -1
  21. package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -447
  22. package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +0 -447
  23. package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +0 -447
  24. package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +0 -447
  25. package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +0 -446
  26. package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +0 -447
  27. package/lib/shared/resources/CometChatLocalize/resources/hu/translation.json +0 -447
  28. package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +0 -447
  29. package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +0 -447
  30. package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +0 -447
  31. package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +0 -447
  32. package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +0 -447
  33. package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +0 -447
  34. package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +0 -446
  35. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.d.ts +0 -29
  36. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -29
  37. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -67,8 +67,7 @@
67
67
  "dependencies": {
68
68
  "@types/prop-types": "^15.7.14",
69
69
  "dayjs": "^1.11.18",
70
- "prop-types": "^15.8.1",
71
- "react-native-localize": "^3.5.2"
70
+ "prop-types": "^15.8.1"
72
71
  },
73
72
  "peerDependencies": {
74
73
  "@cometchat/chat-sdk-react-native": "*",
@@ -77,7 +76,8 @@
77
76
  "react-native": "*",
78
77
  "react-native-gesture-handler": "*",
79
78
  "react-native-svg": "*",
80
- "react-native-video": "*"
79
+ "react-native-video": "*",
80
+ "react-native-localize": "*"
81
81
  },
82
82
  "jest": {
83
83
  "preset": "react-native",
@@ -2157,8 +2157,7 @@ export const CometChatMessageList = memo(
2157
2157
 
2158
2158
  const onLongPress = useCallback(() => {
2159
2159
  if (message.getDeletedBy() != null) return;
2160
-
2161
-
2160
+
2162
2161
  if (!message.getId()) {
2163
2162
  return;
2164
2163
  }
@@ -2293,51 +2292,94 @@ export const CometChatMessageList = memo(
2293
2292
  setShowMessageOptions([]);
2294
2293
  };
2295
2294
 
2295
+ const sentAtToMs = (msg?: any): number | undefined => {
2296
+ if (!msg) return undefined;
2297
+ // try CometChat getter first
2298
+ const raw =
2299
+ typeof msg.getSentAt === "function"
2300
+ ? msg.getSentAt()
2301
+ : (msg?.sentAt ?? msg?.sent_at ?? msg?.sentOn ?? msg?.senton);
2302
+ if (raw === undefined || raw === null) return undefined;
2303
+ // if raw looks like seconds (10 digits) convert to ms
2304
+ return raw < 1e12 ? raw * 1000 : raw;
2305
+ };
2306
+
2307
+ const makeDayKey = (ms?: number | undefined) => {
2308
+ if (!ms) return null;
2309
+ const d = new Date(ms);
2310
+ // use local date parts so "Today" follows user's timezone
2311
+ return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
2312
+ };
2313
+
2314
+ const messageDayKeys = useMemo(() => {
2315
+ return messagesList.map((m) => {
2316
+ const ms = sentAtToMs(m);
2317
+ return makeDayKey(ms); // null if no timestamp
2318
+ });
2319
+ }, [messagesList]);
2320
+
2321
+ const showDateSeparatorAtIndex = useMemo(() => {
2322
+ const n = messagesList.length;
2323
+ const flags = new Array<boolean>(n).fill(false);
2324
+ // helper to find next non-null key to the right
2325
+ const nextNonNullKey = (startIdx: number) => {
2326
+ for (let j = startIdx; j < n; j++) {
2327
+ if (messageDayKeys[j] != null) return messageDayKeys[j];
2328
+ }
2329
+ return null;
2330
+ };
2331
+
2332
+ for (let i = 0; i < n; i++) {
2333
+ const currKey = messageDayKeys[i] ?? nextNonNullKey(i);
2334
+ const nextKey = i + 1 < n ? (messageDayKeys[i + 1] ?? nextNonNullKey(i + 1)) : null;
2335
+ if (currKey != null && currKey !== nextKey) {
2336
+ flags[i] = true;
2337
+ } else if (i === n - 1 && currKey != null) {
2338
+ // last message in list show header
2339
+ flags[i] = true;
2340
+ }
2341
+ }
2342
+ return flags;
2343
+ }, [messageDayKeys, messagesList.length]);
2344
+
2345
+ const isSameLocalDay = (ms?: number) => {
2346
+ if (!ms) return false;
2347
+ const a = new Date(ms);
2348
+ const b = new Date();
2349
+ return (
2350
+ a.getFullYear() === b.getFullYear() &&
2351
+ a.getMonth() === b.getMonth() &&
2352
+ a.getDate() === b.getDate()
2353
+ );
2354
+ };
2355
+
2356
+ const getDayHeaderString = (ms?: number | undefined) => {
2357
+ if (!ms) return undefined;
2358
+ if (isSameLocalDay(ms)) return t("TODAY") || "Today";
2359
+ return dateSeparatorPattern ? dateSeparatorPattern(ms) : undefined;
2360
+ };
2361
+
2296
2362
  const RenderMessageItem = useCallback(
2297
- ({ item, theme }: { item: CometChat.BaseMessage; theme: CometChatTheme }) => {
2298
- const index = useMemo(() => {
2299
- return messagesContentListRef.current.findIndex(
2300
- (msg) => msg.getId() === item.getId() || msg.getMuid() === item.getMuid()
2301
- );
2302
- }, [item]);
2303
-
2304
- const separatorView = useMemo(() => {
2305
- const previousMessageDate = messagesContentListRef.current[index + 1]
2306
- ? new Date(getSentAtTimestamp(messagesContentListRef.current[index + 1]))
2307
- : null;
2308
- const currentMessageDate = new Date(getSentAtTimestamp(item));
2309
- const currentDate = isNaN(currentMessageDate.getDate())
2310
- ? undefined
2311
- : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`;
2312
-
2313
- const previousDate = `${previousMessageDate?.getDate()}-${previousMessageDate?.getMonth()}-${previousMessageDate?.getFullYear()}`;
2314
- if (currentDate !== undefined && previousDate !== currentDate) {
2315
- return (
2316
- <View style={{ marginBottom: 10 }}>
2317
- <CometChatDateSeparator
2318
- timeStamp={getSentAtTimestamp(item)}
2319
- pattern={"dayDateFormat"}
2320
- customDateString={
2321
- dateSeparatorPattern ? dateSeparatorPattern(item.getSentAt()) : undefined
2322
- }
2323
- style={theme.messageListStyles.dateSeparatorStyle}
2324
- />
2325
- </View>
2326
- );
2327
- }
2328
- return null;
2329
- }, [item, dateSeparatorPattern, theme]);
2363
+ ({
2364
+ item,
2365
+ theme,
2366
+ idx,
2367
+ }: {
2368
+ item: CometChat.BaseMessage;
2369
+ theme: CometChatTheme;
2370
+ idx: number;
2371
+ }) => {
2372
+ const index = idx;
2330
2373
 
2331
2374
  lastMessageDate.current = getSentAtTimestamp(item);
2332
2375
 
2333
2376
  return (
2334
- <React.Fragment key={index}>
2335
- {separatorView}
2377
+ <React.Fragment key={`${item.getId()}_${item.getMuid()}`}>
2336
2378
  <MessageView message={item} currentIndex={index} />
2337
2379
  </React.Fragment>
2338
2380
  );
2339
2381
  },
2340
- [mergedTheme]
2382
+ [mergedTheme, messagesList, getSentAtTimestamp, dateSeparatorPattern]
2341
2383
  );
2342
2384
 
2343
2385
  const keyExtractor = useCallback((item: any) => `${item?.getId()}_${item.getMuid()}`, []);
@@ -2462,13 +2504,29 @@ export const CometChatMessageList = memo(
2462
2504
  // }, [messagesList]);
2463
2505
 
2464
2506
  const memoizedRenderItem = useCallback(
2465
- ({ item, index, separators }: any) => (
2466
- <View style={{ flex: 1, paddingHorizontal: 16, paddingVertical: 8 }}>
2467
- <RenderMessageItem item={item} theme={mergedTheme} />
2468
- {itemSeparator()}
2469
- </View>
2470
- ),
2471
- [mergedTheme]
2507
+ ({ item, index, separators }: any) => {
2508
+ // index here is FlatList's index in messagesList (newest-first)
2509
+ const showSeparator = showDateSeparatorAtIndex[index];
2510
+ const ms = sentAtToMs(item) ?? Date.now();
2511
+
2512
+ return (
2513
+ <View style={{ flex: 1, paddingHorizontal: 16, paddingVertical: 8 }}>
2514
+ {showSeparator && (
2515
+ <View style={{ alignItems: "center", marginBottom: 8 }}>
2516
+ <CometChatDateSeparator
2517
+ timeStamp={ms}
2518
+ pattern={"dayDateFormat"}
2519
+ customDateString={getDayHeaderString(ms)}
2520
+ style={mergedTheme.messageListStyles.dateSeparatorStyle}
2521
+ />
2522
+ </View>
2523
+ )}
2524
+ <RenderMessageItem item={item} theme={mergedTheme} idx={index} />
2525
+ {itemSeparator()}
2526
+ </View>
2527
+ );
2528
+ },
2529
+ [mergedTheme, showDateSeparatorAtIndex, dateSeparatorPattern, messageDayKeys]
2472
2530
  );
2473
2531
 
2474
2532
  return (
@@ -1,12 +1,6 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
- import {
4
- Text,
5
- TouchableOpacity,
6
- View,
7
- SafeAreaView,
8
- StyleSheet,
9
- } from "react-native";
3
+ import { Text, TouchableOpacity, View, StyleSheet } from "react-native";
10
4
  import { CometChatAvatar, CometChatSoundManager } from "../../shared";
11
5
  import {
12
6
  CallTypeConstants,
@@ -24,6 +18,7 @@ import { deepMerge } from "../../shared/helper/helperFunctions";
24
18
  import { DeepPartial } from "../../shared/helper/types";
25
19
  import { JSX } from "react";
26
20
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
21
+ import { SafeAreaView } from "react-native-safe-area-context";
27
22
 
28
23
  const listnerID = "CALL_LISTENER_" + new Date().getTime();
29
24
  const CometChatCalls = CallingPackage.CometChatCalls;
@@ -90,7 +85,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
90
85
  } = props;
91
86
 
92
87
  const theme = useTheme();
93
- const {t}= useCometChatTranslation()
88
+ const { t } = useCometChatTranslation();
94
89
  const [showCallScreen, setShowCallScreen] = useState(false);
95
90
  const acceptedCall = useRef<CometChat.Call>(undefined);
96
91
 
@@ -260,12 +255,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
260
255
  */
261
256
  return (
262
257
  <SafeAreaView style={styles.overlay}>
263
- <View
264
- style={[
265
- incomingCallStyle.containerStyle,
266
- { width: "100%" },
267
- ]}
268
- >
258
+ <View style={[incomingCallStyle.containerStyle, { width: "100%" }]}>
269
259
  {/* Top row: LeadingView, Title/Subtitle, TrailingView */}
270
260
  <View style={styles.topRow}>
271
261
  {LeadingView && LeadingView(call)}
@@ -282,7 +272,11 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
282
272
  SubtitleView(call)
283
273
  ) : (
284
274
  <View style={styles.rowInline}>
285
- <Icon name="call-fill" size={16} containerStyle={{ marginTop: 4, marginRight: 4 }} />
275
+ <Icon
276
+ name='call-fill'
277
+ size={16}
278
+ containerStyle={{ marginTop: 4, marginRight: 4 }}
279
+ />
286
280
  <Text style={incomingCallStyle.subtitleTextStyle}>
287
281
  {call?.["type"] === CallTypeConstants.audio
288
282
  ? t("INCOMING_AUDIO_CALL")
@@ -305,22 +299,12 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
305
299
 
306
300
  {/* Buttons row */}
307
301
  <View style={[styles.bottomRow, { marginTop: 16 }]}>
308
- <TouchableOpacity
309
- onPress={endCall}
310
- style={incomingCallStyle.declineCallButtonStyle}
311
- >
312
- <Text style={incomingCallStyle.declineCallTextStyle}>
313
- {t("DECLINE")}
314
- </Text>
302
+ <TouchableOpacity onPress={endCall} style={incomingCallStyle.declineCallButtonStyle}>
303
+ <Text style={incomingCallStyle.declineCallTextStyle}>{t("DECLINE")}</Text>
315
304
  </TouchableOpacity>
316
305
 
317
- <TouchableOpacity
318
- onPress={acceptCall}
319
- style={incomingCallStyle.acceptCallButtonStyle}
320
- >
321
- <Text style={incomingCallStyle.acceptCallTextStyle}>
322
- {t("ACCEPT")}
323
- </Text>
306
+ <TouchableOpacity onPress={acceptCall} style={incomingCallStyle.acceptCallButtonStyle}>
307
+ <Text style={incomingCallStyle.acceptCallTextStyle}>{t("ACCEPT")}</Text>
324
308
  </TouchableOpacity>
325
309
  </View>
326
310
  </View>
@@ -1,6 +1,6 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { JSX, useEffect, useMemo, useRef, useState } from "react";
3
- import { Modal, SafeAreaView, Text, TouchableOpacity, View } from "react-native";
3
+ import { Modal, Text, TouchableOpacity, View } from "react-native";
4
4
  import {
5
5
  MessageCategoryConstants,
6
6
  MessageTypeConstants,
@@ -17,6 +17,7 @@ import { deepMerge } from "../../shared/helper/helperFunctions";
17
17
  import { OutgoingCallStyle } from "./styles";
18
18
  import { DeepPartial } from "../../shared/helper/types";
19
19
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
20
+ import { SafeAreaView } from "react-native-safe-area-context";
20
21
 
21
22
  const listenerId = "callListener_" + new Date().getTime();
22
23
  const CometChatCalls = CallingPackage.CometChatCalls;
@@ -113,7 +114,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
113
114
  const isCallEnded = useRef<null | boolean>(undefined);
114
115
 
115
116
  const theme = useTheme();
116
- const {t}= useCometChatTranslation()
117
+ const { t } = useCometChatTranslation();
117
118
 
118
119
  // Merge default and custom styles for the outgoing call.
119
120
  const outgoingCallStyle = useMemo(() => {
@@ -154,7 +155,9 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
154
155
  ) {
155
156
  ongoingCall.current = call;
156
157
  if (call.getType() == MessageTypeConstants.meeting) {
157
- callSessionId.current = ((call as CometChat.CustomMessage).getCustomData() as any)?.sessionId;
158
+ callSessionId.current = (
159
+ (call as CometChat.CustomMessage).getCustomData() as any
160
+ )?.sessionId;
158
161
  }
159
162
  if (call.getCategory() === MessageCategoryConstants.call) {
160
163
  callSessionId.current = call["sessionId"];
@@ -273,7 +276,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
273
276
  return (
274
277
  <Modal
275
278
  transparent
276
- animationType="fade"
279
+ animationType='fade'
277
280
  visible={isModalVisible}
278
281
  onRequestClose={handleModalClose}
279
282
  >
@@ -317,7 +320,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
317
320
  onPress={handleModalClose}
318
321
  >
319
322
  <Icon
320
- name="call-end-fill"
323
+ name='call-end-fill'
321
324
  size={32}
322
325
  height={outgoingCallStyle.endCallIconStyle.height}
323
326
  width={outgoingCallStyle.endCallIconStyle.width}
@@ -7,7 +7,6 @@ import {
7
7
  KeyboardAvoidingView,
8
8
  NativeModules,
9
9
  Platform,
10
- SafeAreaView,
11
10
  Text,
12
11
  TextInput,
13
12
  TouchableOpacity,
@@ -19,6 +18,7 @@ import { commonVars } from "../../shared/base/vars";
19
18
  import { Icon } from "../../shared/icons/Icon";
20
19
  import { useTheme } from "../../theme";
21
20
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
21
+ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
22
22
 
23
23
  const { CommonUtil } = NativeModules;
24
24
 
@@ -128,11 +128,13 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
128
128
  const [loader, setLoader] = useState(false);
129
129
  const loggedInUser = useRef<CometChat.User | null>(null);
130
130
  const theme = useTheme();
131
- const {t} =useCometChatTranslation()
131
+ const { t } = useCometChatTranslation();
132
132
  const answerRefs = useRef<(TextInput | null)[]>([]);
133
133
  const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
134
134
  const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
135
135
  const flatListRef = useRef<FlatList>(null);
136
+ const insets = useSafeAreaInsets();
137
+ const LIMIT_ERROR = t("REACHED_MAX_LIMIT");
136
138
 
137
139
  /**
138
140
  * Validates the poll question and answer inputs.
@@ -204,12 +206,9 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
204
206
  paddingHorizontal: 15,
205
207
  }}
206
208
  >
207
- <Icon name="info" color={theme.color.error} size={20} />
209
+ <Icon name='info' color={theme.color.error} size={20} />
208
210
  <Text
209
- style={[
210
- theme.typography.caption1.regular,
211
- { color: theme.color.error, marginLeft: 10 },
212
- ]}
211
+ style={[theme.typography.caption1.regular, { color: theme.color.error, marginLeft: 10 }]}
213
212
  >
214
213
  {error}
215
214
  </Text>
@@ -239,7 +238,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
239
238
  let existingAnswers = [...answers];
240
239
  existingAnswers[index] = text;
241
240
  setAnswers(existingAnswers);
242
- if (error) {
241
+ if (error && error !== LIMIT_ERROR) {
243
242
  setError("");
244
243
  }
245
244
  if (index >= 2 && text.trim() === "") {
@@ -274,7 +273,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
274
273
  setAnswers(existingAnswers);
275
274
  setNewlyAddedIndex(existingAnswers.length - 1);
276
275
  } else {
277
- setError("You can only add up to 12 options.");
276
+ setError(LIMIT_ERROR);
278
277
  }
279
278
  }
280
279
 
@@ -325,7 +324,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
325
324
  */
326
325
  function AddAnswer() {
327
326
  if (answers.length >= 12) {
328
- return null;
327
+ return <View style={{ height: 10 }} />;
329
328
  }
330
329
  return (
331
330
  <TouchableOpacity
@@ -398,6 +397,20 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
398
397
  }
399
398
  }, [answers.length]);
400
399
 
400
+ useEffect(() => {
401
+ if (error === LIMIT_ERROR && answers.length < 12) {
402
+ setError("");
403
+ }
404
+ }, [answers, error]);
405
+
406
+ useEffect(() => {
407
+ const isMaxAndAllFilled = answers.length >= 12 && answers.every((a) => a.trim() !== "");
408
+ if (isMaxAndAllFilled) {
409
+ setError(LIMIT_ERROR);
410
+ }
411
+ // do nothing when condition not met — the other effect you already added clears LIMIT_ERROR when answers < 12
412
+ }, [answers]);
413
+
401
414
  useEffect(() => {
402
415
  let answerslist = new Array(defaultAnswers).fill("");
403
416
  setAnswers(answerslist);
@@ -420,7 +433,10 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
420
433
  }, []);
421
434
 
422
435
  return (
423
- <SafeAreaView style={{ flex: 1, backgroundColor: theme.color.background1 }}>
436
+ <SafeAreaView
437
+ style={{ flex: 1, backgroundColor: theme.color.background1 }}
438
+ edges={["top", "left", "right"]}
439
+ >
424
440
  <KeyboardAvoidingView
425
441
  style={{ flex: 1 }}
426
442
  enabled={Platform.OS === "ios"}
@@ -429,12 +445,18 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
429
445
  <TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
430
446
  <View style={{ flex: 1 }}>
431
447
  {/* Header */}
432
- <View style={{ flexDirection: "row", alignItems: "center" }}>
448
+ <View
449
+ style={{
450
+ flexDirection: "row",
451
+ alignItems: "center",
452
+ paddingTop: Platform.OS === "ios" ? insets.top : 0,
453
+ }}
454
+ >
433
455
  <TouchableOpacity
434
456
  onPress={onClose}
435
457
  style={{ flexDirection: "row", paddingVertical: 20, paddingLeft: 10 }}
436
458
  >
437
- <Icon name="arrow-back" />
459
+ <Icon name='arrow-back' />
438
460
  </TouchableOpacity>
439
461
  <Text
440
462
  style={[
@@ -490,16 +512,17 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
490
512
  data={answers}
491
513
  keyExtractor={(item, index) => index.toString()}
492
514
  renderItem={renderAnswerItem}
493
- ListFooterComponent={
494
- <View style={{ paddingBottom: 20 }}>
515
+ // render a footer only when needed, avoiding a permanently present wrapper that causes extra space
516
+ ListFooterComponent={() => (
517
+ <View style={{ paddingBottom: answers.length >= 12 ? 10 : 20 }}>
495
518
  <AddAnswer />
496
519
  </View>
497
- }
520
+ )}
498
521
  removeClippedSubviews={false}
499
- keyboardShouldPersistTaps="always"
500
- keyboardDismissMode="interactive"
522
+ keyboardShouldPersistTaps='always'
523
+ keyboardDismissMode='interactive'
501
524
  contentContainerStyle={{
502
- paddingBottom: 100,
525
+ paddingBottom: 20,
503
526
  paddingTop: 10,
504
527
  paddingHorizontal: 20,
505
528
  }}
@@ -523,15 +546,18 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
523
546
  backgroundColor: "rgba(0,0,0,0.3)",
524
547
  }}
525
548
  >
526
- <ActivityIndicator size="large" color={theme.color.primary} />
549
+ <ActivityIndicator size='large' color={theme.color.primary} />
527
550
  </View>
528
551
  )}
529
552
  {/* Fixed Create Button */}
530
553
  <View
531
554
  style={{
532
555
  paddingHorizontal: 20,
533
- paddingVertical: 10,
534
556
  backgroundColor: theme.color.background1,
557
+ paddingBottom: Platform.select({
558
+ ios: Math.max(insets.bottom, 10),
559
+ android: 10,
560
+ }),
535
561
  }}
536
562
  >
537
563
  {error && <ErrorView />}
@@ -546,7 +572,9 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
546
572
  marginBottom: Platform.select({ ios: 0, android: 10 }),
547
573
  }}
548
574
  >
549
- <Text style={[theme.typography.button.medium, { color: theme.color.primaryButtonText }]}>
575
+ <Text
576
+ style={[theme.typography.button.medium, { color: theme.color.primaryButtonText }]}
577
+ >
550
578
  {t("CREATE")}
551
579
  </Text>
552
580
  </TouchableOpacity>
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import {
3
3
  FlatList,
4
- SafeAreaView,
4
+ Platform,
5
5
  StyleProp,
6
6
  Text,
7
7
  TextStyle,
@@ -12,6 +12,7 @@ import { useTheme } from "../../../theme";
12
12
  import { Icon } from "../../icons/Icon";
13
13
  import { Emojis } from "./emojis";
14
14
  import Styles from "./style";
15
+ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
15
16
 
16
17
  /**
17
18
  * Type definitions for the emoji items and categories.
@@ -149,6 +150,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
149
150
  }) => {
150
151
  const theme = useTheme();
151
152
  const styles = Styles(theme);
153
+ const insets = useSafeAreaInsets();
152
154
 
153
155
  /**
154
156
  * ITEM_HEIGHT is assumed to be the height of one row or the uniform height per row.
@@ -284,6 +286,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
284
286
 
285
287
  return (
286
288
  <SafeAreaView
289
+ edges={["top"]}
287
290
  style={[
288
291
  styles.emojiKeyboardContainer,
289
292
  {
@@ -315,6 +318,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
315
318
  styles.categoryContainer,
316
319
  {
317
320
  backgroundColor: categoryBackground || theme.color.background1,
321
+ paddingBottom: Platform.OS === "ios" ? insets.bottom : 0,
318
322
  },
319
323
  ]}
320
324
  >
@@ -139,6 +139,7 @@ export const CometChatImageLoader = (props: CometChatImageLoaderPropType) => {
139
139
  onTouchStart={handleTouchStart}
140
140
  onTouchEnd={handleTouchEnd}
141
141
  onTouchMove={onTouchMove}
142
+ hitSlop={{top: 10, bottom: 10, left: 10, right: 10}}
142
143
  style={{
143
144
  position: "relative",
144
145
  justifyContent: "center",