@cometchat/chat-uikit-react-native 5.2.10 → 5.2.11
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.
- package/package.json +1 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +24 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +33 -5
- package/src/CometChatMessageList/components/MessageListItem.tsx +11 -8
- package/src/CometChatSearch/style.ts +3 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +1 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +1 -0
- package/src/shared/utils/MessageUtils.tsx +55 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatList/Header.tsx +57 -49
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +0 -1
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +3 -2
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +11 -5
- package/src/shared/views/CometChatReactions/style.ts +35 -8
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +46 -61
- package/src/theme/index.ts +1 -1
package/package.json
CHANGED
|
@@ -105,6 +105,7 @@ const ActionSheetBoard = (props: any) => {
|
|
|
105
105
|
ref={sheetRef}
|
|
106
106
|
onClose={onClose}
|
|
107
107
|
isOpen={shouldShow}
|
|
108
|
+
doNotOccupyEntireHeight
|
|
108
109
|
>
|
|
109
110
|
<CometChatActionSheet actions={options} style={style} />
|
|
110
111
|
</CometChatBottomSheet>
|
|
@@ -132,6 +133,7 @@ const RecordAudio = (props: any) => {
|
|
|
132
133
|
onClose={onClose}
|
|
133
134
|
style={cometChatBottomSheetStyle}
|
|
134
135
|
isOpen={shouldShow}
|
|
136
|
+
doNotOccupyEntireHeight
|
|
135
137
|
>
|
|
136
138
|
<CometChatMediaRecorder
|
|
137
139
|
onClose={onClose}
|
|
@@ -1151,6 +1153,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1151
1153
|
url: messageInput["uri"],
|
|
1152
1154
|
sender: loggedInUser.current,
|
|
1153
1155
|
attachments: [messageInput],
|
|
1156
|
+
entities: {
|
|
1157
|
+
sender: {
|
|
1158
|
+
entity: loggedInUser.current,
|
|
1159
|
+
},
|
|
1160
|
+
},
|
|
1154
1161
|
});
|
|
1155
1162
|
|
|
1156
1163
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
@@ -1172,18 +1179,34 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1172
1179
|
});
|
|
1173
1180
|
}
|
|
1174
1181
|
setReplyMessage(null);
|
|
1182
|
+
setWarningMessage("");
|
|
1175
1183
|
setShowRecordAudio(false);
|
|
1176
1184
|
})
|
|
1177
1185
|
.catch((error: any) => {
|
|
1178
1186
|
setShowRecordAudio(false);
|
|
1187
|
+
if (error?.code === "ERR_PERMISSION_DENIED") {
|
|
1188
|
+
onError && onError(error);
|
|
1189
|
+
// Set error in data.metaData where the message list receipt logic checks
|
|
1190
|
+
const currentData = localMessage.getData() || {};
|
|
1191
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1192
|
+
localMessage.setMetadata({ error: true });
|
|
1193
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1194
|
+
message: localMessage,
|
|
1195
|
+
status: messageStatus.error,
|
|
1196
|
+
});
|
|
1197
|
+
setReplyMessage(null);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1179
1200
|
onError && onError(error);
|
|
1201
|
+
// Set error in data.metaData where the message list receipt logic checks
|
|
1202
|
+
const currentData = localMessage.getData() || {};
|
|
1203
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1180
1204
|
localMessage.setMetadata({ error: true });
|
|
1181
1205
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1182
1206
|
message: localMessage,
|
|
1183
1207
|
status: messageStatus.error,
|
|
1184
1208
|
});
|
|
1185
1209
|
setReplyMessage(null);
|
|
1186
|
-
// console.log("media message sent error", error); // Removed debug log
|
|
1187
1210
|
});
|
|
1188
1211
|
};
|
|
1189
1212
|
|
|
@@ -75,9 +75,9 @@ import { CometChatAvatar } from "../shared/views/CometChatAvatar";
|
|
|
75
75
|
import { CometChatBadge } from "../shared/views/CometChatBadge";
|
|
76
76
|
import { CometChatDate } from "../shared/views/CometChatDate";
|
|
77
77
|
import { CometChatMessageBubble } from "../shared/views/CometChatMessageBubble";
|
|
78
|
-
import { getModerationStatus, ModerationBottomView } from "../shared/utils/MessageUtils";
|
|
78
|
+
import { getModerationStatus, ModerationBottomView, MimeErrorBottomView } from "../shared/utils/MessageUtils";
|
|
79
79
|
import { CometChatReactions } from "../shared/views/CometChatReactions";
|
|
80
|
-
import { useTheme } from "../theme";
|
|
80
|
+
import { useTheme, useThemeInternal } from "../theme";
|
|
81
81
|
import { MessageSkeleton } from "./Skeleton";
|
|
82
82
|
import { ErrorEmptyView } from "../shared/views/ErrorEmptyView/ErrorEmptyView";
|
|
83
83
|
import { BubbleStyles, CometChatTheme } from "../theme/type";
|
|
@@ -715,6 +715,8 @@ export const CometChatMessageList = memo(
|
|
|
715
715
|
}, [hideGroupActionMessages, isAgenticUser, parentMessageId]);
|
|
716
716
|
|
|
717
717
|
const theme = useTheme();
|
|
718
|
+
const themeInternal = useThemeInternal();
|
|
719
|
+
const themeMode = themeInternal.mode; // 'light' or 'dark' - used for FlatList extraData
|
|
718
720
|
const { t } = useCometChatTranslation();
|
|
719
721
|
|
|
720
722
|
const mergedTheme: CometChatTheme = useMemo(() => {
|
|
@@ -3043,11 +3045,17 @@ export const CometChatMessageList = memo(
|
|
|
3043
3045
|
messagesContentListRef.current[currentIndex! - 1].getDeliveredAt();
|
|
3044
3046
|
// Moderation status should override other receipt states for immediate error display
|
|
3045
3047
|
const moderationStatus = getModerationStatus(item);
|
|
3046
|
-
|
|
3048
|
+
|
|
3049
|
+
// Check error metadata FIRST before sentAt/deliveredAt/readAt
|
|
3050
|
+
const hasErrorMetadata = item?.getData?.()?.metaData?.error;
|
|
3051
|
+
const hasErrorInMetadata = item?.getMetadata?.()?.error;
|
|
3052
|
+
const hasErrorProp = (item as any)?.error;
|
|
3053
|
+
if (hasErrorMetadata || hasErrorInMetadata || hasErrorProp) {
|
|
3054
|
+
messageState = MessageReceipt.ERROR;
|
|
3055
|
+
} else if (item.getReadAt() || nextItemIsRead) messageState = MessageReceipt.READ;
|
|
3047
3056
|
else if (item.getDeliveredAt() || nextItemIsDelivered)
|
|
3048
3057
|
messageState = MessageReceipt.DELIVERED;
|
|
3049
3058
|
else if (item.getSentAt()) messageState = MessageReceipt.SENT;
|
|
3050
|
-
else if (item?.getData()?.metaData?.error) messageState = MessageReceipt.ERROR;
|
|
3051
3059
|
else if (isOutgoingMessage) messageState = MessageReceipt.WAIT;
|
|
3052
3060
|
else messageState = MessageReceipt.ERROR;
|
|
3053
3061
|
|
|
@@ -3409,6 +3417,9 @@ export const CometChatMessageList = memo(
|
|
|
3409
3417
|
if (hideFlagMessageOption) {
|
|
3410
3418
|
options = options.filter((opt: any) => opt.id !== MessageOptionConstants.reportMessage);
|
|
3411
3419
|
}
|
|
3420
|
+
if (hideMarkAsUnreadOption) {
|
|
3421
|
+
options = options.filter((opt: any) => opt.id !== MessageOptionConstants.markAsUnread);
|
|
3422
|
+
}
|
|
3412
3423
|
let optionsWithPressHandling = options.map((option) => {
|
|
3413
3424
|
if (!option.onPress)
|
|
3414
3425
|
switch (option.id) {
|
|
@@ -3562,6 +3573,20 @@ export const CometChatMessageList = memo(
|
|
|
3562
3573
|
const BottomView = useMemo(() => {
|
|
3563
3574
|
const moderationStatus = getModerationStatus(message);
|
|
3564
3575
|
const isOutgoing = message.getSender()?.getUid() === loggedInUser.current?.getUid();
|
|
3576
|
+
|
|
3577
|
+
// Check for MIME type error (ERR_PERMISSION_DENIED)
|
|
3578
|
+
const hasErrorMetadata = (message as any)?.getData?.()?.metaData?.error;
|
|
3579
|
+
const hasErrorInMetadata = (message as any)?.getMetadata?.()?.error;
|
|
3580
|
+
if (isOutgoing && (hasErrorMetadata || hasErrorInMetadata) && !isAgenticUser) {
|
|
3581
|
+
return (
|
|
3582
|
+
<MimeErrorBottomView
|
|
3583
|
+
moderationStyle={
|
|
3584
|
+
mergedTheme.messageListStyles.outgoingMessageBubbleStyles.moderationStyle
|
|
3585
|
+
}
|
|
3586
|
+
/>
|
|
3587
|
+
);
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3565
3590
|
if (effectiveHideModeration) {
|
|
3566
3591
|
return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
|
|
3567
3592
|
} else {
|
|
@@ -3847,7 +3872,7 @@ export const CometChatMessageList = memo(
|
|
|
3847
3872
|
</React.Fragment>
|
|
3848
3873
|
);
|
|
3849
3874
|
},
|
|
3850
|
-
[] //
|
|
3875
|
+
[themeMode] // Only recreate when theme mode changes - MessageView accessed via closure
|
|
3851
3876
|
);
|
|
3852
3877
|
|
|
3853
3878
|
const keyExtractor = useCallback((item: any, index: number) => {
|
|
@@ -4374,6 +4399,7 @@ export const CometChatMessageList = memo(
|
|
|
4374
4399
|
isHighlighted={isHighlighted}
|
|
4375
4400
|
highlightAnimatedValue={highlightAnimatedValue}
|
|
4376
4401
|
theme={mergedTheme}
|
|
4402
|
+
themeMode={themeMode}
|
|
4377
4403
|
timestamp={ms}
|
|
4378
4404
|
dayHeaderString={dayHeaderString}
|
|
4379
4405
|
RenderMessageItem={RenderMessageItem}
|
|
@@ -4390,6 +4416,7 @@ export const CometChatMessageList = memo(
|
|
|
4390
4416
|
},
|
|
4391
4417
|
[
|
|
4392
4418
|
mergedTheme,
|
|
4419
|
+
themeMode,
|
|
4393
4420
|
highlightedMessageId,
|
|
4394
4421
|
highlightAnimatedValue,
|
|
4395
4422
|
sentAtToMs,
|
|
@@ -4458,6 +4485,7 @@ export const CometChatMessageList = memo(
|
|
|
4458
4485
|
scrollEventThrottle={16}
|
|
4459
4486
|
keyboardShouldPersistTaps={(Platform.OS === "ios" ? "handled" : "always") as "handled" | "always"}
|
|
4460
4487
|
data={messagesList}
|
|
4488
|
+
extraData={themeMode}
|
|
4461
4489
|
keyExtractor={keyExtractor}
|
|
4462
4490
|
renderItem={memoizedRenderItem}
|
|
4463
4491
|
ListHeaderComponent={renderFooter}
|
|
@@ -14,6 +14,7 @@ interface MessageListItemProps {
|
|
|
14
14
|
isHighlighted: boolean;
|
|
15
15
|
highlightAnimatedValue: Animated.Value;
|
|
16
16
|
theme: CometChatTheme;
|
|
17
|
+
themeMode: string;
|
|
17
18
|
timestamp: number;
|
|
18
19
|
dayHeaderString: string | undefined;
|
|
19
20
|
RenderMessageItem: React.ComponentType<any>;
|
|
@@ -33,6 +34,7 @@ const MessageListItemComponent: React.FC<MessageListItemProps> = ({
|
|
|
33
34
|
isHighlighted,
|
|
34
35
|
highlightAnimatedValue,
|
|
35
36
|
theme,
|
|
37
|
+
themeMode,
|
|
36
38
|
timestamp,
|
|
37
39
|
dayHeaderString,
|
|
38
40
|
RenderMessageItem,
|
|
@@ -99,9 +101,12 @@ const MessageListItemComponent: React.FC<MessageListItemProps> = ({
|
|
|
99
101
|
export const MessageListItem = memo(MessageListItemComponent, (prevProps, nextProps) => {
|
|
100
102
|
// Return true if props are equal (skip re-render)
|
|
101
103
|
// Return false if props changed (re-render needed)
|
|
102
|
-
|
|
104
|
+
|
|
103
105
|
const itemUnchanged = prevProps.item === nextProps.item;
|
|
104
|
-
|
|
106
|
+
|
|
107
|
+
// Theme mode change should trigger re-render for theme updates
|
|
108
|
+
const themeModeUnchanged = prevProps.themeMode === nextProps.themeMode;
|
|
109
|
+
|
|
105
110
|
const visualsUnchanged =
|
|
106
111
|
prevProps.isHighlighted === nextProps.isHighlighted &&
|
|
107
112
|
prevProps.showSeparator === nextProps.showSeparator &&
|
|
@@ -109,19 +114,17 @@ export const MessageListItem = memo(MessageListItemComponent, (prevProps, nextPr
|
|
|
109
114
|
prevProps.dayHeaderString === nextProps.dayHeaderString &&
|
|
110
115
|
prevProps.showNewMessageIndicator === nextProps.showNewMessageIndicator &&
|
|
111
116
|
prevProps.newMessageIndicatorText === nextProps.newMessageIndicatorText;
|
|
112
|
-
|
|
117
|
+
|
|
113
118
|
const styleUnchanged =
|
|
114
|
-
prevProps.theme === nextProps.theme &&
|
|
115
119
|
prevProps.staticStyles === nextProps.staticStyles &&
|
|
116
120
|
prevProps.newMessageIndicatorStyle === nextProps.newMessageIndicatorStyle;
|
|
117
|
-
|
|
121
|
+
|
|
118
122
|
const functionsUnchanged =
|
|
119
|
-
prevProps.RenderMessageItem === nextProps.RenderMessageItem &&
|
|
120
123
|
prevProps.itemSeparator === nextProps.itemSeparator &&
|
|
121
124
|
prevProps.highlightAnimatedValue === nextProps.highlightAnimatedValue &&
|
|
122
125
|
prevProps.onLayout === nextProps.onLayout;
|
|
123
|
-
|
|
124
|
-
return itemUnchanged && visualsUnchanged && styleUnchanged && functionsUnchanged;
|
|
126
|
+
|
|
127
|
+
return itemUnchanged && themeModeUnchanged && visualsUnchanged && styleUnchanged && functionsUnchanged;
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
MessageListItem.displayName = 'MessageListItem';
|
|
@@ -314,9 +314,9 @@ export const getSearchStyleLight = (
|
|
|
314
314
|
maxWidth: '80%',
|
|
315
315
|
},
|
|
316
316
|
textContainerStyle: {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
flex: 1,
|
|
318
|
+
minHeight: 80,
|
|
319
|
+
maxWidth: '100%',
|
|
320
320
|
},
|
|
321
321
|
titleStyle: {
|
|
322
322
|
...typography.caption1.medium,
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Möchten Sie diese Konversation löschen? Diese Konversation wird von all Ihren Geräten gelöscht.",
|
|
27
27
|
"GROUPS": "Gruppen",
|
|
28
28
|
"WRONG_FILE_TYPE":"Sie haben einen anderen Dateityp ausgewählt. Bitte wählen Sie die entsprechende Datei aus.",
|
|
29
|
+
"FILE_TYPE_NOT_ALLOWED": "Dieser Dateityp ist nicht erlaubt.",
|
|
29
30
|
"SHARED": "Geteilt",
|
|
30
31
|
"SOUND_MANAGER": "Soundmanager",
|
|
31
32
|
"THEME": "Thema",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"CONVERSATION_LIST": "Conversation List",
|
|
31
31
|
"MESSAGES": "Messages",
|
|
32
32
|
"WRONG_FILE_TYPE": "You selected a different type of file. Please choose the appropriate file.",
|
|
33
|
+
"FILE_TYPE_NOT_ALLOWED": "This file type is not allowed.",
|
|
33
34
|
"MESSAGE_HEADER": "Message Header",
|
|
34
35
|
"MESSAGE_LIST": "Message List",
|
|
35
36
|
"MESSAGE_COMPOSER": "Message Composer",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"CHATS": "Charlas",
|
|
25
25
|
"SEARCH_EMOJI": "Buscar emojis",
|
|
26
26
|
"WRONG_FILE_TYPE": "Has seleccionado otro tipo de archivo. Seleccione el archivo adecuado.",
|
|
27
|
+
"FILE_TYPE_NOT_ALLOWED": "Este tipo de archivo no está permitido.",
|
|
27
28
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "¿Quieres eliminar esta conversación? Esta conversación se eliminará de todos tus dispositivos.",
|
|
28
29
|
"GROUPS": "Grupos",
|
|
29
30
|
"SHARED": "Compartido",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Mercredi",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Désirez-vous supprimer cette conversation ? Cette conversation sera supprimée de tous vos appareils.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Vous avez sélectionné un autre type de fichier. Choisissez le fichier approprié.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Ce type de fichier n'est pas autorisé.",
|
|
446
447
|
"WRONG_PASSWORD": "Entrez le mot de passe correct et réessayez",
|
|
447
448
|
"WRONG_TEXT": "On dirait que quelque chose a mal tourné.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Veuillez réessayer.",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "क्या आप इस वार्तालाप को मिटाना चाहेंगे? यह वार्तालाप आपके सभी डिवाइस से हटा दिया जाएगा।",
|
|
27
27
|
"GROUPS": "ग्रुप्स",
|
|
28
28
|
"WRONG_FILE_TYPE": "आपने एक अलग प्रकार की फ़ाइल चुनी है। कृपया उपयुक्त फ़ाइल चुनें।",
|
|
29
|
+
"FILE_TYPE_NOT_ALLOWED": "इस फ़ाइल प्रकार की अनुमति नहीं है।",
|
|
29
30
|
"SHARED": "शेयर्ड",
|
|
30
31
|
"SOUND_MANAGER": "साउंड मैनेजर",
|
|
31
32
|
"THEME": "थीम",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Szerda",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Szeretné törölni ezt a beszélgetést? Ez a beszélgetés törlődik az összes eszközéről.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Másik típusú fájlt választott ki. Kérjük, válassza ki a megfelelő fájlt.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Ez a fájltípus nem engedélyezett.",
|
|
446
447
|
"WRONG_PASSWORD": "Kérjük, adja meg a helyes jelszót, és próbálja újra",
|
|
447
448
|
"WRONG_TEXT": "Úgy tűnik, valami félrement.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Kérjük, próbáld meg újra.",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"CONVERSATION_LIST": "Lista conversazioni",
|
|
31
31
|
"MESSAGES": "Messaggi",
|
|
32
32
|
"WRONG_FILE_TYPE": "Hai selezionato un tipo di file diverso. Scegli il file appropriato.",
|
|
33
|
+
"FILE_TYPE_NOT_ALLOWED": "Questo tipo di file non è consentito.",
|
|
33
34
|
"MESSAGE_HEADER": "Intestazione messaggio",
|
|
34
35
|
"MESSAGE_LIST": "Lista messaggi",
|
|
35
36
|
"MESSAGE_COMPOSER": "Compositore messaggi",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"CONVERSATION_LIST": "会話リスト",
|
|
31
31
|
"MESSAGES": "メッセージ",
|
|
32
32
|
"WRONG_FILE_TYPE": "異なるタイプのファイルを選択しました。適切なファイルを選択してください。",
|
|
33
|
+
"FILE_TYPE_NOT_ALLOWED": "このファイル形式は許可されていません。",
|
|
33
34
|
"MESSAGE_HEADER": "メッセージヘッダー",
|
|
34
35
|
"MESSAGE_LIST": "メッセージリスト",
|
|
35
36
|
"MESSAGE_COMPOSER": "メッセージ作成",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Mercoledì",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Vuoi eliminare questa conversazione? Questa conversazione verrà eliminata da tutti i tuoi dispositivi.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Hai selezionato un tipo di file diverso. Scegli il file appropriato.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Šis failo tipas neleidžiamas.",
|
|
446
447
|
"WRONG_PASSWORD": "Inserisci la password corretta e riprova",
|
|
447
448
|
"WRONG_TEXT": "Atrodo, kažkas nutiko ne taip.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Prašome bandyti dar kartą.",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Rabu",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Adakah anda ingin memadamkan perbualan ini? Perbualan ini akan dipadamkan dari semua peranti anda.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Anda memilih jenis fail yang berbeza. Sila pilih fail yang sesuai.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Jenis fail ini tidak dibenarkan.",
|
|
446
447
|
"WRONG_PASSWORD": "Sila masukkan kata laluan yang betul dan cuba lagi",
|
|
447
448
|
"WRONG_TEXT": "Nampaknya ada sesuatu yang tidak kena.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Sila cuba lagi.",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"CONVERSATION_LIST": "Gesprekkenlijst",
|
|
31
31
|
"MESSAGES": "Berichten",
|
|
32
32
|
"WRONG_FILE_TYPE": "Je hebt een ander bestandstype geselecteerd. Kies het juiste bestand.",
|
|
33
|
+
"FILE_TYPE_NOT_ALLOWED": "Dit bestandstype is niet toegestaan.",
|
|
33
34
|
"MESSAGE_HEADER": "Berichtkop",
|
|
34
35
|
"MESSAGE_LIST": "Berichtenlijst",
|
|
35
36
|
"MESSAGE_COMPOSER": "Berichtschrijver",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Quarta-feira",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Você gostaria de excluir esta conversa? Essa conversa será excluída de todos os seus dispositivos.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Você selecionou um tipo diferente de arquivo. Escolha o arquivo apropriado.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Este tipo de arquivo não é permitido.",
|
|
446
447
|
"WRONG_PASSWORD": "Digite a senha correta e tente novamente",
|
|
447
448
|
"WRONG_TEXT": "Parece que algo deu errado.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Por favor, tente novamente.",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "Среда",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Хотите удалить этот разговор? Этот разговор будет удален со всех ваших устройств.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Вы выбрали другой тип файла. Выберите подходящий файл.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Этот тип файла не разрешён.",
|
|
446
447
|
"WRONG_PASSWORD": "Пожалуйста, введите правильный пароль и попробуйте снова",
|
|
447
448
|
"WRONG_TEXT": "Похоже, что что-то пошло не так.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Пожалуйста, попробуйте ещё раз.",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "onsdag",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "Vill du ta bort den här konversationen? Den här konversationen kommer att raderas från alla dina enheter.",
|
|
445
445
|
"WRONG_FILE_TYPE": "Du har valt en annan typ av fil. Välj lämplig fil.",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "Denna filtyp är inte tillåten.",
|
|
446
447
|
"WRONG_PASSWORD": "Ange rätt lösenord och försök igen",
|
|
447
448
|
"WRONG_TEXT": "Det verkar som att något gick fel.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "Vänligen försök igen.",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"CONVERSATION_LIST": "Konuşma Listesi",
|
|
31
31
|
"MESSAGES": "Mesajlar",
|
|
32
32
|
"WRONG_FILE_TYPE": "Farklı bir dosya türü seçtiniz. Lütfen uygun dosyayı seçin.",
|
|
33
|
+
"FILE_TYPE_NOT_ALLOWED": "Bu dosya türüne izin verilmiyor.",
|
|
33
34
|
"MESSAGE_HEADER": "Mesaj Başlığı",
|
|
34
35
|
"MESSAGE_LIST": "Mesaj Listesi",
|
|
35
36
|
"MESSAGE_COMPOSER": "Mesaj Oluşturucu",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "周三",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "你想删除这个对话吗?此对话将从您的所有设备中删除。",
|
|
445
445
|
"WRONG_FILE_TYPE": "您选择了其他类型的文件。请选择相应的文件。",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "不允许使用此文件类型。",
|
|
446
447
|
"WRONG_PASSWORD": "请输入正确的密码并重试",
|
|
447
448
|
"WRONG_TEXT": "看起来出了点问题.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "请再试一次.",
|
|
@@ -443,6 +443,7 @@
|
|
|
443
443
|
"WEDNESDAY": "星期三",
|
|
444
444
|
"WOULD__YOU_LIKE_TO_DELETE_THIS_CONVERSATION": "您想刪除此對話嗎?此對話將從您的所有設備中刪除。",
|
|
445
445
|
"WRONG_FILE_TYPE": "您選取了不同類型的檔案。請選擇適當的檔案。",
|
|
446
|
+
"FILE_TYPE_NOT_ALLOWED": "不允許使用此檔案類型。",
|
|
446
447
|
"WRONG_PASSWORD": "請輸入正確的密碼,然後再試一次",
|
|
447
448
|
"WRONG_TEXT": "看起來出了點問題.",
|
|
448
449
|
"WRONG_TEXT_TRY_AGAIN": "請再試一次.",
|
|
@@ -450,4 +450,59 @@ export const ModerationBottomView = ({
|
|
|
450
450
|
);
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
+
export const MimeErrorBottomView = ({
|
|
454
|
+
moderationStyle,
|
|
455
|
+
}: {
|
|
456
|
+
moderationStyle?: OutgoingBubbleStyles["moderationStyle"];
|
|
457
|
+
}) => {
|
|
458
|
+
const { t } = useCometChatTranslation();
|
|
459
|
+
const theme = useTheme();
|
|
460
|
+
|
|
461
|
+
const bubblePadH =
|
|
462
|
+
theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.paddingHorizontal ??
|
|
463
|
+
theme.spacing?.spacing?.s3 ?? 12;
|
|
464
|
+
|
|
465
|
+
const bubblePadB =
|
|
466
|
+
theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.paddingBottom ?? 0;
|
|
467
|
+
|
|
468
|
+
const bubbleRadius =
|
|
469
|
+
theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.borderRadius ?? 8;
|
|
470
|
+
|
|
471
|
+
const themeModerationStyle =
|
|
472
|
+
theme.messageListStyles.outgoingMessageBubbleStyles.moderationStyle || {};
|
|
473
|
+
|
|
474
|
+
const effective = deepMerge(themeModerationStyle, moderationStyle || {});
|
|
475
|
+
|
|
476
|
+
return (
|
|
477
|
+
<View
|
|
478
|
+
style={[
|
|
479
|
+
{
|
|
480
|
+
marginHorizontal: -bubblePadH,
|
|
481
|
+
marginBottom: -bubblePadB,
|
|
482
|
+
borderTopLeftRadius: 0,
|
|
483
|
+
borderTopRightRadius: 0,
|
|
484
|
+
borderBottomLeftRadius: bubbleRadius,
|
|
485
|
+
borderBottomRightRadius: bubbleRadius,
|
|
486
|
+
flexDirection: "row",
|
|
487
|
+
alignItems: "center",
|
|
488
|
+
},
|
|
489
|
+
effective?.containerStyle,
|
|
490
|
+
]}
|
|
491
|
+
>
|
|
492
|
+
<Icon
|
|
493
|
+
name="message-blocked"
|
|
494
|
+
color={effective?.iconTintColor}
|
|
495
|
+
containerStyle={{ paddingLeft: 12, paddingRight: 4, alignSelf: "stretch" }}
|
|
496
|
+
/>
|
|
497
|
+
<Text
|
|
498
|
+
style={[
|
|
499
|
+
effective?.textStyle,
|
|
500
|
+
]}
|
|
501
|
+
>
|
|
502
|
+
{t("FILE_TYPE_NOT_ALLOWED")}
|
|
503
|
+
</Text>
|
|
504
|
+
</View>
|
|
505
|
+
);
|
|
506
|
+
};
|
|
507
|
+
|
|
453
508
|
|
|
@@ -90,10 +90,10 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => {
|
|
|
90
90
|
<FlatList
|
|
91
91
|
key={"list"}
|
|
92
92
|
keyExtractor={(item) => item.id}
|
|
93
|
-
style={{ flex: 1 }}
|
|
94
93
|
data={actionList}
|
|
95
94
|
numColumns={1}
|
|
96
95
|
renderItem={_render}
|
|
96
|
+
contentContainerStyle={{ paddingBottom: 24 }}
|
|
97
97
|
/>
|
|
98
98
|
);
|
|
99
99
|
};
|
|
@@ -2,6 +2,7 @@ import React, { JSX, useRef } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
ImageSourcePropType,
|
|
4
4
|
ImageStyle,
|
|
5
|
+
Pressable,
|
|
5
6
|
StyleProp,
|
|
6
7
|
Text,
|
|
7
8
|
TextInput,
|
|
@@ -274,60 +275,67 @@ export default function Header({
|
|
|
274
275
|
<SearchView />
|
|
275
276
|
</View>
|
|
276
277
|
) : (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
borderRadius: theme.spacing.radius.max,
|
|
282
|
-
paddingHorizontal: theme.spacing.spacing.s3,
|
|
283
|
-
paddingVertical: theme.spacing.spacing.s3,
|
|
284
|
-
marginTop: theme.spacing.spacing.s2,
|
|
285
|
-
flexDirection: 'row' as const,
|
|
286
|
-
alignItems: 'center' as const,
|
|
287
|
-
gap: theme.spacing.spacing.s2,
|
|
288
|
-
height: 48,
|
|
289
|
-
alignSelf: 'stretch',
|
|
290
|
-
},
|
|
291
|
-
searchStyle?.containerStyle,
|
|
292
|
-
]}
|
|
278
|
+
|
|
279
|
+
<Pressable
|
|
280
|
+
onPress={onSearchBarClicked}
|
|
281
|
+
disabled={!onSearchBarClicked}
|
|
293
282
|
>
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
size={searchStyle?.iconStyle?.width || 24}
|
|
297
|
-
height={searchStyle?.iconStyle?.height || 24}
|
|
298
|
-
width={searchStyle?.iconStyle?.width || 24}
|
|
299
|
-
color={searchStyle?.iconStyle?.tintColor || theme.color.iconSecondary}
|
|
300
|
-
icon={searchStyle?.icon}
|
|
301
|
-
imageStyle={searchStyle?.iconStyle}
|
|
302
|
-
/>
|
|
303
|
-
<TextInput
|
|
304
|
-
ref={inputRef}
|
|
305
|
-
placeholder={searchPlaceholderText}
|
|
306
|
-
placeholderTextColor={
|
|
307
|
-
searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
|
|
308
|
-
}
|
|
309
|
-
onChangeText={searchHandler}
|
|
310
|
-
onFocus={onSearchBarClicked}
|
|
311
|
-
returnKeyType='search'
|
|
312
|
-
value={searchInput}
|
|
313
|
-
onSubmitEditing={() => {
|
|
314
|
-
onSubmitEditing?.();
|
|
315
|
-
inputRef.current?.focus();
|
|
316
|
-
}}
|
|
317
|
-
submitBehavior='submit'
|
|
318
|
-
numberOfLines={1}
|
|
283
|
+
<View
|
|
284
|
+
pointerEvents={onSearchBarClicked ? 'none' : 'auto'}
|
|
319
285
|
style={[
|
|
320
286
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
paddingVertical:
|
|
325
|
-
|
|
287
|
+
backgroundColor: theme.color.background3,
|
|
288
|
+
borderRadius: theme.spacing.radius.max,
|
|
289
|
+
paddingHorizontal: theme.spacing.spacing.s3,
|
|
290
|
+
paddingVertical: theme.spacing.spacing.s3,
|
|
291
|
+
marginTop: theme.spacing.spacing.s2,
|
|
292
|
+
flexDirection: 'row' as const,
|
|
293
|
+
alignItems: 'center' as const,
|
|
294
|
+
gap: theme.spacing.spacing.s2,
|
|
295
|
+
height: 48,
|
|
296
|
+
alignSelf: 'stretch',
|
|
326
297
|
},
|
|
327
|
-
searchStyle?.
|
|
298
|
+
searchStyle?.containerStyle,
|
|
328
299
|
]}
|
|
329
|
-
|
|
330
|
-
|
|
300
|
+
>
|
|
301
|
+
<Icon
|
|
302
|
+
name='search-fill'
|
|
303
|
+
size={searchStyle?.iconStyle?.width || 24}
|
|
304
|
+
height={searchStyle?.iconStyle?.height || 24}
|
|
305
|
+
width={searchStyle?.iconStyle?.width || 24}
|
|
306
|
+
color={searchStyle?.iconStyle?.tintColor || theme.color.iconSecondary}
|
|
307
|
+
icon={searchStyle?.icon}
|
|
308
|
+
imageStyle={searchStyle?.iconStyle}
|
|
309
|
+
/>
|
|
310
|
+
<TextInput
|
|
311
|
+
ref={inputRef}
|
|
312
|
+
placeholder={searchPlaceholderText}
|
|
313
|
+
placeholderTextColor={
|
|
314
|
+
searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
|
|
315
|
+
}
|
|
316
|
+
onChangeText={searchHandler}
|
|
317
|
+
returnKeyType='search'
|
|
318
|
+
value={searchInput}
|
|
319
|
+
editable={!onSearchBarClicked}
|
|
320
|
+
onSubmitEditing={() => {
|
|
321
|
+
onSubmitEditing?.();
|
|
322
|
+
inputRef.current?.focus();
|
|
323
|
+
}}
|
|
324
|
+
submitBehavior='submit'
|
|
325
|
+
numberOfLines={1}
|
|
326
|
+
style={[
|
|
327
|
+
{
|
|
328
|
+
flex: 1,
|
|
329
|
+
color: theme.color.textPrimary,
|
|
330
|
+
fontSize: 16,
|
|
331
|
+
paddingVertical: 4,
|
|
332
|
+
...theme.typography.heading4.regular,
|
|
333
|
+
},
|
|
334
|
+
searchStyle?.textStyle,
|
|
335
|
+
]}
|
|
336
|
+
/>
|
|
337
|
+
</View>
|
|
338
|
+
</Pressable>
|
|
331
339
|
)}
|
|
332
340
|
</View>
|
|
333
341
|
)}
|
|
@@ -18,8 +18,8 @@ export const getQuickReactionStyleLight = (
|
|
|
18
18
|
emojiContainerStyle: {
|
|
19
19
|
backgroundColor: color.background3,
|
|
20
20
|
borderRadius: spacing.radius.max,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
minHeight: 40,
|
|
22
|
+
minWidth: 40,
|
|
23
23
|
justifyContent: 'center',
|
|
24
24
|
alignItems: 'center',
|
|
25
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { JSX, useLayoutEffect } from "react";
|
|
2
|
-
import { Text, TouchableOpacity, View } from "react-native";
|
|
2
|
+
import { PixelRatio, Text, TouchableOpacity, View } from "react-native";
|
|
3
3
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
4
4
|
import { MessageBubbleAlignmentType } from "../../base/Types";
|
|
5
5
|
import { CometChatTheme } from "../../../theme/type";
|
|
@@ -129,19 +129,25 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
129
129
|
useLayoutEffect(() => {
|
|
130
130
|
reactionRef.current = messageObject?.getReactions()!;
|
|
131
131
|
let countEmoji = maxContentWidth ? 0 : 3;
|
|
132
|
+
|
|
133
|
+
// Scale width estimates by the system font scale so that when the user
|
|
134
|
+
// increases the device font/display size the layout calculation still
|
|
135
|
+
// fits reactions correctly and avoids cropping.
|
|
136
|
+
const fontScale = PixelRatio.getFontScale();
|
|
137
|
+
|
|
132
138
|
if (maxContentWidth) {
|
|
133
139
|
let remainingWidth = maxContentWidth;
|
|
134
140
|
for (let i = 0; i < reactionRef.current.length; i++) {
|
|
135
141
|
const currentReactionCount = reactionRef.current[i].getCount();
|
|
136
142
|
let widthToReduce = 0;
|
|
137
143
|
if (currentReactionCount < 10) {
|
|
138
|
-
widthToReduce = 45;
|
|
144
|
+
widthToReduce = 45 * fontScale;
|
|
139
145
|
} else if (currentReactionCount < 100) {
|
|
140
|
-
widthToReduce = 55;
|
|
146
|
+
widthToReduce = 55 * fontScale;
|
|
141
147
|
} else if (currentReactionCount < 1000) {
|
|
142
|
-
widthToReduce = 65;
|
|
148
|
+
widthToReduce = 65 * fontScale;
|
|
143
149
|
}
|
|
144
|
-
if (remainingWidth > 30 + widthToReduce) {
|
|
150
|
+
if (remainingWidth > 30 * fontScale + widthToReduce) {
|
|
145
151
|
remainingWidth = remainingWidth - widthToReduce;
|
|
146
152
|
countEmoji++;
|
|
147
153
|
continue;
|
|
@@ -17,15 +17,19 @@ export const getReactionsStyleLight = (
|
|
|
17
17
|
flexDirection: "row",
|
|
18
18
|
alignItems: "center",
|
|
19
19
|
gap: 2,
|
|
20
|
+
// Allow reactions row to wrap when system font size causes overflow
|
|
21
|
+
flexWrap: "wrap",
|
|
20
22
|
},
|
|
21
23
|
emojiStyle: {
|
|
22
24
|
containerStyle: {
|
|
23
25
|
paddingVertical: spacing.padding.p0_5,
|
|
24
26
|
paddingHorizontal: spacing.padding.p2,
|
|
25
|
-
height
|
|
27
|
+
// Use minHeight instead of fixed height so the container grows
|
|
28
|
+
minHeight: 24,
|
|
26
29
|
backgroundColor: color.background1,
|
|
27
30
|
borderRadius: 20,
|
|
28
31
|
flexDirection: "row",
|
|
32
|
+
alignItems: "center",
|
|
29
33
|
gap: 4,
|
|
30
34
|
borderWidth: 1,
|
|
31
35
|
borderColor: color.borderDark,
|
|
@@ -37,10 +41,13 @@ export const getReactionsStyleLight = (
|
|
|
37
41
|
containerStyle: {
|
|
38
42
|
paddingVertical: spacing.padding.p0_5,
|
|
39
43
|
paddingHorizontal: spacing.padding.p2,
|
|
40
|
-
height
|
|
44
|
+
// Use minHeight instead of fixed height so the container grows
|
|
45
|
+
// when system font/display size is increased (accessibility)
|
|
46
|
+
minHeight: 24,
|
|
41
47
|
backgroundColor: color.extendedPrimary100,
|
|
42
48
|
borderRadius: 20,
|
|
43
49
|
flexDirection: "row",
|
|
50
|
+
alignItems: "center",
|
|
44
51
|
gap: 4,
|
|
45
52
|
borderWidth: 1,
|
|
46
53
|
borderColor: color.borderDark,
|
|
@@ -52,10 +59,13 @@ export const getReactionsStyleLight = (
|
|
|
52
59
|
containerStyle: {
|
|
53
60
|
paddingVertical: spacing.padding.p0_5,
|
|
54
61
|
paddingHorizontal: spacing.padding.p2,
|
|
55
|
-
height
|
|
62
|
+
// Use minHeight instead of fixed height so the container grows
|
|
63
|
+
// when system font/display size is increased (accessibility)
|
|
64
|
+
minHeight: 24,
|
|
56
65
|
backgroundColor: color.background1,
|
|
57
66
|
borderRadius: 20,
|
|
58
67
|
flexDirection: "row",
|
|
68
|
+
alignItems: "center",
|
|
59
69
|
gap: 4,
|
|
60
70
|
borderWidth: 1,
|
|
61
71
|
borderColor: color.borderDark,
|
|
@@ -64,10 +74,13 @@ export const getReactionsStyleLight = (
|
|
|
64
74
|
activeContainerStyle: {
|
|
65
75
|
paddingVertical: spacing.padding.p0_5,
|
|
66
76
|
paddingHorizontal: spacing.padding.p2,
|
|
67
|
-
height
|
|
77
|
+
// Use minHeight instead of fixed height so the container grows
|
|
78
|
+
// when system font/display size is increased (accessibility)
|
|
79
|
+
minHeight: 24,
|
|
68
80
|
backgroundColor: color.extendedPrimary100,
|
|
69
81
|
borderRadius: 20,
|
|
70
82
|
flexDirection: "row",
|
|
83
|
+
alignItems: "center",
|
|
71
84
|
gap: 4,
|
|
72
85
|
borderWidth: 1,
|
|
73
86
|
borderColor: color.borderDark,
|
|
@@ -81,15 +94,20 @@ export const getReactionsStyleLight = (
|
|
|
81
94
|
flexDirection: "row",
|
|
82
95
|
alignItems: "center",
|
|
83
96
|
gap: 2,
|
|
97
|
+
// Allow reactions row to wrap when system font size causes overflow
|
|
98
|
+
flexWrap: "wrap",
|
|
84
99
|
},
|
|
85
100
|
emojiStyle: {
|
|
86
101
|
containerStyle: {
|
|
87
102
|
paddingVertical: spacing.padding.p0_5,
|
|
88
103
|
paddingHorizontal: spacing.padding.p2,
|
|
89
|
-
height
|
|
104
|
+
// Use minHeight instead of fixed height so the container grows
|
|
105
|
+
// when system font/display size is increased (accessibility)
|
|
106
|
+
minHeight: 24,
|
|
90
107
|
backgroundColor: color.background1,
|
|
91
108
|
borderRadius: 20,
|
|
92
109
|
flexDirection: "row",
|
|
110
|
+
alignItems: "center",
|
|
93
111
|
gap: 4,
|
|
94
112
|
borderWidth: 1,
|
|
95
113
|
borderColor: color.borderDark,
|
|
@@ -101,10 +119,13 @@ export const getReactionsStyleLight = (
|
|
|
101
119
|
containerStyle: {
|
|
102
120
|
paddingVertical: spacing.padding.p0_5,
|
|
103
121
|
paddingHorizontal: spacing.padding.p2,
|
|
104
|
-
height
|
|
122
|
+
// Use minHeight instead of fixed height so the container grows
|
|
123
|
+
// when system font/display size is increased (accessibility)
|
|
124
|
+
minHeight: 24,
|
|
105
125
|
backgroundColor: color.extendedPrimary100,
|
|
106
126
|
borderRadius: 20,
|
|
107
127
|
flexDirection: "row",
|
|
128
|
+
alignItems: "center",
|
|
108
129
|
gap: 4,
|
|
109
130
|
borderWidth: 1,
|
|
110
131
|
borderColor: color.borderDark,
|
|
@@ -116,10 +137,13 @@ export const getReactionsStyleLight = (
|
|
|
116
137
|
containerStyle: {
|
|
117
138
|
paddingVertical: spacing.padding.p0_5,
|
|
118
139
|
paddingHorizontal: spacing.padding.p2,
|
|
119
|
-
height
|
|
140
|
+
// Use minHeight instead of fixed height so the container grows
|
|
141
|
+
// when system font/display size is increased (accessibility)
|
|
142
|
+
minHeight: 24,
|
|
120
143
|
backgroundColor: color.background1,
|
|
121
144
|
borderRadius: 20,
|
|
122
145
|
flexDirection: "row",
|
|
146
|
+
alignItems: "center",
|
|
123
147
|
gap: 4,
|
|
124
148
|
borderWidth: 1,
|
|
125
149
|
borderColor: color.borderDark,
|
|
@@ -128,10 +152,13 @@ export const getReactionsStyleLight = (
|
|
|
128
152
|
activeContainerStyle: {
|
|
129
153
|
paddingVertical: spacing.padding.p0_5,
|
|
130
154
|
paddingHorizontal: spacing.padding.p2,
|
|
131
|
-
height
|
|
155
|
+
// Use minHeight instead of fixed height so the container grows
|
|
156
|
+
// when system font/display size is increased (accessibility)
|
|
157
|
+
minHeight: 24,
|
|
132
158
|
backgroundColor: color.extendedPrimary100,
|
|
133
159
|
borderRadius: 20,
|
|
134
160
|
flexDirection: "row",
|
|
161
|
+
alignItems: "center",
|
|
135
162
|
gap: 4,
|
|
136
163
|
borderWidth: 1,
|
|
137
164
|
borderColor: color.borderDark,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useLayoutEffect, useState, useRef, useCallback } from "react";
|
|
1
|
+
import React, { useLayoutEffect, useState, useRef, useCallback, useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
StyleProp,
|
|
4
4
|
Text,
|
|
@@ -63,92 +63,77 @@ export const CometChatTextBubbleText = (
|
|
|
63
63
|
toggleTextStyle,
|
|
64
64
|
} = props;
|
|
65
65
|
|
|
66
|
-
const [formattedText, setFormattedText] = useState<string>(text);
|
|
67
66
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
68
67
|
const [isTruncatable, setIsTruncatable] = useState(false);
|
|
69
|
-
|
|
70
|
-
// store container width for accurate measurement
|
|
71
68
|
const [containerWidth, setContainerWidth] = useState<number | null>(null);
|
|
69
|
+
const [measurementComplete, setMeasurementComplete] = useState(false);
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
* measuredCache helps avoid re-measuring if the same text+width was already measured.
|
|
75
|
-
* Structure: { key: string } where key = `${text}::${width}`
|
|
76
|
-
*/
|
|
71
|
+
// Refs to track state without causing re-renders
|
|
77
72
|
const measuredCacheRef = useRef<Record<string, boolean>>({});
|
|
73
|
+
const lastTextRef = useRef<string>(text);
|
|
78
74
|
|
|
79
|
-
//
|
|
80
|
-
|
|
75
|
+
// Compute formatted text synchronously - no state update needed
|
|
76
|
+
const formattedText = useMemo(() => {
|
|
81
77
|
let finalText = text;
|
|
82
78
|
if (textFormatters && textFormatters.length) {
|
|
83
79
|
for (let i = 0; i < textFormatters.length; i++) {
|
|
84
80
|
finalText = textFormatters[i].getFormattedText(finalText);
|
|
85
81
|
}
|
|
86
82
|
}
|
|
83
|
+
return finalText as string;
|
|
84
|
+
}, [text, textFormatters]);
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
86
|
+
// Reset state only when text actually changes
|
|
87
|
+
useLayoutEffect(() => {
|
|
88
|
+
if (lastTextRef.current !== text) {
|
|
89
|
+
lastTextRef.current = text;
|
|
92
90
|
setIsExpanded(false);
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
setIsTruncatable(false);
|
|
92
|
+
setMeasurementComplete(false);
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
}, [
|
|
98
|
-
text /* only textFormatters intentionally omitted from deps if stable; if not stable include it */,
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
// handler to capture container width whenever layout changes
|
|
102
|
-
const onContainerLayout = useCallback(
|
|
103
|
-
(e: LayoutChangeEvent) => {
|
|
104
|
-
const w = Math.round(e.nativeEvent.layout.width);
|
|
105
|
-
if (w && w !== containerWidth) {
|
|
106
|
-
setContainerWidth(w);
|
|
107
|
-
// Do NOT clear isExpanded here — measurement may change truncation but we want to
|
|
108
|
-
// preserve user's expanded/collapsed state unless the text itself changed.
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
[containerWidth]
|
|
112
|
-
);
|
|
94
|
+
}, [text]);
|
|
113
95
|
|
|
114
|
-
//
|
|
115
|
-
const
|
|
116
|
-
|
|
96
|
+
// Handler to capture container width - use functional update to avoid dependency
|
|
97
|
+
const onContainerLayout = useCallback((e: LayoutChangeEvent) => {
|
|
98
|
+
const w = Math.round(e.nativeEvent.layout.width);
|
|
99
|
+
if (w > 0) {
|
|
100
|
+
setContainerWidth(prev => prev === w ? prev : w);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
// Called when hidden text is laid out
|
|
105
|
+
const onMeasuredTextLayout = useCallback((e: TextLayoutEvent) => {
|
|
117
106
|
const key = `${formattedText}::${containerWidth ?? 0}`;
|
|
118
107
|
|
|
119
|
-
//
|
|
120
|
-
if (measuredCacheRef.current[key])
|
|
108
|
+
// Skip if already measured
|
|
109
|
+
if (measuredCacheRef.current[key]) {
|
|
110
|
+
if (!measurementComplete) {
|
|
111
|
+
setMeasurementComplete(true);
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
121
115
|
|
|
122
116
|
const lines = e.nativeEvent.lines;
|
|
123
117
|
const isNowTruncatable = !!(lines && lines.length > collapseLines);
|
|
124
118
|
|
|
119
|
+
measuredCacheRef.current[key] = true;
|
|
125
120
|
setIsTruncatable(isNowTruncatable);
|
|
126
|
-
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const toggle = () => setIsExpanded(
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Hidden measurement `Text`:
|
|
133
|
-
* - we render it only when we have containerWidth (so it can measure correctly)
|
|
134
|
-
* - style uses same font metrics as visible text because it inherits textStyle
|
|
135
|
-
* - opacity: 0 and position absolute so it does not affect layout
|
|
136
|
-
*
|
|
137
|
-
* Important: We key the hidden Text by formattedText + containerWidth so React remounts
|
|
138
|
-
* it and triggers onTextLayout when either changes.
|
|
139
|
-
*/
|
|
121
|
+
setMeasurementComplete(true);
|
|
122
|
+
}, [formattedText, containerWidth, collapseLines, measurementComplete]);
|
|
123
|
+
|
|
124
|
+
const toggle = useCallback(() => setIsExpanded(v => !v), []);
|
|
125
|
+
|
|
140
126
|
const hiddenTextKey = `${formattedText}::${containerWidth ?? 0}`;
|
|
127
|
+
const needsMeasurement = containerWidth !== null && !measuredCacheRef.current[hiddenTextKey];
|
|
141
128
|
|
|
142
129
|
return (
|
|
143
130
|
<View onLayout={onContainerLayout}>
|
|
144
|
-
{/* Hidden measurement text
|
|
145
|
-
{
|
|
131
|
+
{/* Hidden measurement text - only render if we need to measure */}
|
|
132
|
+
{needsMeasurement && (
|
|
146
133
|
<Text
|
|
147
134
|
key={hiddenTextKey}
|
|
148
|
-
// make sure the hidden text has same width as container
|
|
149
135
|
style={[
|
|
150
|
-
|
|
151
|
-
{ position: "absolute", left: 0, top: -10000, width: containerWidth, opacity: 0 },
|
|
136
|
+
{ position: "absolute", left: 0, top: -10000, width: containerWidth!, opacity: 0 },
|
|
152
137
|
textStyle as any,
|
|
153
138
|
]}
|
|
154
139
|
onTextLayout={onMeasuredTextLayout}
|
|
@@ -157,7 +142,7 @@ export const CometChatTextBubbleText = (
|
|
|
157
142
|
>
|
|
158
143
|
{formattedText}
|
|
159
144
|
</Text>
|
|
160
|
-
)
|
|
145
|
+
)}
|
|
161
146
|
|
|
162
147
|
{/* Visible text */}
|
|
163
148
|
<Text
|
|
@@ -168,8 +153,8 @@ export const CometChatTextBubbleText = (
|
|
|
168
153
|
{formattedText}
|
|
169
154
|
</Text>
|
|
170
155
|
|
|
171
|
-
{/* Toggle
|
|
172
|
-
{isTruncatable
|
|
156
|
+
{/* Toggle - only show after measurement is complete to prevent flicker */}
|
|
157
|
+
{measurementComplete && isTruncatable && (
|
|
173
158
|
<View style={[{ alignItems: "flex-end", marginTop: 6 }, toggleContainerStyle]}>
|
|
174
159
|
<TouchableOpacity onPress={toggle} accessibilityRole='button'>
|
|
175
160
|
<Text style={[{ alignSelf: "flex-end" }, textStyle, toggleTextStyle]}>
|
|
@@ -177,7 +162,7 @@ export const CometChatTextBubbleText = (
|
|
|
177
162
|
</Text>
|
|
178
163
|
</TouchableOpacity>
|
|
179
164
|
</View>
|
|
180
|
-
)
|
|
165
|
+
)}
|
|
181
166
|
</View>
|
|
182
167
|
);
|
|
183
168
|
};
|
package/src/theme/index.ts
CHANGED