stream-chat-react-native-core 5.28.0-beta.4 → 5.28.0-beta.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/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +10 -43
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/{AttachmentSelectionBar.js → AttachmentPickerSelectionBar.js} +6 -6
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -0
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +29 -53
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +2 -6
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +6 -3
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/index.js +4 -4
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js +1 -2
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +18 -9
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/hooks/index.js +11 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useScreenDimensions.js +47 -0
- package/lib/commonjs/hooks/useScreenDimensions.js.map +1 -0
- package/lib/commonjs/i18n/es.json +12 -12
- package/lib/commonjs/i18n/fr.json +12 -12
- package/lib/commonjs/i18n/he.json +12 -12
- package/lib/commonjs/i18n/hi.json +12 -12
- package/lib/commonjs/i18n/it.json +12 -12
- package/lib/commonjs/i18n/ja.json +12 -12
- package/lib/commonjs/i18n/ko.json +12 -12
- package/lib/commonjs/i18n/nl.json +12 -12
- package/lib/commonjs/i18n/pt-BR.json +12 -12
- package/lib/commonjs/i18n/ru.json +12 -12
- package/lib/commonjs/i18n/tr.json +12 -12
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +10 -43
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/{AttachmentSelectionBar.js → AttachmentPickerSelectionBar.js} +6 -6
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -0
- package/lib/module/components/ImageGallery/ImageGallery.js +29 -53
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +2 -6
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +6 -3
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/index.js +4 -4
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js +1 -2
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +18 -9
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/hooks/index.js +11 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useScreenDimensions.js +47 -0
- package/lib/module/hooks/useScreenDimensions.js.map +1 -0
- package/lib/module/i18n/es.json +12 -12
- package/lib/module/i18n/fr.json +12 -12
- package/lib/module/i18n/he.json +12 -12
- package/lib/module/i18n/hi.json +12 -12
- package/lib/module/i18n/it.json +12 -12
- package/lib/module/i18n/ja.json +12 -12
- package/lib/module/i18n/ko.json +12 -12
- package/lib/module/i18n/nl.json +12 -12
- package/lib/module/i18n/pt-BR.json +12 -12
- package/lib/module/i18n/ru.json +12 -12
- package/lib/module/i18n/tr.json +12 -12
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts +30 -12
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerSelectionBar.d.ts +3 -0
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerSelectionBar.d.ts.map +1 -0
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts.map +1 -1
- package/lib/typescript/components/ImageGallery/components/ImageGalleryHeader.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +2 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts +32 -3
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts.map +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts +2 -3
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts.map +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayProvider.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useScreenDimensions.d.ts +12 -0
- package/lib/typescript/hooks/useScreenDimensions.d.ts.map +1 -0
- package/lib/typescript/i18n/es.json +12 -12
- package/lib/typescript/i18n/fr.json +12 -12
- package/lib/typescript/i18n/he.json +12 -12
- package/lib/typescript/i18n/hi.json +12 -12
- package/lib/typescript/i18n/it.json +12 -12
- package/lib/typescript/i18n/ja.json +12 -12
- package/lib/typescript/i18n/ko.json +12 -12
- package/lib/typescript/i18n/nl.json +12 -12
- package/lib/typescript/i18n/pt-BR.json +12 -12
- package/lib/typescript/i18n/ru.json +12 -12
- package/lib/typescript/i18n/tr.json +12 -12
- package/package.json +1 -1
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +21 -69
- package/src/components/AttachmentPicker/components/{AttachmentSelectionBar.tsx → AttachmentPickerSelectionBar.tsx} +2 -2
- package/src/components/ImageGallery/ImageGallery.tsx +31 -79
- package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +3 -19
- package/src/components/MessageInput/MessageInput.tsx +11 -7
- package/src/components/MessageInput/__tests__/MessageInput.test.js +2 -0
- package/src/components/index.ts +1 -1
- package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +34 -10
- package/src/contexts/overlayContext/OverlayContext.tsx +5 -4
- package/src/contexts/overlayContext/OverlayProvider.tsx +10 -7
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useScreenDimensions.ts +41 -0
- package/src/i18n/es.json +12 -12
- package/src/i18n/fr.json +12 -12
- package/src/i18n/he.json +12 -12
- package/src/i18n/hi.json +12 -12
- package/src/i18n/it.json +12 -12
- package/src/i18n/ja.json +12 -12
- package/src/i18n/ko.json +12 -12
- package/src/i18n/nl.json +12 -12
- package/src/i18n/pt-BR.json +12 -12
- package/src/i18n/ru.json +12 -12
- package/src/i18n/tr.json +12 -12
- package/src/version.json +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentSelectionBar.js.map +0 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentSelectionBar.js.map +0 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentSelectionBar.d.ts +0 -3
- package/lib/typescript/components/AttachmentPicker/components/AttachmentSelectionBar.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"1 Reply": "",
|
|
3
|
-
"1 Thread Reply": "
|
|
3
|
+
"1 Thread Reply": "",
|
|
4
4
|
"Allow access to your Gallery": "",
|
|
5
5
|
"Allow camera access in device settings": "",
|
|
6
6
|
"Also send to channel": "",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"Editing Message": "Mesaj Düzenleniyor",
|
|
20
20
|
"Emoji matching": "",
|
|
21
21
|
"Empty message...": "",
|
|
22
|
-
"Error loading": "",
|
|
23
|
-
"Error loading channel list...": "",
|
|
24
|
-
"Error loading messages for this channel...": "",
|
|
22
|
+
"Error loading": "Yükleme hatası",
|
|
23
|
+
"Error loading channel list...": "Kanal listesi yüklenirken hata oluştu...",
|
|
24
|
+
"Error loading messages for this channel...": "Bu kanal için mesajlar yüklenirken hata oluştu...",
|
|
25
25
|
"Error while loading, please reload/refresh": "",
|
|
26
|
-
"File type not supported": "",
|
|
26
|
+
"File type not supported": "Dosya türü desteklenmiyor",
|
|
27
27
|
"Flag": "",
|
|
28
28
|
"Flag Message": "",
|
|
29
29
|
"Flag action failed either due to a network issue or the message is already flagged": "",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"Message deleted": "Mesaj silindi",
|
|
40
40
|
"Message flagged": "",
|
|
41
41
|
"Mute User": "",
|
|
42
|
-
"Not supported": "",
|
|
42
|
+
"Not supported": "Desteklenmiyor",
|
|
43
43
|
"Nothing yet...": "",
|
|
44
44
|
"Ok": "",
|
|
45
45
|
"Only visible to you": "",
|
|
46
46
|
"Open Settings": "",
|
|
47
|
-
"Photo": "
|
|
47
|
+
"Photo": "",
|
|
48
48
|
"Photos and Videos": "",
|
|
49
49
|
"Pin to Conversation": "",
|
|
50
50
|
"Pinned by": "",
|
|
51
51
|
"Please enable access to your photos and videos so you can share them.": "",
|
|
52
52
|
"Please select a channel first": "",
|
|
53
|
-
"Reconnecting...": "
|
|
53
|
+
"Reconnecting...": "",
|
|
54
54
|
"Reply": "",
|
|
55
55
|
"Reply to Message": "Mesajı Yanıtla",
|
|
56
56
|
"Resend": "",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"Unknown User": "",
|
|
67
67
|
"Unmute User": "",
|
|
68
68
|
"Unpin from Conversation": "",
|
|
69
|
-
"Unread Messages": "
|
|
70
|
-
"Video": "
|
|
71
|
-
"You": "",
|
|
69
|
+
"Unread Messages": "",
|
|
70
|
+
"Video": "",
|
|
71
|
+
"You": "Sen",
|
|
72
72
|
"You can't send messages in this channel": "",
|
|
73
73
|
"{{ firstUser }} and {{ nonSelfUserLength }} more are typing": "",
|
|
74
74
|
"{{ index }} of {{ photoLength }}": "",
|
|
75
75
|
"{{ replyCount }} Replies": "",
|
|
76
|
-
"{{ replyCount }} Thread Replies": "
|
|
76
|
+
"{{ replyCount }} Thread Replies": "",
|
|
77
77
|
"{{ user }} is typing": "",
|
|
78
78
|
"🏙 Attachment...": ""
|
|
79
79
|
}
|
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": "5.28.0-beta.
|
|
4
|
+
"version": "5.28.0-beta.6",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { BackHandler,
|
|
2
|
+
import { BackHandler, Keyboard, Platform, StyleSheet } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import BottomSheet, { BottomSheetFlatList
|
|
4
|
+
import BottomSheet, { BottomSheetFlatList } from '@gorhom/bottom-sheet';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import duration from 'dayjs/plugin/duration';
|
|
7
7
|
|
|
@@ -9,9 +9,12 @@ import type { AttachmentPickerErrorProps } from './components/AttachmentPickerEr
|
|
|
9
9
|
|
|
10
10
|
import { renderAttachmentPickerItem } from './components/AttachmentPickerItem';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
AttachmentPickerContextValue,
|
|
14
|
+
useAttachmentPickerContext,
|
|
15
|
+
} from '../../contexts/attachmentPickerContext/AttachmentPickerContext';
|
|
13
16
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
14
|
-
import {
|
|
17
|
+
import { useScreenDimensions } from '../../hooks/useScreenDimensions';
|
|
15
18
|
import { getPhotos, oniOS14GalleryLibrarySelectionChange } from '../../native';
|
|
16
19
|
import type { Asset } from '../../types/types';
|
|
17
20
|
|
|
@@ -23,15 +26,13 @@ const styles = StyleSheet.create({
|
|
|
23
26
|
},
|
|
24
27
|
});
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
AttachmentPickerBottomSheetHandle: React.FC<BottomSheetHandleProps>;
|
|
29
|
+
export type AttachmentPickerProps = Pick<
|
|
30
|
+
AttachmentPickerContextValue,
|
|
31
|
+
| 'AttachmentPickerBottomSheetHandle'
|
|
32
|
+
| 'attachmentPickerBottomSheetHandleHeight'
|
|
33
|
+
| 'attachmentSelectionBarHeight'
|
|
34
|
+
| 'attachmentPickerBottomSheetHeight'
|
|
35
|
+
> & {
|
|
35
36
|
/**
|
|
36
37
|
* Custom UI component to render error component while opening attachment picker.
|
|
37
38
|
*
|
|
@@ -54,13 +55,10 @@ export type AttachmentPickerProps = {
|
|
|
54
55
|
* **Default** [ImageOverlaySelectedComponent](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/ImageOverlaySelectedComponent.tsx)
|
|
55
56
|
*/
|
|
56
57
|
ImageOverlaySelectedComponent: React.ComponentType;
|
|
57
|
-
attachmentPickerBottomSheetHandleHeight?: number;
|
|
58
|
-
attachmentPickerBottomSheetHeight?: number;
|
|
59
58
|
attachmentPickerErrorButtonText?: string;
|
|
60
59
|
attachmentPickerErrorText?: string;
|
|
61
60
|
numberOfAttachmentImagesToLoadPerCall?: number;
|
|
62
61
|
numberOfAttachmentPickerImageColumns?: number;
|
|
63
|
-
translucentStatusBar?: boolean;
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
export const AttachmentPicker = React.forwardRef(
|
|
@@ -77,7 +75,6 @@ export const AttachmentPicker = React.forwardRef(
|
|
|
77
75
|
ImageOverlaySelectedComponent,
|
|
78
76
|
numberOfAttachmentImagesToLoadPerCall,
|
|
79
77
|
numberOfAttachmentPickerImageColumns,
|
|
80
|
-
translucentStatusBar,
|
|
81
78
|
} = props;
|
|
82
79
|
|
|
83
80
|
const {
|
|
@@ -97,9 +94,9 @@ export const AttachmentPicker = React.forwardRef(
|
|
|
97
94
|
setSelectedPicker,
|
|
98
95
|
topInset,
|
|
99
96
|
} = useAttachmentPickerContext();
|
|
100
|
-
const { vh } =
|
|
97
|
+
const { vh: screenVh } = useScreenDimensions();
|
|
101
98
|
|
|
102
|
-
const
|
|
99
|
+
const fullScreenHeight = screenVh(100);
|
|
103
100
|
|
|
104
101
|
const [currentIndex, setCurrentIndex] = useState(-1);
|
|
105
102
|
const endCursorRef = useRef<string>();
|
|
@@ -239,63 +236,18 @@ export const AttachmentPicker = React.forwardRef(
|
|
|
239
236
|
setSelectedImages,
|
|
240
237
|
}));
|
|
241
238
|
|
|
242
|
-
const handleHeight = attachmentPickerBottomSheetHandleHeight
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* This is to handle issues with Android measurements coming back incorrect.
|
|
246
|
-
* If the StatusBar height is perfectly 1/2 of the difference between the two
|
|
247
|
-
* dimensions for screen and window, it is incorrect and we need to account for
|
|
248
|
-
* this. If you use a translucent header bar more adjustments are needed.
|
|
249
|
-
*/
|
|
250
|
-
const getAndroidBottomBarHeightAdjustment = (): number => {
|
|
251
|
-
if (Platform.OS === 'android') {
|
|
252
|
-
const statusBarHeight = StatusBar.currentHeight ?? 0;
|
|
253
|
-
const bottomBarHeight = fullScreenHeight - screenHeight - statusBarHeight;
|
|
254
|
-
if (bottomBarHeight === statusBarHeight) {
|
|
255
|
-
return translucentStatusBar ? 0 : statusBarHeight;
|
|
256
|
-
} else {
|
|
257
|
-
if (translucentStatusBar) {
|
|
258
|
-
if (bottomBarHeight > statusBarHeight) {
|
|
259
|
-
return -bottomBarHeight + statusBarHeight;
|
|
260
|
-
} else {
|
|
261
|
-
return bottomBarHeight > 0 ? -statusBarHeight : 0;
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
return bottomBarHeight > 0 ? 0 : statusBarHeight;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return 0;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const getInitialSnapPoint = (): number => {
|
|
272
|
-
if (attachmentPickerBottomSheetHeight !== undefined) {
|
|
273
|
-
return attachmentPickerBottomSheetHeight;
|
|
274
|
-
}
|
|
275
|
-
if (Platform.OS === 'android') {
|
|
276
|
-
return (
|
|
277
|
-
308 +
|
|
278
|
-
(fullScreenHeight - screenHeight + getAndroidBottomBarHeightAdjustment()) -
|
|
279
|
-
handleHeight
|
|
280
|
-
);
|
|
281
|
-
} else {
|
|
282
|
-
return 308 + (fullScreenHeight - screenHeight);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
239
|
+
const handleHeight = attachmentPickerBottomSheetHandleHeight;
|
|
285
240
|
|
|
286
|
-
const initialSnapPoint =
|
|
241
|
+
const initialSnapPoint = attachmentPickerBottomSheetHeight;
|
|
287
242
|
|
|
288
|
-
const finalSnapPoint =
|
|
289
|
-
Platform.OS === 'android'
|
|
290
|
-
? fullScreenHeight - topInset - handleHeight
|
|
291
|
-
: fullScreenHeight - topInset;
|
|
243
|
+
const finalSnapPoint = fullScreenHeight - topInset;
|
|
292
244
|
|
|
293
245
|
/**
|
|
294
246
|
* Snap points changing cause a rerender of the position,
|
|
295
247
|
* this is an issue if you are calling close on the bottom sheet.
|
|
296
248
|
*/
|
|
297
249
|
const snapPoints = useMemo(
|
|
298
|
-
() => [
|
|
250
|
+
() => [initialSnapPoint, finalSnapPoint],
|
|
299
251
|
[initialSnapPoint, finalSnapPoint],
|
|
300
252
|
);
|
|
301
253
|
|
|
@@ -334,7 +286,7 @@ export const AttachmentPicker = React.forwardRef(
|
|
|
334
286
|
</BottomSheet>
|
|
335
287
|
{selectedPicker === 'images' && photoError && (
|
|
336
288
|
<AttachmentPickerError
|
|
337
|
-
attachmentPickerBottomSheetHeight={
|
|
289
|
+
attachmentPickerBottomSheetHeight={attachmentPickerBottomSheetHeight}
|
|
338
290
|
attachmentPickerErrorButtonText={attachmentPickerErrorButtonText}
|
|
339
291
|
AttachmentPickerErrorImage={AttachmentPickerErrorImage}
|
|
340
292
|
attachmentPickerErrorText={attachmentPickerErrorText}
|
|
@@ -19,7 +19,7 @@ const styles = StyleSheet.create({
|
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
export const
|
|
22
|
+
export const AttachmentPickerSelectionBar = () => {
|
|
23
23
|
const {
|
|
24
24
|
attachmentSelectionBarHeight,
|
|
25
25
|
CameraSelectorIcon,
|
|
@@ -75,7 +75,7 @@ export const AttachmentSelectionBar = () => {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
return (
|
|
78
|
-
<View style={[styles.container, container, { height: attachmentSelectionBarHeight
|
|
78
|
+
<View style={[styles.container, container, { height: attachmentSelectionBarHeight }]}>
|
|
79
79
|
<TouchableOpacity
|
|
80
80
|
hitSlop={{ bottom: 15, top: 15 }}
|
|
81
81
|
onPress={() => setPicker('images')}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Dimensions,
|
|
4
|
-
Image,
|
|
5
|
-
ImageStyle,
|
|
6
|
-
Keyboard,
|
|
7
|
-
Platform,
|
|
8
|
-
StatusBar,
|
|
9
|
-
StyleSheet,
|
|
10
|
-
ViewStyle,
|
|
11
|
-
} from 'react-native';
|
|
2
|
+
import { Image, ImageStyle, Keyboard, Platform, StyleSheet, ViewStyle } from 'react-native';
|
|
12
3
|
|
|
13
4
|
import {
|
|
14
5
|
PanGestureHandler,
|
|
@@ -26,7 +17,7 @@ import Animated, {
|
|
|
26
17
|
withTiming,
|
|
27
18
|
} from 'react-native-reanimated';
|
|
28
19
|
|
|
29
|
-
import { BottomSheetModal, BottomSheetModalProvider
|
|
20
|
+
import { BottomSheetModal, BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
30
21
|
|
|
31
22
|
import type { UserResponse } from 'stream-chat';
|
|
32
23
|
|
|
@@ -63,7 +54,6 @@ import { getUrlOfImageAttachment } from '../../utils/getUrlOfImageAttachment';
|
|
|
63
54
|
import { getGiphyMimeType } from '../Attachment/utils/getGiphyMimeType';
|
|
64
55
|
|
|
65
56
|
const isAndroid = Platform.OS === 'android';
|
|
66
|
-
const fullScreenHeight = Dimensions.get('screen').height;
|
|
67
57
|
|
|
68
58
|
const MARGIN = 32;
|
|
69
59
|
|
|
@@ -132,29 +122,6 @@ type Props<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamC
|
|
|
132
122
|
| 'autoPlayVideo'
|
|
133
123
|
>;
|
|
134
124
|
|
|
135
|
-
type SnapPoints = BottomSheetProps['snapPoints'];
|
|
136
|
-
|
|
137
|
-
const normalizeSnapPoints = (input: SnapPoints): SnapPoints => {
|
|
138
|
-
const snapPoints = input ? ('value' in input ? input.value : input) : [];
|
|
139
|
-
|
|
140
|
-
return snapPoints.map((snapPoint) => {
|
|
141
|
-
if (typeof snapPoint === 'number') {
|
|
142
|
-
return Math.max(0, snapPoint);
|
|
143
|
-
} else {
|
|
144
|
-
const numericValue = Number(snapPoint.replace('%', ''));
|
|
145
|
-
const isPercentage = snapPoint.includes('%');
|
|
146
|
-
|
|
147
|
-
if (isNaN(numericValue)) {
|
|
148
|
-
return 0;
|
|
149
|
-
} else if (isPercentage) {
|
|
150
|
-
return `${Math.max(0, numericValue)}%`;
|
|
151
|
-
} else {
|
|
152
|
-
return Math.max(0, numericValue);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
|
|
158
125
|
export const ImageGallery = <
|
|
159
126
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
160
127
|
>(
|
|
@@ -179,35 +146,20 @@ export const ImageGallery = <
|
|
|
179
146
|
},
|
|
180
147
|
} = useTheme();
|
|
181
148
|
const [gridPhotos, setGridPhotos] = useState<Photo<StreamChatGenerics>[]>([]);
|
|
182
|
-
const { overlay
|
|
149
|
+
const { overlay } = useOverlayContext();
|
|
183
150
|
const { messages, selectedMessage, setSelectedMessage } =
|
|
184
151
|
useImageGalleryContext<StreamChatGenerics>();
|
|
185
152
|
|
|
186
153
|
const { vh, vw } = useViewport();
|
|
187
154
|
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const halfScreenWidth =
|
|
155
|
+
const fullWindowHeight = vh(100);
|
|
156
|
+
const fullWindowWidth = vw(100);
|
|
157
|
+
const halfScreenWidth = fullWindowWidth / 2;
|
|
191
158
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*/
|
|
195
|
-
const statusBarHeight = StatusBar.currentHeight ?? 0;
|
|
196
|
-
const bottomBarHeight = fullScreenHeight - measuredScreenHeight - statusBarHeight;
|
|
197
|
-
const androidScreenHeightAdjustment = translucentStatusBar
|
|
198
|
-
? bottomBarHeight === statusBarHeight || bottomBarHeight < 0
|
|
199
|
-
? 0
|
|
200
|
-
: statusBarHeight
|
|
201
|
-
: bottomBarHeight === statusBarHeight || bottomBarHeight < 0
|
|
202
|
-
? -statusBarHeight
|
|
203
|
-
: 0;
|
|
204
|
-
const screenHeight = isAndroid
|
|
205
|
-
? Dimensions.get('window').height + androidScreenHeightAdjustment
|
|
206
|
-
: vh(100);
|
|
207
|
-
const halfScreenHeight = screenHeight / 2;
|
|
208
|
-
const quarterScreenHeight = screenHeight / 4;
|
|
159
|
+
const halfScreenHeight = fullWindowHeight / 2;
|
|
160
|
+
const quarterScreenHeight = fullWindowHeight / 4;
|
|
209
161
|
const snapPoints = React.useMemo(
|
|
210
|
-
() => [(
|
|
162
|
+
() => [(fullWindowHeight * 3) / 4, fullWindowHeight - imageGalleryGridHandleHeight],
|
|
211
163
|
[],
|
|
212
164
|
);
|
|
213
165
|
|
|
@@ -226,7 +178,7 @@ export const ImageGallery = <
|
|
|
226
178
|
* Fade animation for screen, it is always rendered with pointerEvents
|
|
227
179
|
* set to none for fast opening
|
|
228
180
|
*/
|
|
229
|
-
const screenTranslateY = useSharedValue(
|
|
181
|
+
const screenTranslateY = useSharedValue(fullWindowHeight);
|
|
230
182
|
const showScreen = () => {
|
|
231
183
|
'worklet';
|
|
232
184
|
screenTranslateY.value = withTiming(0, {
|
|
@@ -246,7 +198,7 @@ export const ImageGallery = <
|
|
|
246
198
|
/**
|
|
247
199
|
* Image height from URL or default to full screen height
|
|
248
200
|
*/
|
|
249
|
-
const [currentImageHeight, setCurrentImageHeight] = useState<number>(
|
|
201
|
+
const [currentImageHeight, setCurrentImageHeight] = useState<number>(fullWindowHeight);
|
|
250
202
|
|
|
251
203
|
/**
|
|
252
204
|
* JS and UI index values, the JS follows the UI but is needed
|
|
@@ -321,9 +273,9 @@ export const ImageGallery = <
|
|
|
321
273
|
a.type === 'giphy'
|
|
322
274
|
? giphyURL
|
|
323
275
|
: getResizedImageUrl({
|
|
324
|
-
height:
|
|
276
|
+
height: fullWindowHeight,
|
|
325
277
|
url: imageUrl,
|
|
326
|
-
width:
|
|
278
|
+
width: fullWindowWidth,
|
|
327
279
|
}),
|
|
328
280
|
user: cur.user,
|
|
329
281
|
user_id: cur.user_id,
|
|
@@ -360,7 +312,7 @@ export const ImageGallery = <
|
|
|
360
312
|
|
|
361
313
|
if (newIndex > -1) {
|
|
362
314
|
index.value = newIndex;
|
|
363
|
-
translationX.value = -(
|
|
315
|
+
translationX.value = -(fullWindowWidth + MARGIN) * newIndex;
|
|
364
316
|
runOnJS(setSelectedIndex)(newIndex);
|
|
365
317
|
}
|
|
366
318
|
};
|
|
@@ -383,19 +335,19 @@ export const ImageGallery = <
|
|
|
383
335
|
const uriForCurrentImage = imageGalleryAttachments[selectedIndex]?.uri;
|
|
384
336
|
|
|
385
337
|
useEffect(() => {
|
|
386
|
-
setCurrentImageHeight(
|
|
338
|
+
setCurrentImageHeight(fullWindowHeight);
|
|
387
339
|
const photo = imageGalleryAttachments[index.value];
|
|
388
340
|
const height = photo?.original_height;
|
|
389
341
|
const width = photo?.original_width;
|
|
390
342
|
|
|
391
343
|
if (height && width) {
|
|
392
|
-
const imageHeight = Math.floor(height * (
|
|
393
|
-
setCurrentImageHeight(imageHeight >
|
|
344
|
+
const imageHeight = Math.floor(height * (fullWindowWidth / width));
|
|
345
|
+
setCurrentImageHeight(imageHeight > fullWindowHeight ? fullWindowHeight : imageHeight);
|
|
394
346
|
} else if (photo?.uri) {
|
|
395
347
|
if (photo.type === 'image') {
|
|
396
348
|
Image.getSize(photo.uri, (width, height) => {
|
|
397
|
-
const imageHeight = Math.floor(height * (
|
|
398
|
-
setCurrentImageHeight(imageHeight >
|
|
349
|
+
const imageHeight = Math.floor(height * (fullWindowWidth / width));
|
|
350
|
+
setCurrentImageHeight(imageHeight > fullWindowHeight ? fullWindowHeight : imageHeight);
|
|
399
351
|
});
|
|
400
352
|
}
|
|
401
353
|
}
|
|
@@ -410,8 +362,8 @@ export const ImageGallery = <
|
|
|
410
362
|
overlayOpacity,
|
|
411
363
|
photoLength,
|
|
412
364
|
scale,
|
|
413
|
-
screenHeight,
|
|
414
|
-
screenWidth,
|
|
365
|
+
screenHeight: fullWindowHeight,
|
|
366
|
+
screenWidth: fullWindowWidth,
|
|
415
367
|
selectedIndex,
|
|
416
368
|
setSelectedIndex,
|
|
417
369
|
translateX,
|
|
@@ -425,9 +377,9 @@ export const ImageGallery = <
|
|
|
425
377
|
*/
|
|
426
378
|
const headerFooterOpacity = useDerivedValue(
|
|
427
379
|
() =>
|
|
428
|
-
currentImageHeight * scale.value <
|
|
380
|
+
currentImageHeight * scale.value < fullWindowHeight && translateY.value > 0
|
|
429
381
|
? 1 - translateY.value / quarterScreenHeight
|
|
430
|
-
: currentImageHeight * scale.value >
|
|
382
|
+
: currentImageHeight * scale.value > fullWindowHeight &&
|
|
431
383
|
translateY.value > (currentImageHeight / 2) * scale.value - halfScreenHeight
|
|
432
384
|
? 1 -
|
|
433
385
|
(translateY.value - ((currentImageHeight / 2) * scale.value - halfScreenHeight)) /
|
|
@@ -614,15 +566,15 @@ export const ImageGallery = <
|
|
|
614
566
|
previous={selectedIndex > i}
|
|
615
567
|
repeat={true}
|
|
616
568
|
scale={scale}
|
|
617
|
-
screenHeight={
|
|
569
|
+
screenHeight={fullWindowHeight}
|
|
618
570
|
selected={selectedIndex === i}
|
|
619
571
|
shouldRender={Math.abs(selectedIndex - i) < 4}
|
|
620
572
|
source={{ uri: photo.uri }}
|
|
621
573
|
style={[
|
|
622
574
|
{
|
|
623
|
-
height:
|
|
575
|
+
height: fullWindowHeight * 8,
|
|
624
576
|
marginRight: MARGIN,
|
|
625
|
-
width:
|
|
577
|
+
width: fullWindowWidth * 8,
|
|
626
578
|
},
|
|
627
579
|
slide,
|
|
628
580
|
]}
|
|
@@ -639,14 +591,14 @@ export const ImageGallery = <
|
|
|
639
591
|
photo={photo}
|
|
640
592
|
previous={selectedIndex > i}
|
|
641
593
|
scale={scale}
|
|
642
|
-
screenHeight={
|
|
594
|
+
screenHeight={fullWindowHeight}
|
|
643
595
|
selected={selectedIndex === i}
|
|
644
596
|
shouldRender={Math.abs(selectedIndex - i) < 4}
|
|
645
597
|
style={[
|
|
646
598
|
{
|
|
647
|
-
height:
|
|
599
|
+
height: fullWindowHeight * 8,
|
|
648
600
|
marginRight: MARGIN,
|
|
649
|
-
width:
|
|
601
|
+
width: fullWindowWidth * 8,
|
|
650
602
|
},
|
|
651
603
|
slide,
|
|
652
604
|
]}
|
|
@@ -704,11 +656,11 @@ export const ImageGallery = <
|
|
|
704
656
|
{...imageGalleryCustomComponents?.gridHandle}
|
|
705
657
|
/>
|
|
706
658
|
)}
|
|
707
|
-
handleHeight={imageGalleryGridHandleHeight
|
|
659
|
+
handleHeight={imageGalleryGridHandleHeight}
|
|
708
660
|
index={0}
|
|
709
661
|
onChange={(index: number) => setCurrentBottomSheetIndex(index)}
|
|
710
662
|
ref={bottomSheetModalRef}
|
|
711
|
-
snapPoints={
|
|
663
|
+
snapPoints={imageGalleryGridSnapPoints || snapPoints}
|
|
712
664
|
>
|
|
713
665
|
<ImageGrid
|
|
714
666
|
closeGridView={closeGridView}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Platform,
|
|
4
|
-
Pressable,
|
|
5
|
-
SafeAreaView,
|
|
6
|
-
StatusBar,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
Text,
|
|
9
|
-
View,
|
|
10
|
-
ViewStyle,
|
|
11
|
-
} from 'react-native';
|
|
2
|
+
import { Pressable, SafeAreaView, StyleSheet, Text, View, ViewStyle } from 'react-native';
|
|
12
3
|
import Animated, { Extrapolate, interpolate, useAnimatedStyle } from 'react-native-reanimated';
|
|
13
4
|
|
|
14
5
|
import { useOverlayContext } from '../../../contexts/overlayContext/OverlayContext';
|
|
@@ -108,7 +99,7 @@ export const ImageGalleryHeader = <
|
|
|
108
99
|
},
|
|
109
100
|
} = useTheme();
|
|
110
101
|
const { t, tDateTimeParser } = useTranslationContext();
|
|
111
|
-
const { setOverlay
|
|
102
|
+
const { setOverlay } = useOverlayContext();
|
|
112
103
|
|
|
113
104
|
const parsedDate = photo ? tDateTimeParser(photo?.created_at) : null;
|
|
114
105
|
|
|
@@ -146,11 +137,6 @@ export const ImageGalleryHeader = <
|
|
|
146
137
|
],
|
|
147
138
|
}));
|
|
148
139
|
|
|
149
|
-
const androidTranslucentHeaderStyle = {
|
|
150
|
-
paddingTop:
|
|
151
|
-
Platform.OS === 'android' && translucentStatusBar ? StatusBar.currentHeight : undefined,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
140
|
const hideOverlay = () => {
|
|
155
141
|
setOverlay('none');
|
|
156
142
|
};
|
|
@@ -160,9 +146,7 @@ export const ImageGalleryHeader = <
|
|
|
160
146
|
onLayout={(event) => setHeight(event.nativeEvent.layout.height)}
|
|
161
147
|
pointerEvents={'box-none'}
|
|
162
148
|
>
|
|
163
|
-
<ReanimatedSafeAreaView
|
|
164
|
-
style={[{ backgroundColor: white }, androidTranslucentHeaderStyle, container, headerStyle]}
|
|
165
|
-
>
|
|
149
|
+
<ReanimatedSafeAreaView style={[{ backgroundColor: white }, container, headerStyle]}>
|
|
166
150
|
<View style={[styles.innerContainer, innerContainer]}>
|
|
167
151
|
{leftElement ? (
|
|
168
152
|
leftElement({ hideOverlay, photo })
|
|
@@ -12,7 +12,10 @@ import type { UserResponse } from 'stream-chat';
|
|
|
12
12
|
import { useCountdown } from './hooks/useCountdown';
|
|
13
13
|
|
|
14
14
|
import { ChatContextValue, useChatContext } from '../../contexts';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
AttachmentPickerContextValue,
|
|
17
|
+
useAttachmentPickerContext,
|
|
18
|
+
} from '../../contexts/attachmentPickerContext/AttachmentPickerContext';
|
|
16
19
|
import {
|
|
17
20
|
ChannelContextValue,
|
|
18
21
|
useChannelContext,
|
|
@@ -38,7 +41,6 @@ import {
|
|
|
38
41
|
} from '../../contexts/translationContext/TranslationContext';
|
|
39
42
|
|
|
40
43
|
import type { Asset, DefaultStreamChatGenerics } from '../../types/types';
|
|
41
|
-
import { AttachmentSelectionBar } from '../AttachmentPicker/components/AttachmentSelectionBar';
|
|
42
44
|
import { AutoCompleteInput } from '../AutoCompleteInput/AutoCompleteInput';
|
|
43
45
|
|
|
44
46
|
const styles = StyleSheet.create({
|
|
@@ -80,7 +82,8 @@ const styles = StyleSheet.create({
|
|
|
80
82
|
|
|
81
83
|
type MessageInputPropsWithContext<
|
|
82
84
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
83
|
-
> = Pick<
|
|
85
|
+
> = Pick<AttachmentPickerContextValue, 'AttachmentPickerSelectionBar'> &
|
|
86
|
+
Pick<ChatContextValue<StreamChatGenerics>, 'isOnline'> &
|
|
84
87
|
Pick<
|
|
85
88
|
ChannelContextValue<StreamChatGenerics>,
|
|
86
89
|
'disabled' | 'members' | 'threadList' | 'watchers'
|
|
@@ -146,6 +149,7 @@ const MessageInputWithContext = <
|
|
|
146
149
|
additionalTextInputProps,
|
|
147
150
|
asyncIds,
|
|
148
151
|
asyncUploads,
|
|
152
|
+
AttachmentPickerSelectionBar,
|
|
149
153
|
AutoCompleteSuggestionList,
|
|
150
154
|
closeAttachmentPicker,
|
|
151
155
|
cooldownEndsAt,
|
|
@@ -637,14 +641,12 @@ const MessageInputWithContext = <
|
|
|
637
641
|
{
|
|
638
642
|
backgroundColor: white_smoke,
|
|
639
643
|
height:
|
|
640
|
-
|
|
641
|
-
? attachmentPickerBottomSheetHeight + (attachmentSelectionBarHeight ?? 52)
|
|
642
|
-
: 360) - bottomInset,
|
|
644
|
+
attachmentPickerBottomSheetHeight + attachmentSelectionBarHeight - bottomInset,
|
|
643
645
|
},
|
|
644
646
|
attachmentSelectionBar,
|
|
645
647
|
]}
|
|
646
648
|
>
|
|
647
|
-
<
|
|
649
|
+
<AttachmentPickerSelectionBar />
|
|
648
650
|
</View>
|
|
649
651
|
)}
|
|
650
652
|
</>
|
|
@@ -789,6 +791,7 @@ export const MessageInput = <
|
|
|
789
791
|
>(
|
|
790
792
|
props: MessageInputProps<StreamChatGenerics>,
|
|
791
793
|
) => {
|
|
794
|
+
const { AttachmentPickerSelectionBar } = useAttachmentPickerContext();
|
|
792
795
|
const { isOnline } = useChatContext();
|
|
793
796
|
const ownCapabilities = useOwnCapabilitiesContext();
|
|
794
797
|
|
|
@@ -859,6 +862,7 @@ export const MessageInput = <
|
|
|
859
862
|
additionalTextInputProps,
|
|
860
863
|
asyncIds,
|
|
861
864
|
asyncUploads,
|
|
865
|
+
AttachmentPickerSelectionBar,
|
|
862
866
|
AutoCompleteSuggestionHeader,
|
|
863
867
|
AutoCompleteSuggestionItem,
|
|
864
868
|
AutoCompleteSuggestionList,
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { generateChannelResponse } from '../../../mock-builders/generator/channel';
|
|
17
17
|
import { generateUser } from '../../../mock-builders/generator/user';
|
|
18
18
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
19
|
+
import { AttachmentPickerSelectionBar } from '../../AttachmentPicker/components/AttachmentPickerSelectionBar';
|
|
19
20
|
import { CameraSelectorIcon } from '../../AttachmentPicker/components/CameraSelectorIcon';
|
|
20
21
|
import { FileSelectorIcon } from '../../AttachmentPicker/components/FileSelectorIcon';
|
|
21
22
|
import { ImageSelectorIcon } from '../../AttachmentPicker/components/ImageSelectorIcon';
|
|
@@ -27,6 +28,7 @@ describe('MessageInput', () => {
|
|
|
27
28
|
jest.spyOn(Alert, 'alert');
|
|
28
29
|
jest.spyOn(AttachmentPickerUtils, 'useAttachmentPickerContext').mockImplementation(
|
|
29
30
|
jest.fn(() => ({
|
|
31
|
+
AttachmentPickerSelectionBar,
|
|
30
32
|
CameraSelectorIcon,
|
|
31
33
|
closePicker: jest.fn(),
|
|
32
34
|
FileSelectorIcon,
|
package/src/components/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ export * from './AttachmentPicker/AttachmentPicker';
|
|
|
14
14
|
export * from './AttachmentPicker/components/AttachmentPickerBottomSheetHandle';
|
|
15
15
|
export * from './AttachmentPicker/components/AttachmentPickerError';
|
|
16
16
|
export * from './AttachmentPicker/components/AttachmentPickerErrorImage';
|
|
17
|
-
export * from './AttachmentPicker/components/
|
|
17
|
+
export * from './AttachmentPicker/components/AttachmentPickerSelectionBar';
|
|
18
18
|
export * from './AttachmentPicker/components/CameraSelectorIcon';
|
|
19
19
|
export * from './AttachmentPicker/components/FileSelectorIcon';
|
|
20
20
|
export * from './AttachmentPicker/components/ImageOverlaySelectedComponent';
|