stream-chat-react-native-core 4.2.0-beta.3 → 4.3.0-beta.1
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/lib/commonjs/components/Attachment/Giphy.js +71 -31
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +28 -13
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +6 -0
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +24 -21
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +50 -173
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/InputEditingStateHeader.js +138 -0
- package/lib/commonjs/components/MessageInput/components/InputEditingStateHeader.js.map +1 -0
- package/lib/commonjs/components/MessageInput/components/InputGiphySearch.js +179 -0
- package/lib/commonjs/components/MessageInput/components/InputGiphySearch.js.map +1 -0
- package/lib/commonjs/components/MessageInput/components/InputReplyStateHeader.js +138 -0
- package/lib/commonjs/components/MessageInput/components/InputReplyStateHeader.js.map +1 -0
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +6 -0
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +15 -12
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +8 -2
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Giphy.js +71 -31
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +28 -13
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +6 -0
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +24 -21
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +50 -173
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/components/InputEditingStateHeader.js +138 -0
- package/lib/module/components/MessageInput/components/InputEditingStateHeader.js.map +1 -0
- package/lib/module/components/MessageInput/components/InputGiphySearch.js +179 -0
- package/lib/module/components/MessageInput/components/InputGiphySearch.js.map +1 -0
- package/lib/module/components/MessageInput/components/InputReplyStateHeader.js +138 -0
- package/lib/module/components/MessageInput/components/InputReplyStateHeader.js.map +1 -0
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +6 -0
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +15 -12
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +8 -2
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Giphy.d.ts +5 -3
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +2 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
- package/lib/typescript/components/MessageInput/components/InputEditingStateHeader.d.ts +10 -0
- package/lib/typescript/components/MessageInput/components/InputGiphySearch.d.ts +10 -0
- package/lib/typescript/components/MessageInput/components/InputReplyStateHeader.d.ts +10 -0
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +7 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts +5 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +8 -2
- package/package.json +1 -1
- package/src/components/Attachment/Giphy.tsx +58 -16
- package/src/components/Channel/Channel.tsx +9 -0
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +6 -0
- package/src/components/ImageGallery/ImageGallery.tsx +11 -6
- package/src/components/Message/MessageSimple/MessageContent.tsx +1 -1
- package/src/components/MessageInput/MessageInput.tsx +28 -109
- package/src/components/MessageInput/__tests__/__snapshots__/MessageInput.test.js.snap +0 -2
- package/src/components/MessageInput/components/InputEditingStateHeader.tsx +102 -0
- package/src/components/MessageInput/components/InputGiphySearch.tsx +129 -0
- package/src/components/MessageInput/components/InputReplyStateHeader.tsx +102 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +9 -0
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +6 -0
- package/src/contexts/overlayContext/OverlayContext.tsx +5 -0
- package/src/contexts/overlayContext/OverlayProvider.tsx +2 -0
- package/src/contexts/themeContext/utils/theme.ts +16 -4
- package/src/version.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DefaultStreamChatGenerics } from '../../../types/types';
|
|
2
2
|
import type { ThreadContextValue } from '../../threadContext/ThreadContext';
|
|
3
3
|
import type { MessageInputContextValue } from '../MessageInputContext';
|
|
4
|
-
export declare const useCreateMessageInputContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ additionalTextInputProps, appendText, asyncIds, asyncUploads, AttachButton, autoCompleteSuggestionsLimit, clearEditingState, clearQuotedMessageState, closeAttachmentPicker, CommandsButton, compressImageQuality, cooldownEndsAt, CooldownTimer, doDocUploadRequest, doImageUploadRequest, editing, editMessage, FileUploadPreview, fileUploads, giphyActive, hasCommands, hasFilePicker, hasImagePicker, ImageUploadPreview, imageUploads, initialValue, Input, inputBoxRef, InputButtons, isValidMessage, maxMessageLength, maxNumberOfFiles, mentionAllAppUsersEnabled, mentionAllAppUsersQuery, mentionedUsers, MoreOptionsButton, numberOfLines, numberOfUploads, onChange, onChangeText, onSelectItem, openAttachmentPicker, openCommandsPicker, openFilePicker, openMentionsPicker, pickFile, quotedMessage, removeFile, removeImage, resetInput, selectedPicker, SendButton, sendImageAsync, sending, sendMessage, sendMessageAsync, SendMessageDisallowedIndicator, sendThreadMessageInChannel, setAsyncIds, setAsyncUploads, setFileUploads, setGiphyActive, setImageUploads, setInputBoxRef, setInputRef, setMentionedUsers, setNumberOfUploads, setQuotedMessageState, setSendThreadMessageInChannel, setShowMoreOptions, setText, showMoreOptions, ShowThreadMessageInChannelButton, text, thread, toggleAttachmentPicker, triggerSettings, updateMessage, uploadFile, uploadImage, uploadNewFile, uploadNewImage, UploadProgressIndicator, }: import("../MessageInputContext").LocalMessageInputContext<StreamChatGenerics> & Omit<import("../MessageInputContext").InputMessageInputContextValue<StreamChatGenerics>, "sendMessage"> & Pick<ThreadContextValue<StreamChatGenerics>, "thread">) => MessageInputContextValue<StreamChatGenerics>;
|
|
4
|
+
export declare const useCreateMessageInputContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ additionalTextInputProps, appendText, asyncIds, asyncUploads, AttachButton, autoCompleteSuggestionsLimit, clearEditingState, clearQuotedMessageState, closeAttachmentPicker, CommandsButton, compressImageQuality, cooldownEndsAt, CooldownTimer, doDocUploadRequest, doImageUploadRequest, editing, editMessage, FileUploadPreview, fileUploads, giphyActive, hasCommands, hasFilePicker, hasImagePicker, ImageUploadPreview, imageUploads, initialValue, Input, inputBoxRef, InputButtons, InputEditingStateHeader, InputGiphySearch, InputReplyStateHeader, isValidMessage, maxMessageLength, maxNumberOfFiles, mentionAllAppUsersEnabled, mentionAllAppUsersQuery, mentionedUsers, MoreOptionsButton, numberOfLines, numberOfUploads, onChange, onChangeText, onSelectItem, openAttachmentPicker, openCommandsPicker, openFilePicker, openMentionsPicker, pickFile, quotedMessage, removeFile, removeImage, resetInput, selectedPicker, SendButton, sendImageAsync, sending, sendMessage, sendMessageAsync, SendMessageDisallowedIndicator, sendThreadMessageInChannel, setAsyncIds, setAsyncUploads, setFileUploads, setGiphyActive, setImageUploads, setInputBoxRef, setInputRef, setMentionedUsers, setNumberOfUploads, setQuotedMessageState, setSendThreadMessageInChannel, setShowMoreOptions, setText, showMoreOptions, ShowThreadMessageInChannelButton, text, thread, toggleAttachmentPicker, triggerSettings, updateMessage, uploadFile, uploadImage, uploadNewFile, uploadNewImage, UploadProgressIndicator, }: import("../MessageInputContext").LocalMessageInputContext<StreamChatGenerics> & Omit<import("../MessageInputContext").InputMessageInputContextValue<StreamChatGenerics>, "sendMessage"> & Pick<ThreadContextValue<StreamChatGenerics>, "thread">) => MessageInputContextValue<StreamChatGenerics>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
3
|
+
import type { Attachment } from 'stream-chat';
|
|
3
4
|
import type { AttachmentPickerProps } from '../../components/AttachmentPicker/AttachmentPicker';
|
|
4
5
|
import type { ImageGalleryCustomComponents } from '../../components/ImageGallery/ImageGallery';
|
|
5
6
|
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
|
|
@@ -18,6 +19,10 @@ export declare type OverlayContextValue = {
|
|
|
18
19
|
};
|
|
19
20
|
export declare const OverlayContext: React.Context<OverlayContextValue>;
|
|
20
21
|
export declare type OverlayProviderProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<AttachmentPickerProps> & Partial<Pick<AttachmentPickerContextValue, 'attachmentPickerBottomSheetHeight' | 'attachmentSelectionBarHeight' | 'bottomInset' | 'CameraSelectorIcon' | 'FileSelectorIcon' | 'ImageSelectorIcon' | 'topInset'>> & ImageGalleryCustomComponents<StreamChatGenerics> & Partial<Pick<MessageOverlayContextValue<StreamChatGenerics>, 'MessageActionList' | 'MessageActionListItem' | 'OverlayReactionList' | 'OverlayReactions' | 'OverlayReactionsAvatar'>> & Pick<OverlayContextValue, 'translucentStatusBar'> & {
|
|
22
|
+
/**
|
|
23
|
+
* The giphy version to render - check the keys of the [Image Object](https://developers.giphy.com/docs/api/schema#image-object) for possible values. Uses 'fixed_height' by default
|
|
24
|
+
* */
|
|
25
|
+
giphyVersion: keyof NonNullable<Attachment['giphy']>;
|
|
21
26
|
closePicker?: (ref: React.RefObject<BottomSheetMethods>) => void;
|
|
22
27
|
error?: boolean | Error;
|
|
23
28
|
/** https://github.com/GetStream/stream-chat-react-native/wiki/Internationalization-(i18n) */
|
|
@@ -229,6 +229,10 @@ export declare type Theme = {
|
|
|
229
229
|
editingBoxContainer: ViewStyle;
|
|
230
230
|
editingBoxHeader: ViewStyle;
|
|
231
231
|
editingBoxHeaderTitle: TextStyle;
|
|
232
|
+
editingStateHeader: {
|
|
233
|
+
editingBoxHeader: ViewStyle;
|
|
234
|
+
editingBoxHeaderTitle: TextStyle;
|
|
235
|
+
};
|
|
232
236
|
fileUploadPreview: {
|
|
233
237
|
dismiss: ViewStyle;
|
|
234
238
|
fileContainer: ViewStyle;
|
|
@@ -238,8 +242,10 @@ export declare type Theme = {
|
|
|
238
242
|
fileTextContainer: ViewStyle;
|
|
239
243
|
flatList: ViewStyle;
|
|
240
244
|
};
|
|
241
|
-
|
|
242
|
-
|
|
245
|
+
giphyCommandInput: {
|
|
246
|
+
giphyContainer: ViewStyle;
|
|
247
|
+
giphyText: TextStyle;
|
|
248
|
+
};
|
|
243
249
|
imageUploadPreview: {
|
|
244
250
|
dismiss: ViewStyle;
|
|
245
251
|
flatList: ViewStyle;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0-beta.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -3,6 +3,10 @@ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import type { Attachment } from 'stream-chat';
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
ImageGalleryContextValue,
|
|
8
|
+
useImageGalleryContext,
|
|
9
|
+
} from '../../contexts/imageGalleryContext/ImageGalleryContext';
|
|
6
10
|
import {
|
|
7
11
|
MessageContextValue,
|
|
8
12
|
useMessageContext,
|
|
@@ -11,6 +15,10 @@ import {
|
|
|
11
15
|
MessagesContextValue,
|
|
12
16
|
useMessagesContext,
|
|
13
17
|
} from '../../contexts/messagesContext/MessagesContext';
|
|
18
|
+
import {
|
|
19
|
+
OverlayContextValue,
|
|
20
|
+
useOverlayContext,
|
|
21
|
+
} from '../../contexts/overlayContext/OverlayContext';
|
|
14
22
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
15
23
|
import { GiphyIcon } from '../../icons';
|
|
16
24
|
import { Lightning } from '../../icons/Lightning';
|
|
@@ -107,13 +115,20 @@ const styles = StyleSheet.create({
|
|
|
107
115
|
|
|
108
116
|
export type GiphyPropsWithContext<
|
|
109
117
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
110
|
-
> = Pick<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
> = Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setImage' | 'setImages'> &
|
|
119
|
+
Pick<
|
|
120
|
+
MessageContextValue<StreamChatGenerics>,
|
|
121
|
+
| 'handleAction'
|
|
122
|
+
| 'isMyMessage'
|
|
123
|
+
| 'message'
|
|
124
|
+
| 'onLongPress'
|
|
125
|
+
| 'onPress'
|
|
126
|
+
| 'onPressIn'
|
|
127
|
+
| 'preventPress'
|
|
128
|
+
> &
|
|
114
129
|
Pick<MessagesContextValue<StreamChatGenerics>, 'giphyVersion' | 'additionalTouchableProps'> & {
|
|
115
130
|
attachment: Attachment<StreamChatGenerics>;
|
|
116
|
-
}
|
|
131
|
+
} & Pick<OverlayContextValue, 'setOverlay'>;
|
|
117
132
|
|
|
118
133
|
const GiphyWithContext = <
|
|
119
134
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -123,11 +138,17 @@ const GiphyWithContext = <
|
|
|
123
138
|
const {
|
|
124
139
|
additionalTouchableProps,
|
|
125
140
|
attachment,
|
|
141
|
+
giphyVersion,
|
|
126
142
|
handleAction,
|
|
143
|
+
isMyMessage,
|
|
144
|
+
message,
|
|
127
145
|
onLongPress,
|
|
128
146
|
onPress,
|
|
129
147
|
onPressIn,
|
|
130
148
|
preventPress,
|
|
149
|
+
setImage,
|
|
150
|
+
setImages,
|
|
151
|
+
setOverlay,
|
|
131
152
|
} = props;
|
|
132
153
|
|
|
133
154
|
const { actions, giphy: giphyData, image_url, thumb_url, title, type } = attachment;
|
|
@@ -158,8 +179,14 @@ const GiphyWithContext = <
|
|
|
158
179
|
let uri = image_url || thumb_url;
|
|
159
180
|
const giphyDimensions: { height?: number; width?: number } = {};
|
|
160
181
|
|
|
182
|
+
const defaultOnPress = () => {
|
|
183
|
+
setImages([message]);
|
|
184
|
+
setImage({ messageId: message.id, url: uri });
|
|
185
|
+
setOverlay('gallery');
|
|
186
|
+
};
|
|
187
|
+
|
|
161
188
|
if (type === 'giphy' && giphyData) {
|
|
162
|
-
const giphyVersionInfo = giphyData[
|
|
189
|
+
const giphyVersionInfo = giphyData[giphyVersion];
|
|
163
190
|
uri = giphyVersionInfo.url;
|
|
164
191
|
giphyDimensions.height = parseFloat(giphyVersionInfo.height);
|
|
165
192
|
giphyDimensions.width = parseFloat(giphyVersionInfo.width);
|
|
@@ -246,6 +273,7 @@ const GiphyWithContext = <
|
|
|
246
273
|
onPress={(event) => {
|
|
247
274
|
if (onPress) {
|
|
248
275
|
onPress({
|
|
276
|
+
defaultHandler: defaultOnPress,
|
|
249
277
|
emitter: 'giphy',
|
|
250
278
|
event,
|
|
251
279
|
});
|
|
@@ -262,7 +290,13 @@ const GiphyWithContext = <
|
|
|
262
290
|
testID='giphy-attachment'
|
|
263
291
|
{...additionalTouchableProps}
|
|
264
292
|
>
|
|
265
|
-
<View
|
|
293
|
+
<View
|
|
294
|
+
style={[
|
|
295
|
+
styles.container,
|
|
296
|
+
{ backgroundColor: isMyMessage ? grey_gainsboro : white },
|
|
297
|
+
container,
|
|
298
|
+
]}
|
|
299
|
+
>
|
|
266
300
|
<Image
|
|
267
301
|
resizeMode='contain'
|
|
268
302
|
source={{ uri: makeImageCompatibleUrl(uri) }}
|
|
@@ -295,10 +329,12 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
295
329
|
const {
|
|
296
330
|
attachment: { actions: prevActions, image_url: prevImageUrl, thumb_url: prevThumbUrl },
|
|
297
331
|
giphyVersion: prevGiphyVersion,
|
|
332
|
+
isMyMessage: prevIsMyMessage,
|
|
298
333
|
} = prevProps;
|
|
299
334
|
const {
|
|
300
335
|
attachment: { actions: nextActions, image_url: nextImageUrl, thumb_url: nextThumbUrl },
|
|
301
336
|
giphyVersion: nextGiphyVersion,
|
|
337
|
+
isMyMessage: nextIsMyMessage,
|
|
302
338
|
} = nextProps;
|
|
303
339
|
|
|
304
340
|
const imageUrlEqual = prevImageUrl === nextImageUrl;
|
|
@@ -307,9 +343,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
307
343
|
const thumbUrlEqual = prevThumbUrl === nextThumbUrl;
|
|
308
344
|
if (!thumbUrlEqual) return false;
|
|
309
345
|
|
|
310
|
-
const giphyVersionEqual = prevGiphyVersion === nextGiphyVersion;
|
|
311
|
-
if (!giphyVersionEqual) return false;
|
|
312
|
-
|
|
313
346
|
const actionsEqual =
|
|
314
347
|
Array.isArray(prevActions) === Array.isArray(nextActions) &&
|
|
315
348
|
((Array.isArray(prevActions) &&
|
|
@@ -318,6 +351,12 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
318
351
|
prevActions === nextActions);
|
|
319
352
|
if (!actionsEqual) return false;
|
|
320
353
|
|
|
354
|
+
const giphyVersionEqual = prevGiphyVersion === nextGiphyVersion;
|
|
355
|
+
if (!giphyVersionEqual) return false;
|
|
356
|
+
|
|
357
|
+
const isMyMessageEqual = prevIsMyMessage === nextIsMyMessage;
|
|
358
|
+
if (!isMyMessageEqual) return false;
|
|
359
|
+
|
|
321
360
|
return true;
|
|
322
361
|
};
|
|
323
362
|
|
|
@@ -325,10 +364,7 @@ const MemoizedGiphy = React.memo(GiphyWithContext, areEqual) as typeof GiphyWith
|
|
|
325
364
|
|
|
326
365
|
export type GiphyProps<
|
|
327
366
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
328
|
-
> = Partial<
|
|
329
|
-
Pick<MessageContextValue<StreamChatGenerics>, 'isMyMessage' | 'onLongPress' | 'onPressIn'> &
|
|
330
|
-
Pick<MessagesContextValue<StreamChatGenerics>, 'giphyVersion' | 'additionalTouchableProps'>
|
|
331
|
-
> & {
|
|
367
|
+
> = Partial<GiphyPropsWithContext<StreamChatGenerics>> & {
|
|
332
368
|
attachment: Attachment<StreamChatGenerics>;
|
|
333
369
|
};
|
|
334
370
|
|
|
@@ -340,20 +376,26 @@ export const Giphy = <
|
|
|
340
376
|
>(
|
|
341
377
|
props: GiphyProps<StreamChatGenerics>,
|
|
342
378
|
) => {
|
|
343
|
-
const { handleAction, onLongPress, onPress, onPressIn, preventPress } =
|
|
379
|
+
const { handleAction, isMyMessage, message, onLongPress, onPress, onPressIn, preventPress } =
|
|
344
380
|
useMessageContext<StreamChatGenerics>();
|
|
345
381
|
const { additionalTouchableProps, giphyVersion } = useMessagesContext<StreamChatGenerics>();
|
|
346
|
-
|
|
382
|
+
const { setImage, setImages } = useImageGalleryContext<StreamChatGenerics>();
|
|
383
|
+
const { setOverlay } = useOverlayContext();
|
|
347
384
|
return (
|
|
348
385
|
<MemoizedGiphy
|
|
349
386
|
{...{
|
|
350
387
|
additionalTouchableProps,
|
|
351
388
|
giphyVersion,
|
|
352
389
|
handleAction,
|
|
390
|
+
isMyMessage,
|
|
391
|
+
message,
|
|
353
392
|
onLongPress,
|
|
354
393
|
onPress,
|
|
355
394
|
onPressIn,
|
|
356
395
|
preventPress,
|
|
396
|
+
setImage,
|
|
397
|
+
setImages,
|
|
398
|
+
setOverlay,
|
|
357
399
|
}}
|
|
358
400
|
{...props}
|
|
359
401
|
/>
|
|
@@ -105,6 +105,9 @@ import { MessageStatus as MessageStatusDefault } from '../Message/MessageSimple/
|
|
|
105
105
|
import { ReactionList as ReactionListDefault } from '../Message/MessageSimple/ReactionList';
|
|
106
106
|
import { AttachButton as AttachButtonDefault } from '../MessageInput/AttachButton';
|
|
107
107
|
import { CommandsButton as CommandsButtonDefault } from '../MessageInput/CommandsButton';
|
|
108
|
+
import { InputEditingStateHeader as InputEditingStateHeaderDefault } from '../MessageInput/components/InputEditingStateHeader';
|
|
109
|
+
import { InputGiphySearch as InputGiphyCommandInputDefault } from '../MessageInput/components/InputGiphySearch';
|
|
110
|
+
import { InputReplyStateHeader as InputReplyStateHeaderDefault } from '../MessageInput/components/InputReplyStateHeader';
|
|
108
111
|
import { CooldownTimer as CooldownTimerDefault } from '../MessageInput/CooldownTimer';
|
|
109
112
|
import { FileUploadPreview as FileUploadPreviewDefault } from '../MessageInput/FileUploadPreview';
|
|
110
113
|
import { ImageUploadPreview as ImageUploadPreviewDefault } from '../MessageInput/ImageUploadPreview';
|
|
@@ -452,6 +455,9 @@ const ChannelWithContext = <
|
|
|
452
455
|
InlineUnreadIndicator = InlineUnreadIndicatorDefault,
|
|
453
456
|
Input,
|
|
454
457
|
InputButtons = InputButtonsDefault,
|
|
458
|
+
InputEditingStateHeader = InputEditingStateHeaderDefault,
|
|
459
|
+
InputGiphySearch = InputGiphyCommandInputDefault,
|
|
460
|
+
InputReplyStateHeader = InputReplyStateHeaderDefault,
|
|
455
461
|
keyboardBehavior,
|
|
456
462
|
KeyboardCompatibleView = KeyboardCompatibleViewDefault,
|
|
457
463
|
keyboardVerticalOffset,
|
|
@@ -1621,6 +1627,9 @@ const ChannelWithContext = <
|
|
|
1621
1627
|
initialValue,
|
|
1622
1628
|
Input,
|
|
1623
1629
|
InputButtons,
|
|
1630
|
+
InputEditingStateHeader,
|
|
1631
|
+
InputGiphySearch,
|
|
1632
|
+
InputReplyStateHeader,
|
|
1624
1633
|
maxMessageLength: maxMessageLengthProp ?? clientChannelConfig?.max_message_length ?? undefined,
|
|
1625
1634
|
maxNumberOfFiles,
|
|
1626
1635
|
mentionAllAppUsersEnabled,
|
|
@@ -28,6 +28,9 @@ export const useCreateInputMessageInputContext = <
|
|
|
28
28
|
initialValue,
|
|
29
29
|
Input,
|
|
30
30
|
InputButtons,
|
|
31
|
+
InputEditingStateHeader,
|
|
32
|
+
InputGiphySearch,
|
|
33
|
+
InputReplyStateHeader,
|
|
31
34
|
maxMessageLength,
|
|
32
35
|
maxNumberOfFiles,
|
|
33
36
|
mentionAllAppUsersEnabled,
|
|
@@ -80,6 +83,9 @@ export const useCreateInputMessageInputContext = <
|
|
|
80
83
|
initialValue,
|
|
81
84
|
Input,
|
|
82
85
|
InputButtons,
|
|
86
|
+
InputEditingStateHeader,
|
|
87
|
+
InputGiphySearch,
|
|
88
|
+
InputReplyStateHeader,
|
|
83
89
|
maxMessageLength,
|
|
84
90
|
maxNumberOfFiles,
|
|
85
91
|
mentionAllAppUsersEnabled,
|
|
@@ -53,7 +53,10 @@ import {
|
|
|
53
53
|
} from './components/ImageGridHandle';
|
|
54
54
|
|
|
55
55
|
import { useImageGalleryContext } from '../../contexts/imageGalleryContext/ImageGalleryContext';
|
|
56
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
OverlayProviderProps,
|
|
58
|
+
useOverlayContext,
|
|
59
|
+
} from '../../contexts/overlayContext/OverlayContext';
|
|
57
60
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
58
61
|
import { triggerHaptic } from '../../native';
|
|
59
62
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
@@ -130,7 +133,7 @@ type Props<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamC
|
|
|
130
133
|
*/
|
|
131
134
|
imageGalleryGridSnapPoints?: [string | number, string | number];
|
|
132
135
|
numberOfImageGalleryGridColumns?: number;
|
|
133
|
-
}
|
|
136
|
+
} & Pick<OverlayProviderProps<StreamChatGenerics>, 'giphyVersion'>;
|
|
134
137
|
|
|
135
138
|
export const ImageGallery = <
|
|
136
139
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -138,6 +141,7 @@ export const ImageGallery = <
|
|
|
138
141
|
props: Props<StreamChatGenerics>,
|
|
139
142
|
) => {
|
|
140
143
|
const {
|
|
144
|
+
giphyVersion,
|
|
141
145
|
imageGalleryCustomComponents,
|
|
142
146
|
imageGalleryGridHandleHeight,
|
|
143
147
|
imageGalleryGridSnapPoints,
|
|
@@ -308,10 +312,11 @@ export const ImageGallery = <
|
|
|
308
312
|
const attachmentImages =
|
|
309
313
|
cur.attachments?.filter(
|
|
310
314
|
(attachment) =>
|
|
311
|
-
attachment.type === '
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
+
(attachment.type === 'giphy' && attachment.giphy?.[giphyVersion]?.url) ||
|
|
316
|
+
(attachment.type === 'image' &&
|
|
317
|
+
!attachment.title_link &&
|
|
318
|
+
!attachment.og_scrape_url &&
|
|
319
|
+
getUrlOfImageAttachment(attachment)),
|
|
315
320
|
) || [];
|
|
316
321
|
|
|
317
322
|
const attachmentPhotos = attachmentImages.map((a) => {
|
|
@@ -212,7 +212,7 @@ const MessageContentWithContext = <
|
|
|
212
212
|
backgroundColor = transparent;
|
|
213
213
|
} else if (otherAttachments.length) {
|
|
214
214
|
if (otherAttachments[0].type === 'giphy') {
|
|
215
|
-
backgroundColor = message.quoted_message
|
|
215
|
+
backgroundColor = message.quoted_message ? grey_gainsboro : transparent;
|
|
216
216
|
} else {
|
|
217
217
|
backgroundColor = blue_alice;
|
|
218
218
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { StyleSheet,
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import type { UserResponse } from 'stream-chat';
|
|
5
5
|
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
TranslationContextValue,
|
|
30
30
|
useTranslationContext,
|
|
31
31
|
} from '../../contexts/translationContext/TranslationContext';
|
|
32
|
-
import { CircleClose, CurveLineLeftUp, Edit, Lightning } from '../../icons';
|
|
33
32
|
|
|
34
33
|
import type { Asset } from '../../native';
|
|
35
34
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
@@ -44,6 +43,8 @@ const styles = StyleSheet.create({
|
|
|
44
43
|
autoCompleteInputContainer: {
|
|
45
44
|
alignItems: 'center',
|
|
46
45
|
flexDirection: 'row',
|
|
46
|
+
paddingLeft: 16,
|
|
47
|
+
paddingRight: 16,
|
|
47
48
|
},
|
|
48
49
|
composerContainer: {
|
|
49
50
|
alignItems: 'flex-end',
|
|
@@ -53,28 +54,6 @@ const styles = StyleSheet.create({
|
|
|
53
54
|
borderTopWidth: 1,
|
|
54
55
|
padding: 10,
|
|
55
56
|
},
|
|
56
|
-
editingBoxHeader: {
|
|
57
|
-
alignItems: 'center',
|
|
58
|
-
flexDirection: 'row',
|
|
59
|
-
justifyContent: 'space-between',
|
|
60
|
-
paddingBottom: 10,
|
|
61
|
-
},
|
|
62
|
-
editingBoxHeaderTitle: {
|
|
63
|
-
fontSize: 14,
|
|
64
|
-
fontWeight: 'bold',
|
|
65
|
-
},
|
|
66
|
-
giphyContainer: {
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
borderRadius: 12,
|
|
69
|
-
flexDirection: 'row',
|
|
70
|
-
height: 24,
|
|
71
|
-
marginRight: 8,
|
|
72
|
-
paddingHorizontal: 8,
|
|
73
|
-
},
|
|
74
|
-
giphyText: {
|
|
75
|
-
fontSize: 12,
|
|
76
|
-
fontWeight: 'bold',
|
|
77
|
-
},
|
|
78
57
|
inputBoxContainer: {
|
|
79
58
|
borderRadius: 20,
|
|
80
59
|
borderWidth: 1,
|
|
@@ -120,6 +99,9 @@ type MessageInputPropsWithContext<
|
|
|
120
99
|
| 'Input'
|
|
121
100
|
| 'inputBoxRef'
|
|
122
101
|
| 'InputButtons'
|
|
102
|
+
| 'InputEditingStateHeader'
|
|
103
|
+
| 'InputGiphySearch'
|
|
104
|
+
| 'InputReplyStateHeader'
|
|
123
105
|
| 'isValidMessage'
|
|
124
106
|
| 'maxNumberOfFiles'
|
|
125
107
|
| 'mentionedUsers'
|
|
@@ -160,8 +142,6 @@ const MessageInputWithContext = <
|
|
|
160
142
|
asyncIds,
|
|
161
143
|
asyncUploads,
|
|
162
144
|
AutoCompleteSuggestionList,
|
|
163
|
-
clearEditingState,
|
|
164
|
-
clearQuotedMessageState,
|
|
165
145
|
closeAttachmentPicker,
|
|
166
146
|
cooldownEndsAt,
|
|
167
147
|
CooldownTimer,
|
|
@@ -175,6 +155,9 @@ const MessageInputWithContext = <
|
|
|
175
155
|
Input,
|
|
176
156
|
inputBoxRef,
|
|
177
157
|
InputButtons,
|
|
158
|
+
InputEditingStateHeader,
|
|
159
|
+
InputGiphySearch,
|
|
160
|
+
InputReplyStateHeader,
|
|
178
161
|
isValidMessage,
|
|
179
162
|
maxNumberOfFiles,
|
|
180
163
|
members,
|
|
@@ -187,11 +170,8 @@ const MessageInputWithContext = <
|
|
|
187
170
|
SendButton,
|
|
188
171
|
sending,
|
|
189
172
|
sendMessageAsync,
|
|
190
|
-
setGiphyActive,
|
|
191
|
-
setShowMoreOptions,
|
|
192
173
|
ShowThreadMessageInChannelButton,
|
|
193
174
|
suggestions,
|
|
194
|
-
t,
|
|
195
175
|
thread,
|
|
196
176
|
threadList,
|
|
197
177
|
triggerType,
|
|
@@ -203,25 +183,12 @@ const MessageInputWithContext = <
|
|
|
203
183
|
|
|
204
184
|
const {
|
|
205
185
|
theme: {
|
|
206
|
-
colors: {
|
|
207
|
-
accent_blue,
|
|
208
|
-
black,
|
|
209
|
-
border,
|
|
210
|
-
grey,
|
|
211
|
-
grey_gainsboro,
|
|
212
|
-
grey_whisper,
|
|
213
|
-
white,
|
|
214
|
-
white_smoke,
|
|
215
|
-
},
|
|
186
|
+
colors: { border, grey_whisper, white, white_smoke },
|
|
216
187
|
messageInput: {
|
|
217
188
|
attachmentSelectionBar,
|
|
218
189
|
autoCompleteInputContainer,
|
|
219
190
|
composerContainer,
|
|
220
191
|
container,
|
|
221
|
-
editingBoxHeader,
|
|
222
|
-
editingBoxHeaderTitle,
|
|
223
|
-
giphyContainer,
|
|
224
|
-
giphyText,
|
|
225
192
|
inputBoxContainer,
|
|
226
193
|
optionsContainer,
|
|
227
194
|
replyContainer,
|
|
@@ -434,33 +401,8 @@ const MessageInputWithContext = <
|
|
|
434
401
|
}) => setHeight(newHeight)}
|
|
435
402
|
style={[styles.container, { backgroundColor: white, borderColor: border }, container]}
|
|
436
403
|
>
|
|
437
|
-
{
|
|
438
|
-
|
|
439
|
-
{editing ? (
|
|
440
|
-
<Edit pathFill={grey_gainsboro} />
|
|
441
|
-
) : (
|
|
442
|
-
<CurveLineLeftUp pathFill={grey_gainsboro} />
|
|
443
|
-
)}
|
|
444
|
-
<Text style={[styles.editingBoxHeaderTitle, { color: black }, editingBoxHeaderTitle]}>
|
|
445
|
-
{editing ? t('Editing Message') : t('Reply to Message')}
|
|
446
|
-
</Text>
|
|
447
|
-
<TouchableOpacity
|
|
448
|
-
disabled={disabled}
|
|
449
|
-
onPress={() => {
|
|
450
|
-
resetInput();
|
|
451
|
-
if (editing) {
|
|
452
|
-
clearEditingState();
|
|
453
|
-
}
|
|
454
|
-
if (quotedMessage) {
|
|
455
|
-
clearQuotedMessageState();
|
|
456
|
-
}
|
|
457
|
-
}}
|
|
458
|
-
testID='close-button'
|
|
459
|
-
>
|
|
460
|
-
<CircleClose pathFill={grey} />
|
|
461
|
-
</TouchableOpacity>
|
|
462
|
-
</View>
|
|
463
|
-
)}
|
|
404
|
+
{editing && <InputEditingStateHeader />}
|
|
405
|
+
{quotedMessage && <InputReplyStateHeader />}
|
|
464
406
|
<View style={[styles.composerContainer, composerContainer]}>
|
|
465
407
|
{Input ? (
|
|
466
408
|
<Input
|
|
@@ -500,45 +442,16 @@ const MessageInputWithContext = <
|
|
|
500
442
|
/>
|
|
501
443
|
) : null}
|
|
502
444
|
{fileUploads.length ? <FileUploadPreview /> : null}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
{giphyActive && (
|
|
514
|
-
<View
|
|
515
|
-
style={[
|
|
516
|
-
styles.giphyContainer,
|
|
517
|
-
{ backgroundColor: accent_blue },
|
|
518
|
-
giphyContainer,
|
|
519
|
-
]}
|
|
520
|
-
>
|
|
521
|
-
<Lightning height={16} pathFill={white} width={16} />
|
|
522
|
-
<Text style={[styles.giphyText, { color: white }, giphyText]}>GIPHY</Text>
|
|
523
|
-
</View>
|
|
524
|
-
)}
|
|
525
|
-
<AutoCompleteInput<StreamChatGenerics>
|
|
526
|
-
additionalTextInputProps={additionalTextInputProps}
|
|
527
|
-
cooldownActive={!!cooldownRemainingSeconds}
|
|
528
|
-
/>
|
|
529
|
-
{giphyActive && (
|
|
530
|
-
<TouchableOpacity
|
|
531
|
-
disabled={disabled}
|
|
532
|
-
onPress={() => {
|
|
533
|
-
setGiphyActive(false);
|
|
534
|
-
setShowMoreOptions(true);
|
|
535
|
-
}}
|
|
536
|
-
testID='close-button'
|
|
537
|
-
>
|
|
538
|
-
<CircleClose height={20} pathFill={grey} width={20} />
|
|
539
|
-
</TouchableOpacity>
|
|
540
|
-
)}
|
|
541
|
-
</View>
|
|
445
|
+
{giphyActive ? (
|
|
446
|
+
<InputGiphySearch />
|
|
447
|
+
) : (
|
|
448
|
+
<View style={[styles.autoCompleteInputContainer, autoCompleteInputContainer]}>
|
|
449
|
+
<AutoCompleteInput<StreamChatGenerics>
|
|
450
|
+
additionalTextInputProps={additionalTextInputProps}
|
|
451
|
+
cooldownActive={!!cooldownRemainingSeconds}
|
|
452
|
+
/>
|
|
453
|
+
</View>
|
|
454
|
+
)}
|
|
542
455
|
</View>
|
|
543
456
|
<View style={[styles.sendButtonContainer, sendButtonContainer]}>
|
|
544
457
|
{cooldownRemainingSeconds ? (
|
|
@@ -745,6 +658,9 @@ export const MessageInput = <
|
|
|
745
658
|
Input,
|
|
746
659
|
inputBoxRef,
|
|
747
660
|
InputButtons,
|
|
661
|
+
InputEditingStateHeader,
|
|
662
|
+
InputGiphySearch,
|
|
663
|
+
InputReplyStateHeader,
|
|
748
664
|
isValidMessage,
|
|
749
665
|
maxNumberOfFiles,
|
|
750
666
|
mentionedUsers,
|
|
@@ -805,6 +721,9 @@ export const MessageInput = <
|
|
|
805
721
|
Input,
|
|
806
722
|
inputBoxRef,
|
|
807
723
|
InputButtons,
|
|
724
|
+
InputEditingStateHeader,
|
|
725
|
+
InputGiphySearch,
|
|
726
|
+
InputReplyStateHeader,
|
|
808
727
|
isValidMessage,
|
|
809
728
|
maxNumberOfFiles,
|
|
810
729
|
members,
|