stream-chat-react-native-core 6.3.1 → 6.4.0-beta.2

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.
Files changed (179) hide show
  1. package/lib/commonjs/components/Attachment/AudioAttachment.js +255 -216
  2. package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +11 -11
  4. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/Gallery.js +9 -0
  6. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  7. package/lib/commonjs/components/ChannelList/ChannelList.js +23 -0
  8. package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
  9. package/lib/commonjs/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js +31 -8
  10. package/lib/commonjs/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js.map +1 -1
  11. package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelMemberUpdated.js +75 -0
  12. package/lib/commonjs/components/ChannelList/hooks/listeners/useChannelMemberUpdated.js.map +1 -0
  13. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +21 -10
  14. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
  15. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js +23 -7
  16. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
  17. package/lib/commonjs/components/ChannelList/hooks/useChannelMembershipState.js +17 -0
  18. package/lib/commonjs/components/ChannelList/hooks/useChannelMembershipState.js.map +1 -0
  19. package/lib/commonjs/components/ChannelList/hooks/useSelectedChannelState.js +32 -0
  20. package/lib/commonjs/components/ChannelList/hooks/useSelectedChannelState.js.map +1 -0
  21. package/lib/commonjs/components/ChannelList/hooks/utils/index.js +102 -0
  22. package/lib/commonjs/components/ChannelList/hooks/utils/index.js.map +1 -0
  23. package/lib/commonjs/components/ChannelList/utils.js +23 -11
  24. package/lib/commonjs/components/ChannelList/utils.js.map +1 -1
  25. package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js +1 -2
  26. package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
  27. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +24 -13
  28. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  29. package/lib/commonjs/components/Message/Message.js.map +1 -1
  30. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +35 -23
  31. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  32. package/lib/commonjs/components/ProgressControl/ProgressControl.js +57 -54
  33. package/lib/commonjs/components/ProgressControl/ProgressControl.js.map +1 -1
  34. package/lib/commonjs/components/ProgressControl/WaveProgressBar.js +52 -52
  35. package/lib/commonjs/components/ProgressControl/WaveProgressBar.js.map +1 -1
  36. package/lib/commonjs/components/index.js +22 -0
  37. package/lib/commonjs/components/index.js.map +1 -1
  38. package/lib/commonjs/contexts/themeContext/utils/theme.js +1 -0
  39. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  40. package/lib/commonjs/hooks/useAudioPlayer.js +158 -0
  41. package/lib/commonjs/hooks/useAudioPlayer.js.map +1 -0
  42. package/lib/commonjs/icons/Archieve.js +33 -0
  43. package/lib/commonjs/icons/Archieve.js.map +1 -0
  44. package/lib/commonjs/icons/Pause.js +2 -2
  45. package/lib/commonjs/icons/Pause.js.map +1 -1
  46. package/lib/commonjs/icons/Play.js +2 -2
  47. package/lib/commonjs/icons/Play.js.map +1 -1
  48. package/lib/commonjs/icons/index.js +11 -0
  49. package/lib/commonjs/icons/index.js.map +1 -1
  50. package/lib/commonjs/native.js.map +1 -1
  51. package/lib/commonjs/types/types.js.map +1 -1
  52. package/lib/commonjs/version.json +1 -1
  53. package/lib/module/components/Attachment/AudioAttachment.js +255 -216
  54. package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
  55. package/lib/module/components/Attachment/FileAttachmentGroup.js +11 -11
  56. package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
  57. package/lib/module/components/Attachment/Gallery.js +9 -0
  58. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  59. package/lib/module/components/ChannelList/ChannelList.js +23 -0
  60. package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
  61. package/lib/module/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js +31 -8
  62. package/lib/module/components/ChannelList/hooks/listeners/useAddedToChannelNotification.js.map +1 -1
  63. package/lib/module/components/ChannelList/hooks/listeners/useChannelMemberUpdated.js +75 -0
  64. package/lib/module/components/ChannelList/hooks/listeners/useChannelMemberUpdated.js.map +1 -0
  65. package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +21 -10
  66. package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
  67. package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js +23 -7
  68. package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
  69. package/lib/module/components/ChannelList/hooks/useChannelMembershipState.js +17 -0
  70. package/lib/module/components/ChannelList/hooks/useChannelMembershipState.js.map +1 -0
  71. package/lib/module/components/ChannelList/hooks/useSelectedChannelState.js +32 -0
  72. package/lib/module/components/ChannelList/hooks/useSelectedChannelState.js.map +1 -0
  73. package/lib/module/components/ChannelList/hooks/utils/index.js +102 -0
  74. package/lib/module/components/ChannelList/hooks/utils/index.js.map +1 -0
  75. package/lib/module/components/ChannelList/utils.js +23 -11
  76. package/lib/module/components/ChannelList/utils.js.map +1 -1
  77. package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js +1 -2
  78. package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
  79. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +24 -13
  80. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  81. package/lib/module/components/Message/Message.js.map +1 -1
  82. package/lib/module/components/MessageInput/FileUploadPreview.js +35 -23
  83. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  84. package/lib/module/components/ProgressControl/ProgressControl.js +57 -54
  85. package/lib/module/components/ProgressControl/ProgressControl.js.map +1 -1
  86. package/lib/module/components/ProgressControl/WaveProgressBar.js +52 -52
  87. package/lib/module/components/ProgressControl/WaveProgressBar.js.map +1 -1
  88. package/lib/module/components/index.js +22 -0
  89. package/lib/module/components/index.js.map +1 -1
  90. package/lib/module/contexts/themeContext/utils/theme.js +1 -0
  91. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  92. package/lib/module/hooks/useAudioPlayer.js +158 -0
  93. package/lib/module/hooks/useAudioPlayer.js.map +1 -0
  94. package/lib/module/icons/Archieve.js +33 -0
  95. package/lib/module/icons/Archieve.js.map +1 -0
  96. package/lib/module/icons/Pause.js +2 -2
  97. package/lib/module/icons/Pause.js.map +1 -1
  98. package/lib/module/icons/Play.js +2 -2
  99. package/lib/module/icons/Play.js.map +1 -1
  100. package/lib/module/icons/index.js +11 -0
  101. package/lib/module/icons/index.js.map +1 -1
  102. package/lib/module/native.js.map +1 -1
  103. package/lib/module/types/types.js.map +1 -1
  104. package/lib/module/version.json +1 -1
  105. package/lib/typescript/components/Attachment/AudioAttachment.d.ts +2 -2
  106. package/lib/typescript/components/Attachment/AudioAttachment.d.ts.map +1 -1
  107. package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts.map +1 -1
  108. package/lib/typescript/components/Attachment/Gallery.d.ts.map +1 -1
  109. package/lib/typescript/components/ChannelList/ChannelList.d.ts +20 -6
  110. package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
  111. package/lib/typescript/components/ChannelList/hooks/listeners/useAddedToChannelNotification.d.ts +4 -3
  112. package/lib/typescript/components/ChannelList/hooks/listeners/useAddedToChannelNotification.d.ts.map +1 -1
  113. package/lib/typescript/components/ChannelList/hooks/listeners/useChannelMemberUpdated.d.ts +12 -0
  114. package/lib/typescript/components/ChannelList/hooks/listeners/useChannelMemberUpdated.d.ts.map +1 -0
  115. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessage.d.ts +4 -3
  116. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessage.d.ts.map +1 -1
  117. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessageNotification.d.ts +4 -3
  118. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessageNotification.d.ts.map +1 -1
  119. package/lib/typescript/components/ChannelList/hooks/useChannelMembershipState.d.ts +5 -0
  120. package/lib/typescript/components/ChannelList/hooks/useChannelMembershipState.d.ts.map +1 -0
  121. package/lib/typescript/components/ChannelList/hooks/useSelectedChannelState.d.ts +13 -0
  122. package/lib/typescript/components/ChannelList/hooks/useSelectedChannelState.d.ts.map +1 -0
  123. package/lib/typescript/components/ChannelList/hooks/utils/index.d.ts +22 -0
  124. package/lib/typescript/components/ChannelList/hooks/utils/index.d.ts.map +1 -0
  125. package/lib/typescript/components/ChannelList/utils.d.ts +10 -4
  126. package/lib/typescript/components/ChannelList/utils.d.ts.map +1 -1
  127. package/lib/typescript/components/ChannelPreview/ChannelPreviewMessenger.d.ts.map +1 -1
  128. package/lib/typescript/components/ImageGallery/components/ImageGalleryVideoControl.d.ts.map +1 -1
  129. package/lib/typescript/components/Message/Message.d.ts +22 -11
  130. package/lib/typescript/components/Message/Message.d.ts.map +1 -1
  131. package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts.map +1 -1
  132. package/lib/typescript/components/ProgressControl/ProgressControl.d.ts +35 -2
  133. package/lib/typescript/components/ProgressControl/ProgressControl.d.ts.map +1 -1
  134. package/lib/typescript/components/ProgressControl/WaveProgressBar.d.ts +27 -0
  135. package/lib/typescript/components/ProgressControl/WaveProgressBar.d.ts.map +1 -1
  136. package/lib/typescript/components/index.d.ts +2 -0
  137. package/lib/typescript/components/index.d.ts.map +1 -1
  138. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +1 -0
  139. package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
  140. package/lib/typescript/hooks/useAudioPlayer.d.ts +16 -0
  141. package/lib/typescript/hooks/useAudioPlayer.d.ts.map +1 -0
  142. package/lib/typescript/icons/Archieve.d.ts +4 -0
  143. package/lib/typescript/icons/Archieve.d.ts.map +1 -0
  144. package/lib/typescript/icons/Pause.d.ts.map +1 -1
  145. package/lib/typescript/icons/index.d.ts +1 -0
  146. package/lib/typescript/icons/index.d.ts.map +1 -1
  147. package/lib/typescript/native.d.ts +10 -3
  148. package/lib/typescript/native.d.ts.map +1 -1
  149. package/lib/typescript/types/types.d.ts +5 -1
  150. package/lib/typescript/types/types.d.ts.map +1 -1
  151. package/package.json +4 -2
  152. package/src/components/Attachment/AudioAttachment.tsx +173 -137
  153. package/src/components/Attachment/FileAttachmentGroup.tsx +9 -16
  154. package/src/components/Attachment/Gallery.tsx +3 -0
  155. package/src/components/ChannelList/ChannelList.tsx +38 -3
  156. package/src/components/ChannelList/hooks/listeners/useAddedToChannelNotification.ts +32 -3
  157. package/src/components/ChannelList/hooks/listeners/useChannelMemberUpdated.ts +116 -0
  158. package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +46 -17
  159. package/src/components/ChannelList/hooks/listeners/useNewMessageNotification.ts +18 -3
  160. package/src/components/ChannelList/hooks/useChannelMembershipState.ts +22 -0
  161. package/src/components/ChannelList/hooks/useSelectedChannelState.ts +57 -0
  162. package/src/components/ChannelList/hooks/utils/index.ts +130 -0
  163. package/src/components/ChannelList/utils.ts +50 -14
  164. package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx +1 -2
  165. package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +23 -13
  166. package/src/components/Message/Message.tsx +26 -4
  167. package/src/components/MessageInput/FileUploadPreview.tsx +29 -28
  168. package/src/components/ProgressControl/ProgressControl.tsx +115 -92
  169. package/src/components/ProgressControl/WaveProgressBar.tsx +96 -59
  170. package/src/components/index.ts +2 -0
  171. package/src/contexts/themeContext/utils/theme.ts +2 -0
  172. package/src/hooks/useAudioPlayer.ts +59 -0
  173. package/src/icons/Archieve.tsx +10 -0
  174. package/src/icons/Pause.tsx +2 -5
  175. package/src/icons/Play.tsx +2 -2
  176. package/src/icons/index.ts +1 -0
  177. package/src/native.ts +11 -3
  178. package/src/types/types.ts +14 -1
  179. package/src/version.json +1 -1
