stream-chat-react-native-core 4.11.1-beta.4 → 4.12.0-beta.3
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/AudioAttachment.js +541 -0
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +113 -10
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +2 -2
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/{GallaryImage.js → GalleryImage.js} +3 -3
- package/lib/{module/components/Attachment/GallaryImage.js.map → commonjs/components/Attachment/GalleryImage.js.map} +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Attachment/VideoThumbnail.js +10 -5
- package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js.map +1 -1
- package/lib/commonjs/components/Avatar/GroupAvatar.js +1 -1
- package/lib/commonjs/components/Avatar/GroupAvatar.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +18 -13
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +37 -30
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js +5 -3
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +10 -6
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +17 -14
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +1 -0
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryOverlay.js +2 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryOverlay.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +37 -18
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +3 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGridHandle.js +5 -4
- package/lib/commonjs/components/ImageGallery/components/ImageGridHandle.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +8 -6
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.test.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.test.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +125 -35
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/{module/components/ImageGallery/components → commonjs/components/ProgressControl}/ProgressControl.js +37 -24
- package/lib/commonjs/components/ProgressControl/ProgressControl.js.map +1 -0
- package/lib/commonjs/components/index.js +26 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +5 -2
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +7 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +9 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/icons/Pause.js +2 -2
- package/lib/commonjs/icons/Pause.js.map +1 -1
- package/lib/commonjs/mock-builders/api/channelMocks.js +1 -0
- package/lib/commonjs/mock-builders/api/channelMocks.js.map +1 -1
- package/lib/commonjs/native.js +13 -5
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/AudioAttachment.js +541 -0
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/module/components/Attachment/FileAttachmentGroup.js +113 -10
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +2 -2
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/{GallaryImage.js → GalleryImage.js} +3 -3
- package/lib/{commonjs/components/Attachment/GallaryImage.js.map → module/components/Attachment/GalleryImage.js.map} +1 -1
- package/lib/module/components/Attachment/Giphy.js +1 -1
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Attachment/VideoThumbnail.js +10 -5
- package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/Avatar/Avatar.js.map +1 -1
- package/lib/module/components/Avatar/GroupAvatar.js +1 -1
- package/lib/module/components/Avatar/GroupAvatar.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +18 -13
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +37 -30
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js +5 -3
- package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +10 -6
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +17 -14
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +1 -0
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryOverlay.js +2 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryOverlay.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +37 -18
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGrid.js +3 -1
- package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGridHandle.js +5 -4
- package/lib/module/components/ImageGallery/components/ImageGridHandle.js.map +1 -1
- package/lib/module/components/Message/Message.js +8 -6
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.test.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.test.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +125 -35
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/{commonjs/components/ImageGallery/components → module/components/ProgressControl}/ProgressControl.js +37 -24
- package/lib/module/components/ProgressControl/ProgressControl.js.map +1 -0
- package/lib/module/components/index.js +26 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +5 -2
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +7 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +9 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/icons/Pause.js +2 -2
- package/lib/module/icons/Pause.js.map +1 -1
- package/lib/module/mock-builders/api/channelMocks.js +1 -0
- package/lib/module/mock-builders/api/channelMocks.js.map +1 -1
- package/lib/module/native.js +13 -5
- package/lib/module/native.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +26 -0
- package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts +2 -1
- package/lib/typescript/components/Attachment/{GallaryImage.d.ts → GalleryImage.d.ts} +0 -0
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/__tests__/AnimatedVideoGallery.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGallery.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryFooter.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryGrid.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryGridHandle.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryHeader.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryOverlay.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/__tests__/ImageGalleryVideoControl.test.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/components/AnimatedGalleryImage.d.ts +1 -0
- package/lib/typescript/components/ImageGallery/components/AnimatedGalleryVideo.d.ts +2 -3
- package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +2 -1
- package/lib/typescript/components/ImageGallery/components/ImageGrid.d.ts +2 -3
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +1 -1
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +1 -1
- package/lib/typescript/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.d.ts +1 -0
- package/lib/typescript/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.d.ts +1 -0
- package/lib/typescript/components/ProgressControl/ProgressControl.d.ts +11 -0
- package/lib/typescript/components/index.d.ts +2 -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/themeContext/utils/theme.d.ts +9 -0
- package/lib/typescript/native.d.ts +59 -2
- package/package.json +1 -1
- package/src/components/Attachment/AudioAttachment.tsx +357 -0
- package/src/components/Attachment/FileAttachmentGroup.tsx +96 -7
- package/src/components/Attachment/Gallery.tsx +1 -1
- package/src/components/Attachment/{GallaryImage.tsx → GalleryImage.tsx} +1 -1
- package/src/components/Attachment/Giphy.tsx +1 -1
- package/src/components/Attachment/VideoThumbnail.tsx +4 -4
- package/src/components/Attachment/__tests__/Gallery.test.js +6 -6
- package/src/components/Attachment/__tests__/Giphy.test.js +4 -4
- package/src/components/Avatar/Avatar.tsx +1 -1
- package/src/components/Avatar/GroupAvatar.tsx +1 -1
- package/src/components/Channel/Channel.tsx +3 -0
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -0
- package/src/components/ImageGallery/ImageGallery.tsx +21 -11
- package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx +241 -0
- package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +192 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +190 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryGrid.test.tsx +98 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryGridHandle.test.tsx +79 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +172 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryOverlay.test.tsx +94 -0
- package/src/components/ImageGallery/__tests__/ImageGalleryVideoControl.test.tsx +84 -0
- package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx +3 -0
- package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +11 -3
- package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +9 -2
- package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +1 -1
- package/src/components/ImageGallery/components/ImageGalleryOverlay.tsx +6 -1
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +27 -9
- package/src/components/ImageGallery/components/ImageGrid.tsx +19 -17
- package/src/components/ImageGallery/components/ImageGridHandle.tsx +4 -1
- package/src/components/Message/Message.tsx +2 -1
- package/src/components/Message/MessageSimple/__tests__/MessageContent.test.js +11 -3
- package/src/components/Message/MessageSimple/__tests__/__snapshots__/MessageAvatar.test.js.snap +1 -1
- package/src/components/Message/MessageSimple/utils/parseLinks.test.ts +4 -0
- package/src/components/Message/MessageSimple/utils/parseLinks.ts +1 -1
- package/src/components/MessageInput/FileUploadPreview.tsx +162 -66
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +196 -0
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +212 -0
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +64 -0
- package/src/components/{ImageGallery/components → ProgressControl}/ProgressControl.tsx +37 -19
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +4 -4
- package/src/components/index.ts +3 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +11 -0
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +5 -1
- package/src/contexts/themeContext/utils/theme.ts +15 -0
- package/src/icons/Pause.tsx +2 -2
- package/src/mock-builders/api/channelMocks.tsx +1 -0
- package/src/native.ts +67 -7
- package/src/version.json +1 -1
- package/lib/commonjs/components/ImageGallery/components/ProgressControl.js.map +0 -1
- package/lib/module/components/ImageGallery/components/ProgressControl.js.map +0 -1
- package/lib/typescript/components/ImageGallery/components/ProgressControl.d.ts +0 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { act, ReactTestInstance } from 'react-test-renderer';
|
|
4
|
+
|
|
5
|
+
import { fireEvent, render, waitFor } from '@testing-library/react-native';
|
|
6
|
+
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import duration from 'dayjs/plugin/duration';
|
|
9
|
+
|
|
10
|
+
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
11
|
+
import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
|
|
12
|
+
import type { ImageGalleryFooterVideoControlProps } from '../components/ImageGalleryFooter';
|
|
13
|
+
import { ImageGalleryVideoControl } from '../components/ImageGalleryVideoControl';
|
|
14
|
+
|
|
15
|
+
dayjs.extend(duration);
|
|
16
|
+
|
|
17
|
+
const getComponent = (props: Partial<ImageGalleryFooterVideoControlProps>) => (
|
|
18
|
+
<ThemeProvider theme={defaultTheme}>
|
|
19
|
+
<ImageGalleryVideoControl {...(props as unknown as ImageGalleryFooterVideoControlProps)} />
|
|
20
|
+
</ThemeProvider>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
describe('ImageGalleryOverlay', () => {
|
|
24
|
+
it('should trigger the onPlayPause when play/pause button is pressed', async () => {
|
|
25
|
+
const onPlayPauseMock = jest.fn();
|
|
26
|
+
|
|
27
|
+
const { queryByA11yLabel } = render(getComponent({ onPlayPause: onPlayPauseMock }));
|
|
28
|
+
|
|
29
|
+
const component = queryByA11yLabel('Play Pause Button') as ReactTestInstance;
|
|
30
|
+
|
|
31
|
+
act(() => {
|
|
32
|
+
fireEvent(component, 'onPress');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(component).not.toBeUndefined();
|
|
37
|
+
expect(onPlayPauseMock).toHaveBeenCalled();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should render the play icon when paused prop is true', async () => {
|
|
42
|
+
const { queryByA11yLabel } = render(getComponent({ paused: true }));
|
|
43
|
+
|
|
44
|
+
const component = queryByA11yLabel('Play Icon') as ReactTestInstance;
|
|
45
|
+
|
|
46
|
+
await waitFor(() => {
|
|
47
|
+
expect(component).not.toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should calculate the videoDuration and progressDuration when they are greater than or equal to 3600', () => {
|
|
52
|
+
jest.spyOn(dayjs, 'duration');
|
|
53
|
+
|
|
54
|
+
const { queryByA11yLabel } = render(
|
|
55
|
+
getComponent({
|
|
56
|
+
duration: 3600,
|
|
57
|
+
progress: 1,
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const videoDurationComponent = queryByA11yLabel('Video Duration') as ReactTestInstance;
|
|
62
|
+
const progressDurationComponent = queryByA11yLabel('Progress Duration') as ReactTestInstance;
|
|
63
|
+
|
|
64
|
+
expect(videoDurationComponent.children[0]).toBe('01:00:00');
|
|
65
|
+
expect(progressDurationComponent.children[0]).toBe('01:00:00');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should calculate the videoDuration and progressDuration when they are less than 3600', () => {
|
|
69
|
+
jest.spyOn(dayjs, 'duration');
|
|
70
|
+
|
|
71
|
+
const { queryByA11yLabel } = render(
|
|
72
|
+
getComponent({
|
|
73
|
+
duration: 60,
|
|
74
|
+
progress: 0.5,
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const videoDurationComponent = queryByA11yLabel('Video Duration') as ReactTestInstance;
|
|
79
|
+
const progressDurationComponent = queryByA11yLabel('Progress Duration') as ReactTestInstance;
|
|
80
|
+
|
|
81
|
+
expect(videoDurationComponent.children[0]).toBe('01:00');
|
|
82
|
+
expect(progressDurationComponent.children[0]).toBe('00:30');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -10,6 +10,7 @@ const halfScreenWidth = vw(50);
|
|
|
10
10
|
const oneEighth = 1 / 8;
|
|
11
11
|
|
|
12
12
|
type Props = {
|
|
13
|
+
accessibilityLabel: string;
|
|
13
14
|
index: number;
|
|
14
15
|
offsetScale: Animated.SharedValue<number>;
|
|
15
16
|
photo: { uri: string };
|
|
@@ -26,6 +27,7 @@ type Props = {
|
|
|
26
27
|
export const AnimatedGalleryImage: React.FC<Props> = React.memo(
|
|
27
28
|
(props) => {
|
|
28
29
|
const {
|
|
30
|
+
accessibilityLabel,
|
|
29
31
|
index,
|
|
30
32
|
offsetScale,
|
|
31
33
|
photo,
|
|
@@ -83,6 +85,7 @@ export const AnimatedGalleryImage: React.FC<Props> = React.memo(
|
|
|
83
85
|
|
|
84
86
|
return (
|
|
85
87
|
<Animated.Image
|
|
88
|
+
accessibilityLabel={accessibilityLabel}
|
|
86
89
|
resizeMode={'contain'}
|
|
87
90
|
source={{ uri: photo.uri }}
|
|
88
91
|
style={[
|
|
@@ -19,7 +19,7 @@ const screenWidth = vw(100);
|
|
|
19
19
|
const halfScreenWidth = vw(50);
|
|
20
20
|
const oneEighth = 1 / 8;
|
|
21
21
|
|
|
22
|
-
type
|
|
22
|
+
export type AnimatedGalleryVideoType = {
|
|
23
23
|
handleEnd: () => void;
|
|
24
24
|
handleLoad: (payload: VideoPayloadData) => void;
|
|
25
25
|
handleProgress: (data: VideoProgressData) => void;
|
|
@@ -48,7 +48,7 @@ const styles = StyleSheet.create({
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
export const AnimatedGalleryVideo: React.FC<
|
|
51
|
+
export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.memo(
|
|
52
52
|
(props) => {
|
|
53
53
|
const [opacity, setOpacity] = useState<number>(1);
|
|
54
54
|
const {
|
|
@@ -154,11 +154,17 @@ export const AnimatedGalleryVideo: React.FC<Props> = React.memo(
|
|
|
154
154
|
* load on memory.
|
|
155
155
|
*/
|
|
156
156
|
if (!shouldRender) {
|
|
157
|
-
return
|
|
157
|
+
return (
|
|
158
|
+
<View
|
|
159
|
+
accessibilityLabel='Empty View Image Gallery'
|
|
160
|
+
style={[style, { transform: [{ scale: oneEighth }] }]}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
return (
|
|
161
166
|
<Animated.View
|
|
167
|
+
accessibilityLabel='Image Gallery Video'
|
|
162
168
|
style={[
|
|
163
169
|
style,
|
|
164
170
|
animatedViewStyles,
|
|
@@ -185,11 +191,13 @@ export const AnimatedGalleryVideo: React.FC<Props> = React.memo(
|
|
|
185
191
|
paused={paused}
|
|
186
192
|
resizeMode='contain'
|
|
187
193
|
style={style}
|
|
194
|
+
testID='video-player'
|
|
188
195
|
uri={source.uri}
|
|
189
196
|
videoRef={videoRef}
|
|
190
197
|
/>
|
|
191
198
|
)}
|
|
192
199
|
<Animated.View
|
|
200
|
+
accessibilityLabel='Spinner'
|
|
193
201
|
style={[
|
|
194
202
|
styles.activityIndicator,
|
|
195
203
|
{
|
|
@@ -64,7 +64,7 @@ export type ImageGalleryFooterCustomComponent<
|
|
|
64
64
|
|
|
65
65
|
export type ImageGalleryFooterVideoControlProps = {
|
|
66
66
|
duration: number;
|
|
67
|
-
onPlayPause: () => void;
|
|
67
|
+
onPlayPause: (status?: boolean) => void;
|
|
68
68
|
onProgressDrag: (progress: number) => void;
|
|
69
69
|
paused: boolean;
|
|
70
70
|
progress: number;
|
|
@@ -92,6 +92,7 @@ export type ImageGalleryFooterCustomComponentProps<
|
|
|
92
92
|
type ImageGalleryFooterPropsWithContext<
|
|
93
93
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
94
94
|
> = ImageGalleryFooterCustomComponentProps<StreamChatGenerics> & {
|
|
95
|
+
accessibilityLabel: string;
|
|
95
96
|
duration: number;
|
|
96
97
|
onPlayPause: () => void;
|
|
97
98
|
onProgressDrag: (progress: number) => void;
|
|
@@ -111,6 +112,7 @@ export const ImageGalleryFooterWithContext = <
|
|
|
111
112
|
props: ImageGalleryFooterPropsWithContext<StreamChatGenerics>,
|
|
112
113
|
) => {
|
|
113
114
|
const {
|
|
115
|
+
accessibilityLabel,
|
|
114
116
|
centerElement,
|
|
115
117
|
duration,
|
|
116
118
|
GridIcon,
|
|
@@ -182,6 +184,7 @@ export const ImageGalleryFooterWithContext = <
|
|
|
182
184
|
|
|
183
185
|
return (
|
|
184
186
|
<Animated.View
|
|
187
|
+
accessibilityLabel={accessibilityLabel}
|
|
185
188
|
onLayout={(event) => setHeight(event.nativeEvent.layout.height)}
|
|
186
189
|
pointerEvents={'box-none'}
|
|
187
190
|
style={styles.wrapper}
|
|
@@ -204,7 +207,11 @@ export const ImageGalleryFooterWithContext = <
|
|
|
204
207
|
{leftElement ? (
|
|
205
208
|
leftElement({ openGridView, photo, share, shareMenuOpen })
|
|
206
209
|
) : (
|
|
207
|
-
<TouchableOpacity
|
|
210
|
+
<TouchableOpacity
|
|
211
|
+
accessibilityLabel='Share Button'
|
|
212
|
+
disabled={shareMenuOpen}
|
|
213
|
+
onPress={share}
|
|
214
|
+
>
|
|
208
215
|
<View style={[styles.leftContainer, leftContainer]}>
|
|
209
216
|
{ShareIcon ? ShareIcon : <ShareIconDefault pathFill={black} />}
|
|
210
217
|
</View>
|
|
@@ -167,7 +167,7 @@ export const ImageGalleryHeader = <
|
|
|
167
167
|
{leftElement ? (
|
|
168
168
|
leftElement({ hideOverlay, photo })
|
|
169
169
|
) : (
|
|
170
|
-
<TouchableOpacity onPress={hideOverlay}>
|
|
170
|
+
<TouchableOpacity accessibilityLabel='Hide Overlay' onPress={hideOverlay}>
|
|
171
171
|
<View style={[styles.leftContainer, leftContainer]}>
|
|
172
172
|
{CloseIcon ? CloseIcon : <Close />}
|
|
173
173
|
</View>
|
|
@@ -74,7 +74,12 @@ export const ImageGalleryOverlay: React.FC<Props> = (props) => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<TapGestureHandler
|
|
77
|
+
<TapGestureHandler
|
|
78
|
+
maxDeltaX={16}
|
|
79
|
+
maxDeltaY={16}
|
|
80
|
+
onHandlerStateChange={tapEvent}
|
|
81
|
+
testID='image-gallery-overlay'
|
|
82
|
+
>
|
|
78
83
|
<Animated.View
|
|
79
84
|
style={[
|
|
80
85
|
StyleSheet.absoluteFillObject,
|
|
@@ -4,20 +4,18 @@ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
|
|
6
6
|
import type { ImageGalleryFooterVideoControlProps } from './ImageGalleryFooter';
|
|
7
|
-
import { ProgressControl } from './ProgressControl';
|
|
8
7
|
|
|
9
8
|
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
|
|
10
9
|
|
|
11
10
|
import { Pause, Play } from '../../../icons';
|
|
11
|
+
import { ProgressControl } from '../../ProgressControl/ProgressControl';
|
|
12
12
|
|
|
13
13
|
const styles = StyleSheet.create({
|
|
14
14
|
durationTextStyle: {
|
|
15
|
-
color: '#fff',
|
|
16
15
|
fontWeight: 'bold',
|
|
17
16
|
},
|
|
18
17
|
roundedView: {
|
|
19
18
|
alignItems: 'center',
|
|
20
|
-
backgroundColor: '#fff',
|
|
21
19
|
borderRadius: 50,
|
|
22
20
|
display: 'flex',
|
|
23
21
|
elevation: 2,
|
|
@@ -55,6 +53,7 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
|
|
|
55
53
|
|
|
56
54
|
const {
|
|
57
55
|
theme: {
|
|
56
|
+
colors: { static_black, static_white },
|
|
58
57
|
imageGallery: {
|
|
59
58
|
videoControl: { durationTextStyle, roundedView, videoContainer },
|
|
60
59
|
},
|
|
@@ -63,25 +62,44 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
|
|
|
63
62
|
|
|
64
63
|
return (
|
|
65
64
|
<View style={[styles.videoContainer, videoContainer]}>
|
|
66
|
-
<TouchableOpacity
|
|
67
|
-
|
|
65
|
+
<TouchableOpacity
|
|
66
|
+
accessibilityLabel='Play Pause Button'
|
|
67
|
+
onPress={() => {
|
|
68
|
+
onPlayPause();
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<View style={[styles.roundedView, roundedView, { backgroundColor: static_white }]}>
|
|
68
72
|
{paused ? (
|
|
69
|
-
<Play height={24} pathFill={
|
|
73
|
+
<Play accessibilityLabel='Play Icon' height={24} pathFill={static_black} width={24} />
|
|
70
74
|
) : (
|
|
71
|
-
<Pause
|
|
75
|
+
<Pause
|
|
76
|
+
accessibilityLabel='Pause Icon'
|
|
77
|
+
height={24}
|
|
78
|
+
pathFill={static_black}
|
|
79
|
+
width={24}
|
|
80
|
+
/>
|
|
72
81
|
)}
|
|
73
82
|
</View>
|
|
74
83
|
</TouchableOpacity>
|
|
75
|
-
<Text
|
|
84
|
+
<Text
|
|
85
|
+
accessibilityLabel='Progress Duration'
|
|
86
|
+
style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
|
|
87
|
+
>
|
|
76
88
|
{progressDuration ? progressDuration : '00:00'}
|
|
77
89
|
</Text>
|
|
78
90
|
<ProgressControl
|
|
79
91
|
duration={duration}
|
|
92
|
+
filledColor={static_white}
|
|
80
93
|
onPlayPause={onPlayPause}
|
|
81
94
|
onProgressDrag={onProgressDrag}
|
|
82
95
|
progress={progress}
|
|
96
|
+
testID={'progress-control'}
|
|
97
|
+
width={180}
|
|
83
98
|
/>
|
|
84
|
-
<Text
|
|
99
|
+
<Text
|
|
100
|
+
accessibilityLabel='Video Duration'
|
|
101
|
+
style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
|
|
102
|
+
>
|
|
85
103
|
{videoDuration ? videoDuration : '00:00'}
|
|
86
104
|
</Text>
|
|
87
105
|
</View>
|
|
@@ -82,7 +82,7 @@ const GridImage = <
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
|
-
<TouchableOpacity onPress={selectAndClose}>
|
|
85
|
+
<TouchableOpacity accessibilityLabel='Grid Image' onPress={selectAndClose}>
|
|
86
86
|
{type === 'video' ? (
|
|
87
87
|
<View style={[styles.image, { height: size, width: size }, gridImage]}>
|
|
88
88
|
<VideoThumbnail />
|
|
@@ -102,26 +102,27 @@ const renderItem = <
|
|
|
102
102
|
item: GridImageItem<StreamChatGenerics>;
|
|
103
103
|
}) => <GridImage item={item} />;
|
|
104
104
|
|
|
105
|
-
type
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
export type ImageGridType<
|
|
106
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
107
|
+
> = ImageGalleryGridImageComponents<StreamChatGenerics> & {
|
|
108
|
+
closeGridView: () => void;
|
|
109
|
+
photos: Photo<StreamChatGenerics>[];
|
|
110
|
+
setImage: React.Dispatch<
|
|
111
|
+
React.SetStateAction<
|
|
112
|
+
| {
|
|
113
|
+
messageId?: string | undefined;
|
|
114
|
+
url?: string | undefined;
|
|
115
|
+
}
|
|
116
|
+
| undefined
|
|
117
|
+
>
|
|
118
|
+
>;
|
|
119
|
+
numberOfImageGalleryGridColumns?: number;
|
|
120
|
+
};
|
|
120
121
|
|
|
121
122
|
export const ImageGrid = <
|
|
122
123
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
123
124
|
>(
|
|
124
|
-
props:
|
|
125
|
+
props: ImageGridType<StreamChatGenerics>,
|
|
125
126
|
) => {
|
|
126
127
|
const {
|
|
127
128
|
avatarComponent,
|
|
@@ -154,6 +155,7 @@ export const ImageGrid = <
|
|
|
154
155
|
|
|
155
156
|
return (
|
|
156
157
|
<BottomSheetFlatList<GridImageItem<StreamChatGenerics>>
|
|
158
|
+
accessibilityLabel='Image Grid'
|
|
157
159
|
contentContainerStyle={[
|
|
158
160
|
styles.contentContainer,
|
|
159
161
|
{ backgroundColor: white },
|
|
@@ -60,7 +60,10 @@ export const ImageGridHandle: React.FC<Props> = (props) => {
|
|
|
60
60
|
const { t } = useTranslationContext();
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
|
-
<View
|
|
63
|
+
<View
|
|
64
|
+
accessibilityLabel='Image Grid Handle'
|
|
65
|
+
style={[styles.handle, { backgroundColor: white }, handle]}
|
|
66
|
+
>
|
|
64
67
|
{leftComponent ? leftComponent({ closeGridView }) : <View style={styles.leftContainer} />}
|
|
65
68
|
{centerComponent ? (
|
|
66
69
|
centerComponent({ closeGridView })
|
|
@@ -342,6 +342,8 @@ const MessageWithContext = <
|
|
|
342
342
|
} else if (cur.type === 'video' && !cur.og_scrape_url) {
|
|
343
343
|
acc.files.push(cur);
|
|
344
344
|
acc.other = []; // remove other attachments if a file exists
|
|
345
|
+
} else if (cur.type === 'audio') {
|
|
346
|
+
acc.files.push(cur);
|
|
345
347
|
} else if (cur.type === 'image' && !cur.title_link && !cur.og_scrape_url) {
|
|
346
348
|
/**
|
|
347
349
|
* this next if is not combined with the above one for cases where we have
|
|
@@ -371,7 +373,6 @@ const MessageWithContext = <
|
|
|
371
373
|
other: [] as Attachment<StreamChatGenerics>[],
|
|
372
374
|
videos: [] as Attachment<StreamChatGenerics>[],
|
|
373
375
|
};
|
|
374
|
-
|
|
375
376
|
/**
|
|
376
377
|
* Check if any actions to prevent long press
|
|
377
378
|
*/
|
|
@@ -188,15 +188,23 @@ describe('MessageContent', () => {
|
|
|
188
188
|
it('renders the FileAttachment component when a file attachment exists', async () => {
|
|
189
189
|
const user = generateUser();
|
|
190
190
|
const message = generateMessage({
|
|
191
|
-
attachments: [
|
|
191
|
+
attachments: [
|
|
192
|
+
{ title: 'file', type: 'file' },
|
|
193
|
+
{ title: 'audio', type: 'audio' },
|
|
194
|
+
{ title: 'video', type: 'video' },
|
|
195
|
+
],
|
|
192
196
|
user,
|
|
193
197
|
});
|
|
194
198
|
|
|
195
|
-
const { getByTestId } = renderMessage({ message });
|
|
199
|
+
const { getByTestId, queryAllByA11yLabel, queryAllByTestId } = renderMessage({ message });
|
|
200
|
+
|
|
201
|
+
const fileAttachments = queryAllByTestId('file-attachment');
|
|
202
|
+
const audioAttachments = queryAllByA11yLabel('audio-attachment-preview');
|
|
196
203
|
|
|
197
204
|
await waitFor(() => {
|
|
198
205
|
expect(getByTestId('message-content-wrapper')).toBeTruthy();
|
|
199
|
-
expect(
|
|
206
|
+
expect(fileAttachments).toHaveLength(1);
|
|
207
|
+
expect(audioAttachments).toHaveLength(1);
|
|
200
208
|
});
|
|
201
209
|
});
|
|
202
210
|
|
|
@@ -22,6 +22,10 @@ describe('parseLinksFromText', () => {
|
|
|
22
22
|
],
|
|
23
23
|
['127.0.0.1/local_(development)_server', '127.0.0.1/local_(development)_server'],
|
|
24
24
|
['https://a.co:8999/ab.php?p=12', 'a.co:8999/ab.php?p=12'],
|
|
25
|
+
[
|
|
26
|
+
'http://help.apple.com/xcode/mac/current/#/devba7f53ad4',
|
|
27
|
+
'help.apple.com/xcode/mac/current/#/devba7f53ad4',
|
|
28
|
+
],
|
|
25
29
|
])('Returns the encoded value of %p as %p', (link, expected) => {
|
|
26
30
|
const result = parseLinksFromText(link);
|
|
27
31
|
|
|
@@ -11,7 +11,7 @@ const schema = `(\\w{2,15}:\\/\\/)`;
|
|
|
11
11
|
// something.tld OR 123.123.123.123
|
|
12
12
|
const domain = `((?:\\w+\\.[a-zA-Z]+)+(?:[^:\\/\\s]+)|(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))`;
|
|
13
13
|
const port = `(:[0-9]{1,5})`;
|
|
14
|
-
const path = `((?:\\/)?[
|
|
14
|
+
const path = `((?:\\/)?[^?\\s]+)`;
|
|
15
15
|
const queryString = `(\\?[^#\\s]+)`;
|
|
16
16
|
const fragment = `(#[\\w_-]+)`;
|
|
17
17
|
|