@cometchat/chat-uikit-react-native 5.2.4 → 5.2.6
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/CometChatGroupMembers/CometChatGroupMembers.tsx +23 -7
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +34 -2
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +4 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +165 -89
- package/src/CometChatSearch/CometChatSearch.tsx +604 -158
- package/src/shared/helper/helperFunctions.ts +1 -2
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +10 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +8 -0
- package/src/shared/views/CometChatList/Header.tsx +1 -0
- package/src/shared/views/CometChatList/styles.ts +4 -2
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +8 -0
- package/src/theme/provider.tsx +17 -8
|
@@ -78,8 +78,7 @@ export function getLastSeenTime(timestamp: number | null | undefined): string {
|
|
|
78
78
|
try {
|
|
79
79
|
if (timestamp === null || timestamp === undefined) {
|
|
80
80
|
// Move the hook call inside the function, just like in functions.js
|
|
81
|
-
|
|
82
|
-
return t("LAST_SEEN_UNKNOWN");
|
|
81
|
+
return "";
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
// Convert to milliseconds if in seconds
|
|
@@ -52,8 +52,16 @@ export const CometChatAvatar = (props: CometChatAvatarProps) => {
|
|
|
52
52
|
return <Image source={imageSource} style={[avatarStyle.imageStyle]} />;
|
|
53
53
|
}
|
|
54
54
|
const initials = [...(name || "")].slice(0, 2).join("").toUpperCase();
|
|
55
|
-
|
|
56
|
-
return
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Text
|
|
58
|
+
style={[avatarStyle.textStyle]}
|
|
59
|
+
adjustsFontSizeToFit={true}
|
|
60
|
+
numberOfLines={1}
|
|
61
|
+
>
|
|
62
|
+
{initials}
|
|
63
|
+
</Text>
|
|
64
|
+
);
|
|
57
65
|
}, [image, name, avatarStyle.imageStyle, avatarStyle.textStyle]);
|
|
58
66
|
|
|
59
67
|
return <View style={[avatarStyle.containerStyle]}>{getImageView()}</View>;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
GestureResponderEvent,
|
|
7
7
|
ImageSourcePropType,
|
|
8
8
|
ImageStyle,
|
|
9
|
+
Platform,
|
|
9
10
|
StyleProp,
|
|
10
11
|
Text,
|
|
11
12
|
TextStyle,
|
|
@@ -245,11 +246,17 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
|
|
|
245
246
|
|
|
246
247
|
const listHandlerRef = useRef<any>(null);
|
|
247
248
|
const initialRunRef = useRef(true);
|
|
249
|
+
const selectionEffectDidMountRef = useRef(false);
|
|
248
250
|
|
|
249
251
|
const [list, setList] = useState<any[]>([]);
|
|
250
252
|
const [dataLoadingStatus, setDataLoadingStatus] = useState<string>(LOADING);
|
|
251
253
|
|
|
252
254
|
useEffect(() => {
|
|
255
|
+
// Skip calling onSelection on initial mount; only trigger after a user-driven change
|
|
256
|
+
if (!selectionEffectDidMountRef.current) {
|
|
257
|
+
selectionEffectDidMountRef.current = true;
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
253
260
|
if (props.onSelection) {
|
|
254
261
|
const selectedArray = Object.values(selectedItems);
|
|
255
262
|
props.onSelection(selectedArray);
|
|
@@ -766,6 +773,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
|
|
|
766
773
|
showsVerticalScrollIndicator={false}
|
|
767
774
|
ListFooterComponent={renderFooter}
|
|
768
775
|
keyboardShouldPersistTaps='always'
|
|
776
|
+
keyboardDismissMode={Platform.OS === 'ios' ? 'on-drag' : 'none'}
|
|
769
777
|
/>
|
|
770
778
|
</View>
|
|
771
779
|
);
|
|
@@ -39,7 +39,8 @@ const styles = StyleSheet.create({
|
|
|
39
39
|
flexDirection: "row",
|
|
40
40
|
alignItems: "center",
|
|
41
41
|
justifyContent: "center",
|
|
42
|
-
|
|
42
|
+
minHeight: 44, // minHeight for accessibility
|
|
43
|
+
paddingVertical:8,
|
|
43
44
|
},
|
|
44
45
|
selectedCountText: {
|
|
45
46
|
paddingLeft: 10,
|
|
@@ -90,11 +91,12 @@ const styles = StyleSheet.create({
|
|
|
90
91
|
width: "100%",
|
|
91
92
|
},
|
|
92
93
|
headerLetterStyle: {
|
|
93
|
-
|
|
94
|
+
minHeight: 24, // minHeight for accessibility
|
|
94
95
|
fontWeight: "500",
|
|
95
96
|
fontFamily: undefined,
|
|
96
97
|
fontSize: 13,
|
|
97
98
|
marginTop: 8,
|
|
99
|
+
paddingVertical: 4,
|
|
98
100
|
},
|
|
99
101
|
dividerStyle: {
|
|
100
102
|
height: 1,
|
|
@@ -88,6 +88,12 @@ export interface CometChatMessageInputInterface {
|
|
|
88
88
|
* @type {RefObject<any>}
|
|
89
89
|
*/
|
|
90
90
|
messageInputRef?: RefObject<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Selection state for the TextInput to control cursor position.
|
|
93
|
+
*
|
|
94
|
+
* @type {{ start: number; end: number } | undefined}
|
|
95
|
+
*/
|
|
96
|
+
selection?: { start: number; end: number };
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
/**
|
|
@@ -112,6 +118,7 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
|
|
|
112
118
|
onSelectionChange,
|
|
113
119
|
messageInputRef,
|
|
114
120
|
VoiceRecordingButtonView,
|
|
121
|
+
selection,
|
|
115
122
|
} = props;
|
|
116
123
|
|
|
117
124
|
return (
|
|
@@ -125,6 +132,7 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
|
|
|
125
132
|
textAlignVertical='top'
|
|
126
133
|
placeholder={placeHolderText}
|
|
127
134
|
onSelectionChange={onSelectionChange}
|
|
135
|
+
selection={selection}
|
|
128
136
|
onFocus={() => {
|
|
129
137
|
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
130
138
|
alignment: ViewAlignment.composerBottom,
|
package/src/theme/provider.tsx
CHANGED
|
@@ -66,15 +66,20 @@ export const CometChatThemeProvider = ({
|
|
|
66
66
|
const updatedSpacing = light.spacing
|
|
67
67
|
? CometChatThemeHelper.updateSpacing(light.spacing)
|
|
68
68
|
: {} as any;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
69
|
+
|
|
70
|
+
// Create a new object cause react native will know the theme has changed
|
|
71
|
+
const updatedLight = {
|
|
72
|
+
...light,
|
|
73
|
+
color: updatedColors,
|
|
74
|
+
spacing: updatedSpacing
|
|
75
|
+
};
|
|
76
|
+
const mergedTheme = deepMerge(parentProviderTheme.light, updatedLight);
|
|
72
77
|
const defaultLightThemeWithOverridesApplied = isColorAvailable ? lightThemeMaker(
|
|
73
78
|
mergedTheme.spacing as CometChatTheme["spacing"],
|
|
74
79
|
mergedTheme.color as CometChatTheme["color"],
|
|
75
80
|
mergedTheme.typography as CometChatTheme["typography"]
|
|
76
81
|
) : mergedTheme;
|
|
77
|
-
return deepMerge(defaultLightThemeWithOverridesApplied,
|
|
82
|
+
return deepMerge(defaultLightThemeWithOverridesApplied, updatedLight);
|
|
78
83
|
}
|
|
79
84
|
return parentProviderTheme.light;
|
|
80
85
|
}, [light, parentProviderTheme.light]);
|
|
@@ -91,15 +96,19 @@ export const CometChatThemeProvider = ({
|
|
|
91
96
|
const updatedSpacing = dark.spacing
|
|
92
97
|
? CometChatThemeHelper.updateSpacing(dark.spacing)
|
|
93
98
|
: {} as any;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
// Create a new object cause react native will know the theme has changed
|
|
100
|
+
const updatedDark = {
|
|
101
|
+
...dark,
|
|
102
|
+
color: updatedColors,
|
|
103
|
+
spacing: updatedSpacing
|
|
104
|
+
};
|
|
105
|
+
const mergedTheme = deepMerge(parentProviderTheme.dark, updatedDark);
|
|
97
106
|
const defaultDarkThemeWithOverridesApplied = isColorAvailable ? darkThemeMaker(
|
|
98
107
|
mergedTheme.spacing as CometChatTheme["spacing"],
|
|
99
108
|
mergedTheme.color as CometChatTheme["color"],
|
|
100
109
|
mergedTheme.typography as CometChatTheme["typography"]
|
|
101
110
|
) : mergedTheme;
|
|
102
|
-
return deepMerge(defaultDarkThemeWithOverridesApplied,
|
|
111
|
+
return deepMerge(defaultDarkThemeWithOverridesApplied, updatedDark);
|
|
103
112
|
}
|
|
104
113
|
return parentProviderTheme.dark;
|
|
105
114
|
}, [dark, parentProviderTheme.dark]);
|