@cometchat/chat-uikit-react-native 5.2.10 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +4 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +909 -10
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorPackage.kt +24 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +5382 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +452 -0
- package/ios/FileManager.m +430 -3
- package/ios/RichTextEditorView.swift +5504 -0
- package/ios/RichTextEditorViewManager.m +66 -0
- package/ios/RichTextEditorViewManager.swift +291 -0
- package/ios/ToolbarIcons.swift +736 -0
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +4557 -0
- package/src/CometChatCompactMessageComposer/SingleLineTextComposerConfiguration.tsx +568 -0
- package/src/CometChatCompactMessageComposer/heightUtils.ts +204 -0
- package/src/CometChatCompactMessageComposer/index.ts +56 -0
- package/src/CometChatCompactMessageComposer/resources/index.ts +5 -0
- package/src/CometChatCompactMessageComposer/styles.ts +291 -0
- package/src/CometChatConversations/CometChatConversations.tsx +139 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +25 -21
- package/src/CometChatMessageComposer/styles.tsx +0 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +39 -6
- package/src/CometChatMessageList/components/MessageListItem.tsx +11 -8
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
- package/src/CometChatRichTextEditor/index.tsx +385 -0
- package/src/CometChatRichTextEditor/types.ts +162 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -3
- package/src/CometChatSearch/style.ts +3 -3
- package/src/index.ts +48 -1
- package/src/shared/constants/UIKitConstants.ts +12 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
- package/src/shared/formatters/index.ts +3 -0
- package/src/shared/framework/MessageDataSource.tsx +93 -2
- package/src/shared/helper/composerHelpers.ts +553 -0
- package/src/shared/helper/useKeyboard.tsx +7 -17
- package/src/shared/icons/components/code-blocks.tsx +13 -0
- package/src/shared/icons/components/code.tsx +11 -0
- package/src/shared/icons/components/format-bold.tsx +11 -0
- package/src/shared/icons/components/format-italic.tsx +11 -0
- package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
- package/src/shared/icons/components/format-list-numbered.tsx +11 -0
- package/src/shared/icons/components/format-quote.tsx +13 -0
- package/src/shared/icons/components/format-strikethrough.tsx +13 -0
- package/src/shared/icons/components/format-underlined.tsx +11 -0
- package/src/shared/icons/components/smileys-&-people.tsx +1 -1
- package/src/shared/icons/icon-mapping.tsx +18 -0
- package/src/shared/index.ts +54 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +38 -32
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +6 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +19 -13
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
- package/src/shared/utils/MarkdownUtils.ts +143 -0
- package/src/shared/utils/MentionUtils.ts +37 -0
- package/src/shared/utils/MessageUtils.tsx +55 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
- package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
- package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
- package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
- package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
- package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
- 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/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +108 -75
- package/src/shared/views/index.ts +39 -0
- package/src/theme/index.ts +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
Text,
|
|
5
|
+
TextInput,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { useTheme } from "../../../theme";
|
|
10
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
|
|
11
|
+
import {
|
|
12
|
+
getLinkConfirmPopupStyleLight,
|
|
13
|
+
getLinkConfirmPopupStyleDark,
|
|
14
|
+
} from "./style";
|
|
15
|
+
|
|
16
|
+
export interface CometChatLinkConfirmPopupInterface {
|
|
17
|
+
/** Whether the popup is visible */
|
|
18
|
+
visible: boolean;
|
|
19
|
+
/** The URL of the tapped link */
|
|
20
|
+
url: string;
|
|
21
|
+
/** Initial display text for edit mode */
|
|
22
|
+
initialEditText?: string;
|
|
23
|
+
/** Initial URL for edit mode */
|
|
24
|
+
initialEditUrl?: string;
|
|
25
|
+
/** When true, opens directly in edit mode with "Insert Link" title.
|
|
26
|
+
* The confirm view (Edit/Remove) is skipped entirely. */
|
|
27
|
+
insertMode?: boolean;
|
|
28
|
+
/** Called when the popup is dismissed (backdrop press or cancel) */
|
|
29
|
+
onDismiss: () => void;
|
|
30
|
+
/** Called when the user saves an edited link */
|
|
31
|
+
onEdit: (newUrl: string, newText: string) => void;
|
|
32
|
+
/** Called when the user removes the link */
|
|
33
|
+
onRemove: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const CometChatLinkConfirmPopup = (props: CometChatLinkConfirmPopupInterface) => {
|
|
37
|
+
const {
|
|
38
|
+
visible,
|
|
39
|
+
url,
|
|
40
|
+
initialEditText = "",
|
|
41
|
+
initialEditUrl = "",
|
|
42
|
+
insertMode = false,
|
|
43
|
+
onDismiss,
|
|
44
|
+
onEdit,
|
|
45
|
+
onRemove,
|
|
46
|
+
} = props;
|
|
47
|
+
|
|
48
|
+
const theme = useTheme();
|
|
49
|
+
const { t } = useCometChatTranslation();
|
|
50
|
+
const styles = useMemo(
|
|
51
|
+
() =>
|
|
52
|
+
theme.mode === "dark"
|
|
53
|
+
? getLinkConfirmPopupStyleDark(theme.color, theme.spacing, theme.typography)
|
|
54
|
+
: getLinkConfirmPopupStyleLight(theme.color, theme.spacing, theme.typography),
|
|
55
|
+
[theme]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const [editMode, setEditMode] = useState(false);
|
|
59
|
+
const [editUrl, setEditUrl] = useState(initialEditUrl || url);
|
|
60
|
+
const [editText, setEditText] = useState(initialEditText);
|
|
61
|
+
|
|
62
|
+
// Sync state when popup opens with new data
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (visible) {
|
|
65
|
+
setEditMode(insertMode);
|
|
66
|
+
setEditUrl(initialEditUrl || url);
|
|
67
|
+
setEditText(initialEditText);
|
|
68
|
+
}
|
|
69
|
+
}, [visible, url, initialEditUrl, initialEditText, insertMode]);
|
|
70
|
+
|
|
71
|
+
const handleDismiss = () => {
|
|
72
|
+
setEditMode(false);
|
|
73
|
+
onDismiss();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handleSave = () => {
|
|
77
|
+
if (editUrl.trim()) {
|
|
78
|
+
onEdit(editUrl.trim(), editText.trim() || editUrl.trim());
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Modal
|
|
84
|
+
visible={visible}
|
|
85
|
+
transparent
|
|
86
|
+
animationType="fade"
|
|
87
|
+
onRequestClose={handleDismiss}
|
|
88
|
+
>
|
|
89
|
+
<TouchableOpacity
|
|
90
|
+
style={styles.overlayStyle}
|
|
91
|
+
activeOpacity={1}
|
|
92
|
+
onPress={handleDismiss}
|
|
93
|
+
>
|
|
94
|
+
<TouchableOpacity
|
|
95
|
+
activeOpacity={1}
|
|
96
|
+
style={styles.containerStyle}
|
|
97
|
+
>
|
|
98
|
+
{editMode ? (
|
|
99
|
+
<>
|
|
100
|
+
<Text style={styles.titleTextStyle}>
|
|
101
|
+
{insertMode ? t("INSERT_LINK") : t("EDIT_LINK")}
|
|
102
|
+
</Text>
|
|
103
|
+
<TextInput
|
|
104
|
+
testID="link-tap-edit-text-input"
|
|
105
|
+
accessibilityLabel="link-tap-edit-text-input"
|
|
106
|
+
placeholder={t("LINK_TEXT")}
|
|
107
|
+
placeholderTextColor={theme.color.textTertiary as string}
|
|
108
|
+
value={editText}
|
|
109
|
+
onChangeText={setEditText}
|
|
110
|
+
style={styles.inputStyle}
|
|
111
|
+
autoFocus
|
|
112
|
+
/>
|
|
113
|
+
<TextInput
|
|
114
|
+
testID="link-tap-edit-url-input"
|
|
115
|
+
accessibilityLabel="link-tap-edit-url-input"
|
|
116
|
+
placeholder={t("URL")}
|
|
117
|
+
placeholderTextColor={theme.color.textTertiary as string}
|
|
118
|
+
value={editUrl}
|
|
119
|
+
onChangeText={setEditUrl}
|
|
120
|
+
style={styles.inputStyle}
|
|
121
|
+
keyboardType="url"
|
|
122
|
+
autoCapitalize="none"
|
|
123
|
+
/>
|
|
124
|
+
<View style={styles.buttonRowStyle}>
|
|
125
|
+
<TouchableOpacity
|
|
126
|
+
testID="link-tap-edit-cancel"
|
|
127
|
+
style={styles.cancelButtonStyle}
|
|
128
|
+
onPress={handleDismiss}
|
|
129
|
+
>
|
|
130
|
+
<Text style={styles.cancelButtonTextStyle}>{ t("CANCEL") }</Text>
|
|
131
|
+
</TouchableOpacity>
|
|
132
|
+
<TouchableOpacity
|
|
133
|
+
testID="link-tap-edit-confirm"
|
|
134
|
+
disabled={!editUrl.trim()}
|
|
135
|
+
style={[
|
|
136
|
+
styles.confirmButtonStyle,
|
|
137
|
+
!editUrl.trim() && { opacity: 0.4 },
|
|
138
|
+
]}
|
|
139
|
+
onPress={handleSave}
|
|
140
|
+
>
|
|
141
|
+
<Text style={styles.confirmButtonTextStyle}>
|
|
142
|
+
{insertMode ? t("INSERT") : t("SAVE")}
|
|
143
|
+
</Text>
|
|
144
|
+
</TouchableOpacity>
|
|
145
|
+
</View>
|
|
146
|
+
</>
|
|
147
|
+
) : (
|
|
148
|
+
<>
|
|
149
|
+
<View style={styles.confirmSectionStyle}>
|
|
150
|
+
<Text style={styles.titleTextStyle}>{ t("LINK") }</Text>
|
|
151
|
+
<Text
|
|
152
|
+
testID="link-tap-url-display"
|
|
153
|
+
style={styles.urlTextStyle}
|
|
154
|
+
numberOfLines={2}
|
|
155
|
+
>
|
|
156
|
+
{url}
|
|
157
|
+
</Text>
|
|
158
|
+
</View>
|
|
159
|
+
<View
|
|
160
|
+
style={[styles.buttonRowStyle, styles.confirmSectionDividerStyle]}
|
|
161
|
+
>
|
|
162
|
+
<TouchableOpacity
|
|
163
|
+
testID="link-tap-edit"
|
|
164
|
+
style={styles.cancelButtonStyle}
|
|
165
|
+
onPress={() => setEditMode(true)}
|
|
166
|
+
>
|
|
167
|
+
<Text style={styles.cancelButtonTextStyle}>{ t("EDIT") }</Text>
|
|
168
|
+
</TouchableOpacity>
|
|
169
|
+
<TouchableOpacity
|
|
170
|
+
testID="link-tap-remove"
|
|
171
|
+
style={styles.removeButtonStyle}
|
|
172
|
+
onPress={onRemove}
|
|
173
|
+
>
|
|
174
|
+
<Text style={styles.removeButtonTextStyle}>{ t("REMOVE") }</Text>
|
|
175
|
+
</TouchableOpacity>
|
|
176
|
+
</View>
|
|
177
|
+
</>
|
|
178
|
+
)}
|
|
179
|
+
</TouchableOpacity>
|
|
180
|
+
</TouchableOpacity>
|
|
181
|
+
</Modal>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CometChatLinkConfirmPopup,
|
|
3
|
+
} from "./CometChatLinkConfirmPopup";
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
CometChatLinkConfirmPopupInterface,
|
|
7
|
+
} from "./CometChatLinkConfirmPopup";
|
|
8
|
+
|
|
9
|
+
export type { LinkConfirmPopupStyle } from "./style";
|
|
10
|
+
export {
|
|
11
|
+
getLinkConfirmPopupStyleLight,
|
|
12
|
+
getLinkConfirmPopupStyleDark,
|
|
13
|
+
} from "./style";
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { StyleSheet, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import { CometChatTheme } from "../../../theme/type";
|
|
3
|
+
import { deepMerge } from "../../helper/helperFunctions";
|
|
4
|
+
|
|
5
|
+
export type LinkConfirmPopupStyle = {
|
|
6
|
+
overlayStyle: ViewStyle;
|
|
7
|
+
containerStyle: ViewStyle;
|
|
8
|
+
titleTextStyle: TextStyle;
|
|
9
|
+
urlTextStyle: TextStyle;
|
|
10
|
+
inputStyle: TextStyle;
|
|
11
|
+
buttonRowStyle: ViewStyle;
|
|
12
|
+
cancelButtonStyle: ViewStyle;
|
|
13
|
+
cancelButtonTextStyle: TextStyle;
|
|
14
|
+
confirmButtonStyle: ViewStyle;
|
|
15
|
+
confirmButtonTextStyle: TextStyle;
|
|
16
|
+
removeButtonStyle: ViewStyle;
|
|
17
|
+
removeButtonTextStyle: TextStyle;
|
|
18
|
+
confirmSectionStyle: ViewStyle;
|
|
19
|
+
confirmSectionDividerStyle: ViewStyle;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getLinkConfirmPopupStyleLight = (
|
|
23
|
+
color: CometChatTheme["color"],
|
|
24
|
+
spacing: CometChatTheme["spacing"],
|
|
25
|
+
typography: CometChatTheme["typography"]
|
|
26
|
+
): LinkConfirmPopupStyle => {
|
|
27
|
+
return StyleSheet.create({
|
|
28
|
+
overlayStyle: {
|
|
29
|
+
flex: 1,
|
|
30
|
+
backgroundColor: "rgba(0,0,0,0.4)",
|
|
31
|
+
justifyContent: "center",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
},
|
|
34
|
+
containerStyle: {
|
|
35
|
+
backgroundColor: color.background1,
|
|
36
|
+
borderWidth: 1,
|
|
37
|
+
borderColor: color.borderLight,
|
|
38
|
+
borderRadius: spacing.radius.r4,
|
|
39
|
+
padding: spacing.padding.p6,
|
|
40
|
+
width: "85%",
|
|
41
|
+
maxWidth: 400,
|
|
42
|
+
gap: spacing.padding.p3,
|
|
43
|
+
shadowColor: "#101828",
|
|
44
|
+
shadowOffset: { width: 0, height: 12 },
|
|
45
|
+
shadowOpacity: 0.08,
|
|
46
|
+
shadowRadius: 16,
|
|
47
|
+
elevation: 8,
|
|
48
|
+
},
|
|
49
|
+
titleTextStyle: {
|
|
50
|
+
color: color.textPrimary,
|
|
51
|
+
...typography.heading2.medium,
|
|
52
|
+
},
|
|
53
|
+
urlTextStyle: {
|
|
54
|
+
color: color.textHighlight,
|
|
55
|
+
...typography.body.regular,
|
|
56
|
+
},
|
|
57
|
+
inputStyle: {
|
|
58
|
+
borderBottomWidth: 1,
|
|
59
|
+
borderBottomColor: color.borderDefault,
|
|
60
|
+
paddingVertical: spacing.padding.p2,
|
|
61
|
+
color: color.textPrimary,
|
|
62
|
+
...typography.body.regular,
|
|
63
|
+
},
|
|
64
|
+
buttonRowStyle: {
|
|
65
|
+
flexDirection: "row",
|
|
66
|
+
gap: spacing.padding.p2,
|
|
67
|
+
paddingTop: spacing.padding.p3,
|
|
68
|
+
},
|
|
69
|
+
cancelButtonStyle: {
|
|
70
|
+
flex: 1,
|
|
71
|
+
height: spacing.spacing.s10,
|
|
72
|
+
borderWidth: 1,
|
|
73
|
+
borderColor: color.borderDark,
|
|
74
|
+
borderRadius: spacing.radius.r2,
|
|
75
|
+
justifyContent: "center",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
},
|
|
78
|
+
cancelButtonTextStyle: {
|
|
79
|
+
color: color.textPrimary,
|
|
80
|
+
...typography.button.medium,
|
|
81
|
+
},
|
|
82
|
+
confirmButtonStyle: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
height: spacing.spacing.s10,
|
|
85
|
+
backgroundColor: color.primary,
|
|
86
|
+
borderRadius: spacing.radius.r2,
|
|
87
|
+
justifyContent: "center",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
},
|
|
90
|
+
confirmButtonTextStyle: {
|
|
91
|
+
color: color.primaryButtonIcon,
|
|
92
|
+
...typography.button.medium,
|
|
93
|
+
},
|
|
94
|
+
removeButtonStyle: {
|
|
95
|
+
flex: 1,
|
|
96
|
+
height: spacing.spacing.s10,
|
|
97
|
+
backgroundColor: color.error,
|
|
98
|
+
borderRadius: spacing.radius.r2,
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
},
|
|
102
|
+
removeButtonTextStyle: {
|
|
103
|
+
color: color.primaryButtonIcon,
|
|
104
|
+
...typography.button.medium,
|
|
105
|
+
},
|
|
106
|
+
confirmSectionStyle: {
|
|
107
|
+
gap: spacing.padding.p2,
|
|
108
|
+
},
|
|
109
|
+
confirmSectionDividerStyle: {
|
|
110
|
+
borderTopWidth: 1,
|
|
111
|
+
borderTopColor: color.borderLight,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const getLinkConfirmPopupStyleDark = (
|
|
117
|
+
color: CometChatTheme["color"],
|
|
118
|
+
spacing: CometChatTheme["spacing"],
|
|
119
|
+
typography: CometChatTheme["typography"]
|
|
120
|
+
): LinkConfirmPopupStyle => {
|
|
121
|
+
return <LinkConfirmPopupStyle>(
|
|
122
|
+
deepMerge(getLinkConfirmPopupStyleLight(color, spacing, typography), {
|
|
123
|
+
containerStyle: {
|
|
124
|
+
backgroundColor: color.background2,
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
};
|
|
@@ -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,
|