stream-chat-react-native-core 4.6.0 → 4.7.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/Attachment.js +22 -13
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +72 -37
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/VideoThumbnail.js +83 -0
- package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -0
- package/lib/commonjs/components/Attachment/hooks/useGoToURL.js +1 -1
- package/lib/commonjs/components/Attachment/hooks/useGoToURL.js.map +1 -1
- package/lib/commonjs/components/Attachment/utils/buildGallery/buildThumbnail.js +1 -0
- package/lib/commonjs/components/Attachment/utils/buildGallery/buildThumbnail.js.map +1 -1
- package/lib/commonjs/components/Attachment/utils/getAspectRatio.js +5 -5
- package/lib/commonjs/components/Attachment/utils/getAspectRatio.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +19 -14
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +4 -2
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +43 -28
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +167 -345
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js +4 -4
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +225 -0
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -0
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +102 -40
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +145 -0
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -0
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +31 -34
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ProgressControl.js +153 -0
- package/lib/commonjs/components/ImageGallery/components/ProgressControl.js.map +1 -0
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js +373 -0
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -0
- package/lib/commonjs/components/Message/Message.js +23 -13
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +58 -33
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js +4 -2
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +25 -23
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +32 -12
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/components/Spinner/Spinner.js +12 -4
- package/lib/commonjs/components/Spinner/Spinner.js.map +1 -1
- package/lib/commonjs/components/index.js +26 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js +2 -2
- package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +10 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/icons/Pause.js +61 -0
- package/lib/commonjs/icons/Pause.js.map +1 -0
- package/lib/commonjs/icons/Play.js +42 -0
- package/lib/commonjs/icons/Play.js.map +1 -0
- package/lib/commonjs/icons/index.js +26 -0
- package/lib/commonjs/icons/index.js.map +1 -1
- package/lib/commonjs/mock-builders/api/queryMembers.js +98 -1
- package/lib/commonjs/mock-builders/api/queryMembers.js.map +1 -1
- package/lib/commonjs/native.js +7 -1
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/utils/getUrlOfImageAttachment.js +1 -1
- package/lib/commonjs/utils/getUrlOfImageAttachment.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +22 -13
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +72 -37
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/VideoThumbnail.js +83 -0
- package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -0
- package/lib/module/components/Attachment/hooks/useGoToURL.js +1 -1
- package/lib/module/components/Attachment/hooks/useGoToURL.js.map +1 -1
- package/lib/module/components/Attachment/utils/buildGallery/buildThumbnail.js +1 -0
- package/lib/module/components/Attachment/utils/buildGallery/buildThumbnail.js.map +1 -1
- package/lib/module/components/Attachment/utils/getAspectRatio.js +5 -5
- package/lib/module/components/Attachment/utils/getAspectRatio.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +19 -14
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +4 -2
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +43 -28
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +167 -345
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js +4 -4
- package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +225 -0
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -0
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +102 -40
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +145 -0
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -0
- package/lib/module/components/ImageGallery/components/ImageGrid.js +31 -34
- package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ProgressControl.js +153 -0
- package/lib/module/components/ImageGallery/components/ProgressControl.js.map +1 -0
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js +373 -0
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -0
- package/lib/module/components/Message/Message.js +23 -13
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +58 -33
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/components/Message/hooks/useCreateMessageContext.js +4 -2
- package/lib/module/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +25 -23
- package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +32 -12
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/components/Spinner/Spinner.js +12 -4
- package/lib/module/components/Spinner/Spinner.js.map +1 -1
- package/lib/module/components/index.js +26 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js +2 -2
- package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +10 -1
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/icons/Pause.js +61 -0
- package/lib/module/icons/Pause.js.map +1 -0
- package/lib/module/icons/Play.js +42 -0
- package/lib/module/icons/Play.js.map +1 -0
- package/lib/module/icons/index.js +26 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/mock-builders/api/queryMembers.js +98 -1
- package/lib/module/mock-builders/api/queryMembers.js.map +1 -1
- package/lib/module/native.js +7 -1
- package/lib/module/native.js.map +1 -1
- package/lib/module/utils/getUrlOfImageAttachment.js +1 -1
- package/lib/module/utils/getUrlOfImageAttachment.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Gallery.d.ts +1 -1
- package/lib/typescript/components/Attachment/VideoThumbnail.d.ts +4 -0
- package/lib/typescript/components/Attachment/utils/buildGallery/types.d.ts +1 -0
- package/lib/typescript/components/Attachment/utils/getAspectRatio.d.ts +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.d.ts +1 -0
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewDisplayName.d.ts +4 -4
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +2 -0
- package/lib/typescript/components/ImageGallery/components/AnimatedGalleryVideo.d.ts +27 -0
- package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +18 -2
- package/lib/typescript/components/ImageGallery/components/ImageGalleryVideoControl.d.ts +3 -0
- package/lib/typescript/components/ImageGallery/components/ProgressControl.d.ts +5 -0
- package/lib/typescript/components/ImageGallery/hooks/useImageGalleryGestures.d.ts +36 -0
- package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts +1 -1
- package/lib/typescript/components/Spinner/Spinner.d.ts +7 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +3 -1
- package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +1 -0
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +9 -0
- package/lib/typescript/icons/Pause.d.ts +3 -0
- package/lib/typescript/icons/Play.d.ts +3 -0
- package/lib/typescript/icons/index.d.ts +2 -0
- package/lib/typescript/mock-builders/api/queryMembers.d.ts +161 -0
- package/lib/typescript/mock-builders/api/utils.d.ts +7 -0
- package/lib/typescript/mock-builders/generator/user.d.ts +30 -0
- package/lib/typescript/mock-builders/mock.d.ts +3 -0
- package/lib/typescript/native.d.ts +66 -1
- package/package.json +1 -1
- package/src/components/Attachment/Attachment.tsx +11 -7
- package/src/components/Attachment/Gallery.tsx +75 -36
- package/src/components/Attachment/VideoThumbnail.tsx +45 -0
- package/src/components/Attachment/hooks/useGoToURL.ts +1 -1
- package/src/components/Attachment/utils/buildGallery/buildThumbnail.ts +1 -0
- package/src/components/Attachment/utils/buildGallery/types.ts +1 -0
- package/src/components/Attachment/utils/getAspectRatio.ts +7 -5
- package/src/components/Channel/Channel.tsx +4 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx +83 -0
- package/src/components/ChannelPreview/hooks/useChannelPreviewDisplayName.ts +43 -26
- package/src/components/ImageGallery/ImageGallery.tsx +145 -667
- package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx +4 -4
- package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +224 -0
- package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +114 -19
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +103 -0
- package/src/components/ImageGallery/components/ImageGrid.tsx +12 -25
- package/src/components/ImageGallery/components/ProgressControl.tsx +107 -0
- package/src/components/ImageGallery/hooks/useImageGalleryGestures.tsx +722 -0
- package/src/components/Message/Message.tsx +10 -3
- package/src/components/Message/MessageSimple/MessageContent.tsx +50 -16
- package/src/components/Message/hooks/useCreateMessageContext.ts +2 -0
- package/src/components/MessageOverlay/MessageOverlay.tsx +2 -0
- package/src/components/Reply/Reply.tsx +36 -23
- package/src/components/Spinner/Spinner.tsx +11 -4
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +0 -12
- package/src/components/index.ts +2 -0
- package/src/contexts/messageContext/MessageContext.tsx +2 -0
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +1 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +2 -0
- package/src/contexts/themeContext/utils/theme.ts +18 -0
- package/src/icons/Pause.tsx +14 -0
- package/src/icons/Play.tsx +17 -0
- package/src/icons/index.ts +2 -0
- package/src/mock-builders/api/queryMembers.js +98 -0
- package/src/native.ts +59 -1
- package/src/utils/getUrlOfImageAttachment.ts +1 -1
- package/src/version.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { PanGestureHandler } from 'react-native-gesture-handler';
|
|
4
|
+
import Animated, {
|
|
5
|
+
cancelAnimation,
|
|
6
|
+
runOnJS,
|
|
7
|
+
useAnimatedGestureHandler,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useSharedValue,
|
|
10
|
+
} from 'react-native-reanimated';
|
|
11
|
+
|
|
12
|
+
import type { ImageGalleryFooterVideoControlProps } from './ImageGalleryFooter';
|
|
13
|
+
|
|
14
|
+
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
|
|
15
|
+
|
|
16
|
+
type ProgressControlProps = Pick<
|
|
17
|
+
ImageGalleryFooterVideoControlProps,
|
|
18
|
+
'duration' | 'onPlayPause' | 'onProgressDrag' | 'progress'
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
const width = 180;
|
|
22
|
+
const height = 2;
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
containerStyle: {
|
|
25
|
+
borderRadius: 50,
|
|
26
|
+
height,
|
|
27
|
+
width,
|
|
28
|
+
},
|
|
29
|
+
innerStyle: {
|
|
30
|
+
height,
|
|
31
|
+
},
|
|
32
|
+
progressControlThumbStyle: {
|
|
33
|
+
backgroundColor: '#fff',
|
|
34
|
+
borderRadius: 5,
|
|
35
|
+
height: 20,
|
|
36
|
+
top: -11,
|
|
37
|
+
width: 4,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const ProgressControlThumb = () => <View style={styles.progressControlThumbStyle} />;
|
|
42
|
+
|
|
43
|
+
export const ProgressControl: React.FC<ProgressControlProps> = React.memo(
|
|
44
|
+
(props) => {
|
|
45
|
+
const { duration, onPlayPause, onProgressDrag, progress } = props;
|
|
46
|
+
const {
|
|
47
|
+
theme: {
|
|
48
|
+
colors: { grey_dark, white_snow },
|
|
49
|
+
},
|
|
50
|
+
} = useTheme();
|
|
51
|
+
|
|
52
|
+
const state = useSharedValue(0);
|
|
53
|
+
const translateX = useSharedValue(0);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
state.value = progress * width;
|
|
57
|
+
translateX.value = progress * width;
|
|
58
|
+
}, [progress]);
|
|
59
|
+
|
|
60
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
61
|
+
backgroundColor: white_snow,
|
|
62
|
+
width: state.value,
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
const thumbStyles = useAnimatedStyle(() => ({
|
|
66
|
+
transform: [{ translateX: state.value }],
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
const onGestureEvent = useAnimatedGestureHandler(
|
|
70
|
+
{
|
|
71
|
+
onActive: (event) => {
|
|
72
|
+
state.value = translateX.value + event.translationX;
|
|
73
|
+
if (state.value > width) state.value = width;
|
|
74
|
+
else if (state.value < 0) state.value = 0;
|
|
75
|
+
},
|
|
76
|
+
onFinish: () => {
|
|
77
|
+
translateX.value = state.value;
|
|
78
|
+
const dragFinishLocationInSeconds = (state.value / width) * duration;
|
|
79
|
+
runOnJS(onProgressDrag)(dragFinishLocationInSeconds);
|
|
80
|
+
runOnJS(onPlayPause)();
|
|
81
|
+
},
|
|
82
|
+
onStart: () => {
|
|
83
|
+
runOnJS(onPlayPause)();
|
|
84
|
+
cancelAnimation(translateX);
|
|
85
|
+
state.value = translateX.value;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
[duration],
|
|
89
|
+
);
|
|
90
|
+
return (
|
|
91
|
+
<View style={[styles.containerStyle, { backgroundColor: grey_dark }]}>
|
|
92
|
+
<Animated.View style={[styles.innerStyle, animatedStyles]} />
|
|
93
|
+
|
|
94
|
+
<PanGestureHandler maxPointers={1} onGestureEvent={onGestureEvent}>
|
|
95
|
+
<Animated.View style={[thumbStyles]}>
|
|
96
|
+
<ProgressControlThumb />
|
|
97
|
+
</Animated.View>
|
|
98
|
+
</PanGestureHandler>
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
(prevProps, nextProps) => {
|
|
103
|
+
if (prevProps.duration === nextProps.duration && prevProps.progress === nextProps.progress)
|
|
104
|
+
return true;
|
|
105
|
+
else return false;
|
|
106
|
+
},
|
|
107
|
+
);
|