@@ -1,22 +1,50 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { Platform, Pressable, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
4
  import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
5
5
 
6
6
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
7
- import { triggerHaptic } from '../../native';
8
7
  import { resampleWaveformData } from '../MessageInput/utils/audioSampling';
9
8
 
10
9
  export type WaveProgressBarProps = {
10
+ /**
11
+ * The progress of the waveform in percentage
12
+ */
11
13
  progress: number;
14
+ /**
15
+ * The waveform data to be displayed
16
+ */
12
17
  waveformData: number[];
18
+ /**
19
+ * The number of amplitudes to display
20
+ */
13
21
  amplitudesCount?: number;
22
+ /**
23
+ * The color of the filled waveform
24
+ */
14
25
  filledColor?: string;
26
+ /**
27
+ * The function to be called when the user ends dragging the waveform
28
+ */
29
+ onEndDrag?: (progress: number) => void;
30
+ /**
31
+ * The function to be called when the user plays or pauses the audio
32
+ * @deprecated Use onStartDrag and onEndDrag instead
33
+ */
15
34
  onPlayPause?: (status?: boolean) => void;
35
+ /**
36
+ * The function to be called when the user is dragging the waveform
37
+ */
16
38
  onProgressDrag?: (progress: number) => void;
39
+ /**
40
+ * The function to be called when the user starts dragging the waveform
41
+ */
42
+ onStartDrag?: (progress: number) => void;
17
43
  };
18
44
 
19
45
  const WAVEFORM_WIDTH = 2;
46
+ const WAVE_MAX_HEIGHT = 25;
47
+ const WAVE_MIN_HEIGHT = 3;
20
48
 
21
49
  const ProgressControlThumb = ({ style }: { style?: StyleProp<ViewStyle> }) => {
22
50
  const {
@@ -43,61 +71,65 @@ const ProgressControlThumb = ({ style }: { style?: StyleProp<ViewStyle> }) => {
43
71
 
44
72
  export const WaveProgressBar = React.memo(
45
73
  (props: WaveProgressBarProps) => {
46
- const [endPosition, setEndPosition] = useState(0);
47
- const [currentWaveformProgress, setCurrentWaveformProgress] = useState(0);
48
74
  /* On Android, the seek doesn't work for AAC files, hence we disable progress drag for now */
49
75
  const showProgressDrag = Platform.OS === 'ios';
50
76
  const {
51
77
  amplitudesCount = 70,
52
78
  filledColor,
79
+ onEndDrag,
53
80
  onPlayPause,
54
81
  onProgressDrag,
82
+ onStartDrag,
55
83
  progress,
56
84
  waveformData,
57
85
  } = props;
86
+ const eachWaveformWidth = WAVEFORM_WIDTH * 2;
87
+ const fullWidth = (amplitudesCount - 1) * eachWaveformWidth;
88
+ const state = useSharedValue(progress);
89
+ const [currentWaveformProgress, setCurrentWaveformProgress] = useState<number>(0);
90
+
91
+ const waveFormNumberFromProgress = useCallback(
92
+ (progress: number) => {
93
+ 'worklet';
94
+ const progressInPrecision = Number(progress.toFixed(2));
95
+ const progressInWaveformWidth = Number((progressInPrecision * fullWidth).toFixed(0));
96
+ const progressInWaveformNumber = Math.floor(progressInWaveformWidth / 4);
97
+ runOnJS(setCurrentWaveformProgress)(progressInWaveformNumber);
98
+ },
99
+ [fullWidth],
100
+ );
101
+
102
+ useEffect(() => {
103
+ waveFormNumberFromProgress(progress);
104
+ }, [progress, waveFormNumberFromProgress]);
105
+
58
106
  const {
59
107
  theme: {
60
108
  colors: { accent_blue, grey_dark },
61
109
  waveProgressBar: { container, thumb, waveform: waveformTheme },
62
110
  },
63
111
  } = useTheme();
64
- const state = useSharedValue(0);
65
112
 
66
113
  const pan = Gesture.Pan()
67
114
  .maxPointers(1)
68
- .onStart(() => {
115
+ .onStart((event) => {
116
+ const currentProgress = (state.value + event.x) / fullWidth;
117
+ state.value = Math.max(0, Math.min(currentProgress, 1));
118
+ if (onStartDrag) runOnJS(onStartDrag)(state.value);
69
119
  if (onPlayPause) runOnJS(onPlayPause)(true);
70
- state.value = endPosition;
71
120
  })
72
- .onChange((event) => {
73
- const stage = Math.floor((endPosition + event.translationX) / (WAVEFORM_WIDTH * 2));
74
- runOnJS(setCurrentWaveformProgress)(stage);
75
- state.value = stage * (WAVEFORM_WIDTH * 2);
76
- if (state.value < 0) {
77
- state.value = 0;
78
- } else if (state.value > amplitudesCount * (WAVEFORM_WIDTH * 2)) {
79
- state.value = (amplitudesCount - 1) * (WAVEFORM_WIDTH * 2);
80
- } else {
81
- runOnJS(triggerHaptic)('impactLight');
82
- }
121
+ .onUpdate((event) => {
122
+ const currentProgress = (state.value + event.x) / fullWidth;
123
+ state.value = Math.max(0, Math.min(currentProgress, 1));
124
+ if (onProgressDrag) runOnJS(onProgressDrag)(state.value);
83
125
  })
84
- .onEnd(() => {
85
- const stage = Math.floor(state.value / (WAVEFORM_WIDTH * 2));
86
- runOnJS(setEndPosition)(state.value);
87
- if (onProgressDrag) runOnJS(onProgressDrag)(stage);
126
+ .onEnd((event) => {
127
+ const currentProgress = (state.value + event.x) / fullWidth;
128
+ state.value = Math.max(0, Math.min(currentProgress, 1));
129
+ if (onEndDrag) runOnJS(onEndDrag)(state.value);
88
130
  if (onPlayPause) runOnJS(onPlayPause)(false);
89
131
  });
90
132
 
91
- useEffect(() => {
92
- const stageProgress = Math.floor(
93
- progress * (showProgressDrag ? amplitudesCount - 1 : amplitudesCount),
94
- );
95
- state.value = stageProgress * (WAVEFORM_WIDTH * 2);
96
- setEndPosition(state.value);
97
- setCurrentWaveformProgress(stageProgress);
98
- // eslint-disable-next-line react-hooks/exhaustive-deps
99
- }, [progress]);
100
-
101
133
  const stringifiedWaveformData = waveformData.toString();
102
134
 
103
135
  const resampledWaveformData = useMemo(
@@ -106,35 +138,41 @@ export const WaveProgressBar = React.memo(
106
138
  [amplitudesCount, stringifiedWaveformData],
107
139
  );
108
140
 
109
- const thumbStyles = useAnimatedStyle(() => ({
110
- position: 'absolute',
111
- transform: [{ translateX: state.value }],
112
- }));
141
+ const thumbStyles = useAnimatedStyle(
142
+ () => ({
143
+ position: 'absolute',
144
+ transform: [{ translateX: currentWaveformProgress * eachWaveformWidth }],
145
+ }),
146
+ [currentWaveformProgress, fullWidth],
147
+ );
113
148
 
114
149
  return (
115
- <View style={[styles.container, container]}>
116
- {resampledWaveformData.map((waveform, index) => (
117
- <View
118
- key={index}
119
- style={[
120
- styles.waveform,
121
- {
122
- backgroundColor:
123
- index < currentWaveformProgress ? filledColor || accent_blue : grey_dark,
124
- height: waveform * 25 > 3 ? waveform * 25 : 3,
125
- },
126
- waveformTheme,
127
- ]}
128
- />
129
- ))}
130
- {showProgressDrag && onProgressDrag && (
131
- <GestureDetector gesture={pan}>
150
+ <GestureDetector gesture={pan}>
151
+ <View style={[styles.container, container]}>
152
+ {resampledWaveformData.map((waveform, index) => (
153
+ <Animated.View
154
+ key={index}
155
+ style={[
156
+ styles.waveform,
157
+ {
158
+ backgroundColor:
159
+ index < currentWaveformProgress ? filledColor || accent_blue : grey_dark,
160
+ height:
161
+ waveform * WAVE_MAX_HEIGHT > WAVE_MIN_HEIGHT
162
+ ? waveform * WAVE_MAX_HEIGHT
163
+ : WAVE_MIN_HEIGHT,
164
+ },
165
+ waveformTheme,
166
+ ]}
167
+ />
168
+ ))}
169
+ {showProgressDrag && (onEndDrag || onProgressDrag) && (
132
170
  <Animated.View style={[thumbStyles, thumb]}>
133
171
  <ProgressControlThumb />
134
172
  </Animated.View>
135
- </GestureDetector>
136
- )}
137
- </View>
173
+ )}
174
+ </View>
175
+ </GestureDetector>
138
176
  );
139
177
  },
140
178
  (prevProps, nextProps) => {
@@ -147,14 +185,13 @@ export const WaveProgressBar = React.memo(
147
185
  const styles = StyleSheet.create({
148
186
  container: {
149
187
  alignItems: 'center',
150
- alignSelf: 'center',
151
188
  flexDirection: 'row',
152
189
  },
153
190
  progressControlThumbStyle: {
154
191
  borderRadius: 5,
155
192
  borderWidth: 0.2,
156
193
  elevation: 6,
157
- height: 25,
194
+ height: 28,
158
195
  shadowOffset: {
159
196
  height: 3,
160
197
  width: 0,
@@ -166,7 +203,7 @@ const styles = StyleSheet.create({
166
203
  waveform: {
167
204
  alignSelf: 'center',
168
205
  borderRadius: 2,
169
- marginHorizontal: WAVEFORM_WIDTH / 2,
206
+ marginRight: WAVEFORM_WIDTH,
170
207
  width: WAVEFORM_WIDTH,
171
208
  },
172
209
  });
@@ -47,6 +47,7 @@ export * from './ChannelList/ChannelListMessenger';
47
47
  export * from './ChannelList/hooks/listeners/useAddedToChannelNotification';
48
48
  export * from './ChannelList/hooks/listeners/useChannelDeleted';
49
49
  export * from './ChannelList/hooks/listeners/useChannelHidden';
50
+ export * from './ChannelList/hooks/listeners/useChannelMemberUpdated';
50
51
  export * from './ChannelList/hooks/listeners/useChannelTruncated';
51
52
  export * from './ChannelList/hooks/listeners/useChannelUpdated';
52
53
  export * from './ChannelList/hooks/listeners/useNewMessage';
@@ -55,6 +56,7 @@ export * from './ChannelList/hooks/listeners/useRemovedFromChannelNotification';
55
56
  export * from './ChannelList/hooks/listeners/useUserPresence';
56
57
  export * from './ChannelList/hooks/useCreateChannelsContext';
57
58
  export * from './ChannelList/hooks/usePaginatedChannels';
59
+ export * from './ChannelList/hooks/useChannelMembershipState';
58
60
  export * from './ChannelList/Skeleton';
59
61
 
60
62
  export * from './ChannelPreview/ChannelAvatar';
@@ -236,6 +236,7 @@ export type Theme = {
236
236
  };
237
237
  videoControl: {
238
238
  durationTextStyle: TextStyle;
239
+ progressDurationText: TextStyle;
239
240
  roundedView: ViewStyle;
240
241
  videoContainer: ViewStyle;
241
242
  };
@@ -1007,6 +1008,7 @@ export const defaultTheme: Theme = {
1007
1008
  },
1008
1009
  videoControl: {
1009
1010
  durationTextStyle: {},
1011
+ progressDurationText: {},
1010
1012
  roundedView: {},
1011
1013
  videoContainer: {},
1012
1014
  },
@@ -0,0 +1,59 @@
1
+ import { SDK, SoundReturnType } from '../native';
2
+
3
+ export type UseSoundPlayerProps = {
4
+ soundRef: React.MutableRefObject<SoundReturnType | null>;
5
+ };
6
+
7
+ /**
8
+ * This hook is used to play, pause, seek and change audio speed.
9
+ * It handles both Expo CLI and Native CLI.
10
+ */
11
+ export const useAudioPlayer = (props: UseSoundPlayerProps) => {
12
+ const { soundRef } = props;
13
+
14
+ const isExpoCLI = SDK === 'stream-chat-expo';
15
+
16
+ const playAudio = async () => {
17
+ if (isExpoCLI) {
18
+ if (soundRef.current?.playAsync) await soundRef.current.playAsync();
19
+ } else {
20
+ if (soundRef.current?.resume) soundRef.current.resume();
21
+ }
22
+ };
23
+
24
+ const pauseAudio = async () => {
25
+ if (isExpoCLI) {
26
+ if (soundRef.current?.pauseAsync) await soundRef.current.pauseAsync();
27
+ } else {
28
+ if (soundRef.current?.pause) soundRef.current.pause();
29
+ }
30
+ };
31
+
32
+ const seekAudio = async (currentTime: number) => {
33
+ if (isExpoCLI) {
34
+ if (currentTime === 0) {
35
+ // If currentTime is 0, we should replay the video from 0th position.
36
+ if (soundRef.current?.replayAsync) {
37
+ await soundRef.current.replayAsync({
38
+ positionMillis: 0,
39
+ shouldPlay: false,
40
+ });
41
+ }
42
+ } else {
43
+ if (soundRef.current?.setPositionAsync) {
44
+ await soundRef.current.setPositionAsync(currentTime * 1000);
45
+ }
46
+ }
47
+ } else {
48
+ if (soundRef.current?.seek) soundRef.current.seek(currentTime);
49
+ }
50
+ };
51
+
52
+ const changeAudioSpeed = async (speed: number) => {
53
+ // Handled through prop `rate` in `Sound.Player`
54
+ if (!isExpoCLI) return;
55
+ if (soundRef.current?.setRateAsync) await soundRef.current.setRateAsync(speed);
56
+ };
57
+
58
+ return { changeAudioSpeed, pauseAudio, playAudio, seekAudio };
59
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import Svg, { Path } from 'react-native-svg';
3
+
4
+ import { IconProps } from './utils/base';
5
+
6
+ export const Archieve: React.FC<IconProps> = ({ height = 512, width = 512, ...rest }) => (
7
+ <Svg height={height} viewBox={'0 0 512 512'} width={width} {...rest}>
8
+ <Path d='M32 32l448 0c17.7 0 32 14.3 32 32l0 32c0 17.7-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96L0 64C0 46.3 14.3 32 32 32zm0 128l448 0 0 256c0 35.3-28.7 64-64 64L96 480c-35.3 0-64-28.7-64-64l0-256zm128 80c0 8.8 7.2 16 16 16l160 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-160 0c-8.8 0-16 7.2-16 16z' />
9
+ </Svg>
10
+ );
@@ -6,10 +6,7 @@ import { IconProps } from './utils/base';
6
6
  type Props = IconProps;
7
7
 
8
8
  export const Pause = ({ height, width, ...rest }: Props) => (
9
- <Svg height={height} viewBox={`0 0 ${height} ${width}`} width={width} {...rest}>
10
- <Path
11
- d='M8 25.3333H13.3333V6.66663H8V25.3333ZM18.6667 6.66663V25.3333H24V6.66663H18.6667Z'
12
- {...rest}
13
- />
9
+ <Svg height={height} viewBox={`0 0 24 24`} width={width} {...rest}>
10
+ <Path d='M6 19H10V5H6V19ZM14 5V19H18V5H14Z' {...rest} />
14
11
  </Svg>
15
12
  );
@@ -7,7 +7,7 @@ import { IconProps } from './utils/base';
7
7
  type Props = IconProps;
8
8
 
9
9
  export const Play = ({ height, width, ...rest }: Props) => (
10
- <Svg height={height} viewBox={`0 0 ${height} ${width}`} width={width} {...rest}>
11
- <Path d='M8.66602 6.66663V25.3333L23.3327 16L8.66602 6.66663Z' {...rest} />
10
+ <Svg height={height} viewBox={`0 0 24 24`} width={width} {...rest}>
11
+ <Path d='M6.5 5V19L17.5 12L6.5 5Z' {...rest} />
12
12
  </Svg>
13
13
  );
@@ -1,5 +1,6 @@
1
1
  export * from './utils/base';
2
2
 
3
+ export * from './Archieve';
3
4
  export * from './ArrowRight';
4
5
  export * from './ArrowLeft';
5
6
  export * from './ArrowUp';
package/src/native.ts CHANGED
@@ -114,6 +114,7 @@ export type PlaybackStatus = {
114
114
  isLooping: boolean;
115
115
  isMuted: boolean;
116
116
  isPlaying: boolean;
117
+ isSeeking: boolean;
117
118
  positionMillis: number;
118
119
  shouldPlay: boolean;
119
120
  };
@@ -141,7 +142,6 @@ export type SoundOptions = {
141
142
  };
142
143
 
143
144
  export type SoundReturnType = {
144
- paused: boolean;
145
145
  testID: string;
146
146
  getDuration?: () => number;
147
147
  isPlaying?: () => boolean;
@@ -149,18 +149,21 @@ export type SoundReturnType = {
149
149
  onEnd?: () => void;
150
150
  onLoad?: (payload: VideoPayloadData) => void;
151
151
  onLoadStart?: () => void;
152
+ onPlaybackStateChanged?: (playbackState: PlaybackStatus) => void;
152
153
  onPlaybackStatusUpdate?: (playbackStatus: PlaybackStatus) => void;
153
154
  onProgress?: (data: VideoProgressData) => void;
154
155
  onReadyForDisplay?: () => void;
156
+ onSeek?: (seekResponse: VideoSeekResponse) => void;
155
157
  pause?: () => void;
156
158
  pauseAsync?: () => void;
159
+ paused?: boolean;
157
160
  play?: () => void;
158
161
  playAsync?: () => void;
159
162
  rate?: number;
160
- replayAsync?: () => void;
163
+ replayAsync?: (status: Partial<AVPlaybackStatusToSet>) => void;
161
164
  resizeMode?: string;
162
165
  resume?: () => void;
163
- seek?: (progress: number) => void;
166
+ seek?: (progress: number, tolerance?: number) => void;
164
167
  setPositionAsync?: (millis: number) => void;
165
168
  setProgressUpdateIntervalAsync?: (progressUpdateIntervalMillis: number) => void;
166
169
  setRateAsync?: (rate: number) => void;
@@ -241,6 +244,11 @@ export let Audio: AudioType | undefined;
241
244
 
242
245
  export let Sound: SoundType;
243
246
 
247
+ export type VideoSeekResponse = {
248
+ currentTime: number;
249
+ seekTime: number;
250
+ };
251
+
244
252
  export type VideoProgressData = {
245
253
  currentTime: number;
246
254
  seekableDuration: number;
@@ -1,4 +1,10 @@
1
- import type { ChannelState, ExtendableGenerics, LiteralStringForUnion } from 'stream-chat';
1
+ import type {
2
+ ChannelFilters,
3
+ ChannelSort,
4
+ ChannelState,
5
+ ExtendableGenerics,
6
+ LiteralStringForUnion,
7
+ } from 'stream-chat';
2
8
 
3
9
  import type { FileStateValue } from '../utils/utils';
4
10
 
@@ -97,6 +103,13 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics {
97
103
  userType: DefaultUserType;
98
104
  }
99
105
 
106
+ export type ChannelListEventListenerOptions<
107
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
108
+ > = {
109
+ filters?: ChannelFilters<StreamChatGenerics>;
110
+ sort?: ChannelSort<StreamChatGenerics>;
111
+ };
112
+
100
113
  export type UnknownType = Record<string, unknown>;
101
114
 
102
115
  export type ValueOf<T> = T[keyof T];
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "6.3.1"
2
+ "version": "6.4.0-beta.2"
3
3
  }