stream-chat-react-native-core 4.12.0-beta.2 → 4.12.0-beta.5
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/{MessageInput/AudioAttachmentUploadPreview.js → Attachment/AudioAttachment.js} +38 -64
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +132 -12
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +22 -18
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/VideoThumbnail.js +12 -6
- package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +18 -18
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +11 -10
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +38 -44
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +14 -13
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/commonjs/components/index.js +13 -13
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.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 +2 -2
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/{MessageInput/AudioAttachmentUploadPreview.js → Attachment/AudioAttachment.js} +38 -64
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/module/components/Attachment/FileAttachmentGroup.js +132 -12
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +22 -18
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/VideoThumbnail.js +12 -6
- package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +18 -18
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +11 -10
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +38 -44
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +14 -13
- package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/module/components/index.js +13 -13
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.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 +2 -2
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +23 -0
- package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -4
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +3 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/{MessageInput/AudioAttachmentUploadPreview.tsx → Attachment/AudioAttachment.tsx} +82 -131
- package/src/components/Attachment/FileAttachmentGroup.tsx +119 -9
- package/src/components/Attachment/Gallery.tsx +7 -1
- package/src/components/Attachment/VideoThumbnail.tsx +3 -2
- package/src/components/Channel/Channel.tsx +4 -3
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +0 -2
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +12 -7
- package/src/components/Message/MessageSimple/__tests__/MessageContent.test.js +4 -2
- package/src/components/MessageInput/FileUploadPreview.tsx +34 -26
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +15 -8
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +15 -8
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +5 -5
- package/src/components/MessageOverlay/MessageOverlay.tsx +1 -0
- package/src/components/index.ts +1 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +0 -6
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +0 -2
- package/src/contexts/messagesContext/MessagesContext.tsx +3 -0
- package/src/contexts/themeContext/utils/theme.ts +4 -4
- package/src/version.json +1 -1
- package/lib/commonjs/components/MessageInput/AudioAttachmentUploadPreview.js.map +0 -1
- package/lib/module/components/MessageInput/AudioAttachmentUploadPreview.js.map +0 -1
- package/lib/typescript/components/MessageInput/AudioAttachmentUploadPreview.d.ts +0 -26
|
@@ -53,7 +53,7 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
|
|
|
53
53
|
|
|
54
54
|
const {
|
|
55
55
|
theme: {
|
|
56
|
-
colors: {
|
|
56
|
+
colors: { static_black, static_white },
|
|
57
57
|
imageGallery: {
|
|
58
58
|
videoControl: { durationTextStyle, roundedView, videoContainer },
|
|
59
59
|
},
|
|
@@ -68,23 +68,28 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
|
|
|
68
68
|
onPlayPause();
|
|
69
69
|
}}
|
|
70
70
|
>
|
|
71
|
-
<View style={[styles.roundedView, roundedView, { backgroundColor:
|
|
71
|
+
<View style={[styles.roundedView, roundedView, { backgroundColor: static_white }]}>
|
|
72
72
|
{paused ? (
|
|
73
|
-
<Play accessibilityLabel='Play Icon' height={24} pathFill={
|
|
73
|
+
<Play accessibilityLabel='Play Icon' height={24} pathFill={static_black} width={24} />
|
|
74
74
|
) : (
|
|
75
|
-
<Pause
|
|
75
|
+
<Pause
|
|
76
|
+
accessibilityLabel='Pause Icon'
|
|
77
|
+
height={24}
|
|
78
|
+
pathFill={static_black}
|
|
79
|
+
width={24}
|
|
80
|
+
/>
|
|
76
81
|
)}
|
|
77
82
|
</View>
|
|
78
83
|
</TouchableOpacity>
|
|
79
84
|
<Text
|
|
80
85
|
accessibilityLabel='Progress Duration'
|
|
81
|
-
style={[styles.durationTextStyle, durationTextStyle, { color:
|
|
86
|
+
style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
|
|
82
87
|
>
|
|
83
88
|
{progressDuration ? progressDuration : '00:00'}
|
|
84
89
|
</Text>
|
|
85
90
|
<ProgressControl
|
|
86
91
|
duration={duration}
|
|
87
|
-
filledColor={
|
|
92
|
+
filledColor={static_white}
|
|
88
93
|
onPlayPause={onPlayPause}
|
|
89
94
|
onProgressDrag={onProgressDrag}
|
|
90
95
|
progress={progress}
|
|
@@ -93,7 +98,7 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
|
|
|
93
98
|
/>
|
|
94
99
|
<Text
|
|
95
100
|
accessibilityLabel='Video Duration'
|
|
96
|
-
style={[styles.durationTextStyle, durationTextStyle, { color:
|
|
101
|
+
style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
|
|
97
102
|
>
|
|
98
103
|
{videoDuration ? videoDuration : '00:00'}
|
|
99
104
|
</Text>
|
|
@@ -196,13 +196,15 @@ describe('MessageContent', () => {
|
|
|
196
196
|
user,
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
-
const { getByTestId, queryAllByTestId } = renderMessage({ message });
|
|
199
|
+
const { getByTestId, queryAllByA11yLabel, queryAllByTestId } = renderMessage({ message });
|
|
200
200
|
|
|
201
201
|
const fileAttachments = queryAllByTestId('file-attachment');
|
|
202
|
+
const audioAttachments = queryAllByA11yLabel('audio-attachment-preview');
|
|
202
203
|
|
|
203
204
|
await waitFor(() => {
|
|
204
205
|
expect(getByTestId('message-content-wrapper')).toBeTruthy();
|
|
205
|
-
expect(fileAttachments).toHaveLength(
|
|
206
|
+
expect(fileAttachments).toHaveLength(1);
|
|
207
|
+
expect(audioAttachments).toHaveLength(1);
|
|
206
208
|
});
|
|
207
209
|
});
|
|
208
210
|
|
|
@@ -123,9 +123,9 @@ type FileUploadPreviewPropsWithContext<
|
|
|
123
123
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
124
124
|
> = Pick<
|
|
125
125
|
MessageInputContextValue<StreamChatGenerics>,
|
|
126
|
-
'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads'
|
|
126
|
+
'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads'
|
|
127
127
|
> &
|
|
128
|
-
Pick<MessagesContextValue<StreamChatGenerics>, 'FileAttachmentIcon'>;
|
|
128
|
+
Pick<MessagesContextValue<StreamChatGenerics>, 'AudioAttachment' | 'FileAttachmentIcon'>;
|
|
129
129
|
|
|
130
130
|
const FileUploadPreviewWithContext = <
|
|
131
131
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -133,7 +133,7 @@ const FileUploadPreviewWithContext = <
|
|
|
133
133
|
props: FileUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
134
134
|
) => {
|
|
135
135
|
const {
|
|
136
|
-
|
|
136
|
+
AudioAttachment,
|
|
137
137
|
FileAttachmentIcon,
|
|
138
138
|
fileUploads,
|
|
139
139
|
removeFile,
|
|
@@ -172,8 +172,8 @@ const FileUploadPreviewWithContext = <
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
// The handler which controls or sets the paused/played state of the audio.
|
|
175
|
-
const onPlayPause = (index: string,
|
|
176
|
-
if (
|
|
175
|
+
const onPlayPause = (index: string, pausedStatus?: boolean) => {
|
|
176
|
+
if (pausedStatus === false) {
|
|
177
177
|
// If the status is false we set the audio with the index as playing and the others as paused.
|
|
178
178
|
setFileUploads((prevFileUploads) =>
|
|
179
179
|
prevFileUploads.map((fileUpload) => ({
|
|
@@ -194,7 +194,7 @@ const FileUploadPreviewWithContext = <
|
|
|
194
194
|
|
|
195
195
|
const {
|
|
196
196
|
theme: {
|
|
197
|
-
colors: { black, grey_dark, grey_gainsboro, grey_whisper },
|
|
197
|
+
colors: { black, grey_dark, grey_gainsboro, grey_whisper, white },
|
|
198
198
|
messageInput: {
|
|
199
199
|
fileUploadPreview: {
|
|
200
200
|
audioAttachmentFileContainer,
|
|
@@ -230,14 +230,31 @@ const FileUploadPreviewWithContext = <
|
|
|
230
230
|
audioAttachmentFileContainer,
|
|
231
231
|
]}
|
|
232
232
|
>
|
|
233
|
-
<
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
<View
|
|
234
|
+
style={[
|
|
235
|
+
styles.fileContainer,
|
|
236
|
+
index === fileUploads.length - 1
|
|
237
|
+
? {
|
|
238
|
+
marginBottom: 0,
|
|
239
|
+
}
|
|
240
|
+
: {},
|
|
241
|
+
{
|
|
242
|
+
backgroundColor: white,
|
|
243
|
+
borderColor: grey_whisper,
|
|
244
|
+
width: -16,
|
|
245
|
+
},
|
|
246
|
+
fileContainer,
|
|
247
|
+
]}
|
|
239
248
|
testID='audio-attachment-upload-preview'
|
|
240
|
-
|
|
249
|
+
>
|
|
250
|
+
<AudioAttachment
|
|
251
|
+
item={item}
|
|
252
|
+
onLoad={onLoad}
|
|
253
|
+
onPlayPause={onPlayPause}
|
|
254
|
+
onProgress={onProgress}
|
|
255
|
+
testID='audio-attachment-upload-preview'
|
|
256
|
+
/>
|
|
257
|
+
</View>
|
|
241
258
|
</View>
|
|
242
259
|
) : (
|
|
243
260
|
<View
|
|
@@ -296,18 +313,9 @@ const FileUploadPreviewWithContext = <
|
|
|
296
313
|
style={[styles.dismiss, { backgroundColor: grey_gainsboro }, dismiss]}
|
|
297
314
|
testID='remove-file-upload-preview'
|
|
298
315
|
>
|
|
299
|
-
<Close />
|
|
316
|
+
<Close pathFill={grey_dark} />
|
|
300
317
|
</TouchableOpacity>
|
|
301
318
|
</UploadProgressIndicator>
|
|
302
|
-
<TouchableOpacity
|
|
303
|
-
onPress={() => {
|
|
304
|
-
removeFile(item.id);
|
|
305
|
-
}}
|
|
306
|
-
style={[styles.dismiss, { backgroundColor: grey_gainsboro }, dismiss]}
|
|
307
|
-
testID='remove-file-upload-preview'
|
|
308
|
-
>
|
|
309
|
-
<Close pathFill={grey_dark} />
|
|
310
|
-
</TouchableOpacity>
|
|
311
319
|
</>
|
|
312
320
|
);
|
|
313
321
|
};
|
|
@@ -380,14 +388,14 @@ export const FileUploadPreview = <
|
|
|
380
388
|
>(
|
|
381
389
|
props: FileUploadPreviewProps<StreamChatGenerics>,
|
|
382
390
|
) => {
|
|
383
|
-
const {
|
|
391
|
+
const { fileUploads, removeFile, setFileUploads, uploadFile } =
|
|
384
392
|
useMessageInputContext<StreamChatGenerics>();
|
|
385
|
-
const { FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
|
|
393
|
+
const { AudioAttachment, FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
|
|
386
394
|
|
|
387
395
|
return (
|
|
388
396
|
<MemoizedFileUploadPreview
|
|
389
397
|
{...{
|
|
390
|
-
|
|
398
|
+
AudioAttachment,
|
|
391
399
|
FileAttachmentIcon,
|
|
392
400
|
fileUploads,
|
|
393
401
|
removeFile,
|
|
@@ -4,15 +4,16 @@ import { act } from 'react-test-renderer';
|
|
|
4
4
|
|
|
5
5
|
import { fireEvent, render } from '@testing-library/react-native';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
FileUpload,
|
|
9
|
+
MessageInputContext,
|
|
10
|
+
MessageInputContextValue,
|
|
11
|
+
} from '../../../contexts/messageInputContext/MessageInputContext';
|
|
8
12
|
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
9
13
|
import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
|
|
10
14
|
|
|
11
15
|
import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
|
|
12
|
-
import {
|
|
13
|
-
AudioAttachmentUploadPreview,
|
|
14
|
-
AudioAttachmentUploadPreviewProps,
|
|
15
|
-
} from '../AudioAttachmentUploadPreview';
|
|
16
|
+
import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
|
|
16
17
|
|
|
17
18
|
jest.mock('../../../native.ts', () => ({
|
|
18
19
|
isAudioPackageAvailable: jest.fn(() => true),
|
|
@@ -29,13 +30,19 @@ jest.mock('react-native/Libraries/ReactNative/I18nManager', () => ({
|
|
|
29
30
|
isRTL: true,
|
|
30
31
|
}));
|
|
31
32
|
|
|
32
|
-
const getComponent = (
|
|
33
|
+
const getComponent = (
|
|
34
|
+
props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
|
|
35
|
+
) => (
|
|
33
36
|
<ThemeProvider theme={defaultTheme}>
|
|
34
|
-
<
|
|
37
|
+
<MessageInputContext.Provider
|
|
38
|
+
value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
|
|
39
|
+
>
|
|
40
|
+
<AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
|
|
41
|
+
</MessageInputContext.Provider>
|
|
35
42
|
</ThemeProvider>
|
|
36
43
|
);
|
|
37
44
|
|
|
38
|
-
describe('
|
|
45
|
+
describe('AudioAttachmentExpo', () => {
|
|
39
46
|
it('handle play pause button when isPausedStatusAvailable unavailable and progress 1', () => {
|
|
40
47
|
const setPositionAsyncMock = jest.fn();
|
|
41
48
|
jest.spyOn(React, 'useRef').mockReturnValue({
|
|
@@ -4,15 +4,16 @@ import { act } from 'react-test-renderer';
|
|
|
4
4
|
|
|
5
5
|
import { fireEvent, render } from '@testing-library/react-native';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
FileUpload,
|
|
9
|
+
MessageInputContext,
|
|
10
|
+
MessageInputContextValue,
|
|
11
|
+
} from '../../../contexts/messageInputContext/MessageInputContext';
|
|
8
12
|
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
9
13
|
import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
|
|
10
14
|
|
|
11
15
|
import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
|
|
12
|
-
import {
|
|
13
|
-
AudioAttachmentUploadPreview,
|
|
14
|
-
AudioAttachmentUploadPreviewProps,
|
|
15
|
-
} from '../AudioAttachmentUploadPreview';
|
|
16
|
+
import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
|
|
16
17
|
|
|
17
18
|
jest.mock('../../../native.ts', () => {
|
|
18
19
|
const View = require('react-native/Libraries/Components/View/View');
|
|
@@ -28,13 +29,19 @@ jest.mock('../../../native.ts', () => {
|
|
|
28
29
|
};
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
const getComponent = (
|
|
32
|
+
const getComponent = (
|
|
33
|
+
props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
|
|
34
|
+
) => (
|
|
32
35
|
<ThemeProvider theme={defaultTheme}>
|
|
33
|
-
<
|
|
36
|
+
<MessageInputContext.Provider
|
|
37
|
+
value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
|
|
38
|
+
>
|
|
39
|
+
<AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
|
|
40
|
+
</MessageInputContext.Provider>
|
|
34
41
|
</ThemeProvider>
|
|
35
42
|
);
|
|
36
43
|
|
|
37
|
-
describe('
|
|
44
|
+
describe('AudioAttachment', () => {
|
|
38
45
|
it('handle play pause button when isPausedStatusAvailable unavailable and progress 1', () => {
|
|
39
46
|
const seekMock = jest.fn();
|
|
40
47
|
jest.spyOn(React, 'useRef').mockReturnValue({
|
|
@@ -351,13 +351,13 @@ describe('FileUploadPreview', () => {
|
|
|
351
351
|
</OverlayProvider>,
|
|
352
352
|
);
|
|
353
353
|
|
|
354
|
-
const
|
|
354
|
+
const AudioAttachmentComponent = getByTestId('audio-attachment-upload-preview');
|
|
355
355
|
|
|
356
356
|
await waitFor(() => {
|
|
357
|
-
fireEvent(
|
|
358
|
-
fireEvent(
|
|
359
|
-
fireEvent(
|
|
360
|
-
fireEvent(
|
|
357
|
+
fireEvent(AudioAttachmentComponent, 'onLoad');
|
|
358
|
+
fireEvent(AudioAttachmentComponent, 'onProgress');
|
|
359
|
+
fireEvent(AudioAttachmentComponent, 'onPlayPause');
|
|
360
|
+
fireEvent(AudioAttachmentComponent, 'onPlayPause', {
|
|
361
361
|
status: false,
|
|
362
362
|
});
|
|
363
363
|
});
|
package/src/components/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './Attachment/Attachment';
|
|
2
2
|
export * from './Attachment/AttachmentActions';
|
|
3
|
+
export * from './Attachment/AudioAttachment';
|
|
3
4
|
export * from './Attachment/Card';
|
|
4
5
|
export * from './Attachment/FileAttachment';
|
|
5
6
|
export * from './Attachment/FileAttachmentGroup';
|
|
@@ -113,7 +114,6 @@ export * from './MessageInput/AttachButton';
|
|
|
113
114
|
export * from './MessageInput/CommandsButton';
|
|
114
115
|
export * from './MessageInput/CooldownTimer';
|
|
115
116
|
export * from './MessageInput/FileUploadPreview';
|
|
116
|
-
export * from './MessageInput/AudioAttachmentUploadPreview';
|
|
117
117
|
export * from './MessageInput/ImageUploadPreview';
|
|
118
118
|
export * from './MessageInput/InputButtons';
|
|
119
119
|
export * from './MessageInput/MessageInput';
|
|
@@ -22,7 +22,6 @@ import { useCreateMessageInputContext } from './hooks/useCreateMessageInputConte
|
|
|
22
22
|
import { isEditingBoolean, useMessageDetailsForState } from './hooks/useMessageDetailsForState';
|
|
23
23
|
|
|
24
24
|
import type { AttachButtonProps } from '../../components/MessageInput/AttachButton';
|
|
25
|
-
import type { AudioAttachmentUploadPreviewProps } from '../../components/MessageInput/AudioAttachmentUploadPreview';
|
|
26
25
|
import type { CommandsButtonProps } from '../../components/MessageInput/CommandsButton';
|
|
27
26
|
import type { InputEditingStateHeaderProps } from '../../components/MessageInput/components/InputEditingStateHeader';
|
|
28
27
|
import type { InputGiphySearchProps } from '../../components/MessageInput/components/InputGiphySearch';
|
|
@@ -225,11 +224,6 @@ export type InputMessageInputContextValue<
|
|
|
225
224
|
*/
|
|
226
225
|
AttachButton: React.ComponentType<AttachButtonProps<StreamChatGenerics>>;
|
|
227
226
|
|
|
228
|
-
/** Custom UI component for AudioAttachmentUploadPreview. */
|
|
229
|
-
AudioAttachmentUploadPreview: React.ComponentType<
|
|
230
|
-
AudioAttachmentUploadPreviewProps<StreamChatGenerics>
|
|
231
|
-
>;
|
|
232
|
-
|
|
233
227
|
clearEditingState: () => void;
|
|
234
228
|
clearQuotedMessageState: () => void;
|
|
235
229
|
/**
|
|
@@ -12,7 +12,6 @@ export const useCreateMessageInputContext = <
|
|
|
12
12
|
asyncIds,
|
|
13
13
|
asyncUploads,
|
|
14
14
|
AttachButton,
|
|
15
|
-
AudioAttachmentUploadPreview,
|
|
16
15
|
autoCompleteSuggestionsLimit,
|
|
17
16
|
clearEditingState,
|
|
18
17
|
clearQuotedMessageState,
|
|
@@ -116,7 +115,6 @@ export const useCreateMessageInputContext = <
|
|
|
116
115
|
asyncIds,
|
|
117
116
|
asyncUploads,
|
|
118
117
|
AttachButton,
|
|
119
|
-
AudioAttachmentUploadPreview,
|
|
120
118
|
autoCompleteSuggestionsLimit,
|
|
121
119
|
clearEditingState,
|
|
122
120
|
clearQuotedMessageState,
|
|
@@ -11,6 +11,7 @@ import type { Attachment, ChannelState, MessageResponse } from 'stream-chat';
|
|
|
11
11
|
|
|
12
12
|
import type { AttachmentProps } from '../../components/Attachment/Attachment';
|
|
13
13
|
import type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';
|
|
14
|
+
import type { AudioAttachmentProps } from '../../components/Attachment/AudioAttachment';
|
|
14
15
|
import type { CardProps } from '../../components/Attachment/Card';
|
|
15
16
|
import type { FileAttachmentProps } from '../../components/Attachment/FileAttachment';
|
|
16
17
|
import type { FileAttachmentGroupProps } from '../../components/Attachment/FileAttachmentGroup';
|
|
@@ -72,6 +73,8 @@ export type MessagesContextValue<
|
|
|
72
73
|
* Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/AttachmentActions.tsx)
|
|
73
74
|
*/
|
|
74
75
|
AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;
|
|
76
|
+
/** Custom UI component for AudioAttachment. */
|
|
77
|
+
AudioAttachment: React.ComponentType<AudioAttachmentProps>;
|
|
75
78
|
/**
|
|
76
79
|
* UI component to display generic media type e.g. giphy, url preview etc
|
|
77
80
|
* Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/Card.tsx)
|
|
@@ -247,12 +247,12 @@ export type Theme = {
|
|
|
247
247
|
editingBoxHeaderTitle: TextStyle;
|
|
248
248
|
};
|
|
249
249
|
fileUploadPreview: {
|
|
250
|
-
|
|
251
|
-
audioAttachmentUploadPreview: {
|
|
250
|
+
audioAttachment: {
|
|
252
251
|
progressControlView: ViewStyle;
|
|
253
252
|
progressDurationText: TextStyle;
|
|
254
253
|
roundedView: ViewStyle;
|
|
255
254
|
};
|
|
255
|
+
audioAttachmentFileContainer: ViewStyle;
|
|
256
256
|
dismiss: ViewStyle;
|
|
257
257
|
fileContainer: ViewStyle;
|
|
258
258
|
fileContentContainer: ViewStyle;
|
|
@@ -746,12 +746,12 @@ export const defaultTheme: Theme = {
|
|
|
746
746
|
editingBoxHeaderTitle: {},
|
|
747
747
|
},
|
|
748
748
|
fileUploadPreview: {
|
|
749
|
-
|
|
750
|
-
audioAttachmentUploadPreview: {
|
|
749
|
+
audioAttachment: {
|
|
751
750
|
progressControlView: {},
|
|
752
751
|
progressDurationText: {},
|
|
753
752
|
roundedView: {},
|
|
754
753
|
},
|
|
754
|
+
audioAttachmentFileContainer: {},
|
|
755
755
|
dismiss: {},
|
|
756
756
|
fileContainer: {},
|
|
757
757
|
fileContentContainer: {},
|
package/src/version.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["AudioAttachmentUploadPreview.tsx"],"names":["dayjs","extend","duration","FILE_PREVIEW_HEIGHT","styles","StyleSheet","create","fileContainer","borderRadius","borderWidth","flexDirection","height","paddingLeft","paddingRight","fileContentContainer","filenameText","fontSize","fontWeight","fileTextContainer","justifyContent","flatList","marginBottom","maxHeight","overlay","marginLeft","marginRight","progressControlView","flex","progressDurationText","roundedView","alignItems","alignSelf","display","elevation","shadowOffset","width","shadowOpacity","shadowRadius","AudioAttachmentUploadPreviewWithContext","props","soundRef","React","useRef","fileUploads","index","item","onLoad","onPlayPause","onProgress","handleLoad","payload","id","handleProgress","data","currentTime","seekableDuration","handlePlayPause","isPausedStatusAvailable","current","undefined","progress","seek","setPositionAsync","paused","playAsync","pauseAsync","handleProgressDrag","position","handleEnd","onPlaybackStatusUpdate","playbackStatus","isLoaded","error","console","log","durationMillis","positionMillis","isPlaying","isBuffering","didJustFinish","isLooping","Sound","Player","initiateSound","file","uri","initializeSound","stopAsync","unloadAsync","initalPlayPause","theme","colors","accent_blue","black","grey_dark","grey_whisper","static_black","static_white","messageInput","fileUploadPreview","audioAttachmentUploadPreview","progressValueInSeconds","progressDuration","format","lastIndexOfDot","name","lastIndexOf","length","borderColor","backgroundColor","shadowColor","color","I18nManager","isRTL","writingDirection","slice","AudioAttachmentUploadPreview","removeFile","uploadFile","displayName"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEA;;AAMA;;AACA;;AAQA;;;;;;;;;AAEAA,kBAAMC,MAAN,CAAaC,oBAAb;;AAEA,IAAMC,mBAAmB,GAAG,EAA5B;;AAEA,IAAMC,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC/BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,YAAY,EAAE,EADD;AAEbC,IAAAA,WAAW,EAAE,CAFA;AAGbC,IAAAA,aAAa,EAAE,KAHF;AAIbC,IAAAA,MAAM,EAAER,mBAJK;AAKbS,IAAAA,WAAW,EA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AAEjB;AAAT,KAA9B,EAAoDlE,oBAApD,CAAb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACG0E,gBADH,CAnBF,EAsBE,gCAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAAClG,MAAM,CAACsB,mBAAR,EAA6BA,mBAA7B,CAAb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,gCAAD;AACE,IAAA,QAAQ,EAAEmB,IAAI,CAAC3C,QADjB;AAEE,IAAA,WAAW,EAAE0F,WAFf;AAGE,IAAA,WAAW,EAAEpC,eAHf;AAIE,IAAA,cAAc,EAAEU,kBAJlB;AAKE,IAAA,QAAQ,EAAErB,IAAI,CAACe,QALjB;AAME,IAAA,MAAM,EAAC,kBANT;AAOE,IAAA,KAAK,EAAE,GAPT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF,CAtBF,CApBF,CAhBF,CAhBF,CADF;AA2FD,CA5OD;;AA6PO,IAAMwD,4BAA4B,GAAG,SAA/BA,4BAA+B,CAG1C7E,KAH0C,EAIvC;AACH,8BAAgD,uCAAhD;AAAA,MAAQI,WAAR,yBAAQA,WAAR;AAAA,MAAqB0E,UAArB,yBAAqBA,UAArB;AAAA,MAAiCC,UAAjC,yBAAiCA,UAAjC;;AAEA,SACE,gCAAC,uCAAD;AACQ3E,IAAAA,WAAW,EAAXA,WADR;AACqB0E,IAAAA,UAAU,EAAVA,UADrB;AACiCC,IAAAA,UAAU,EAAVA;AADjC,KAEM/E,KAFN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KADF;AAMD,CAbM;;;AAeP6E,4BAA4B,CAACG,WAA7B,GACE,yEADF","sourcesContent":["import React, { useEffect } from 'react';\nimport { I18nManager, StyleSheet, Text, TouchableOpacity, View } from 'react-native';\n\nimport dayjs from 'dayjs';\nimport duration from 'dayjs/plugin/duration';\n\nimport {\n FileUpload,\n MessageInputContextValue,\n useMessageInputContext,\n useTheme,\n} from '../../contexts';\nimport { Pause, Play } from '../../icons';\nimport {\n PlaybackStatus,\n Sound,\n SoundReturnType,\n VideoPayloadData,\n VideoProgressData,\n} from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { ProgressControl } from '../ProgressControl/ProgressControl';\n\ndayjs.extend(duration);\n\nconst FILE_PREVIEW_HEIGHT = 70;\n\nconst styles = StyleSheet.create({\n fileContainer: {\n borderRadius: 12,\n borderWidth: 1,\n flexDirection: 'row',\n height: FILE_PREVIEW_HEIGHT,\n paddingLeft: 8,\n paddingRight: 8,\n },\n fileContentContainer: { flexDirection: 'row' },\n filenameText: {\n fontSize: 14,\n fontWeight: 'bold',\n paddingLeft: 10,\n },\n fileTextContainer: {\n justifyContent: 'space-around',\n },\n flatList: { marginBottom: 12, maxHeight: FILE_PREVIEW_HEIGHT * 2.5 + 16 },\n overlay: {\n borderRadius: 12,\n marginLeft: 8,\n marginRight: 8,\n },\n progressControlView: {\n flex: 8,\n },\n progressDurationText: {\n flex: 4,\n fontSize: 12,\n paddingLeft: 10,\n paddingRight: 8,\n },\n roundedView: {\n alignItems: 'center',\n alignSelf: 'center',\n borderRadius: 50,\n display: 'flex',\n elevation: 4,\n height: 36,\n justifyContent: 'center',\n shadowOffset: {\n height: 2,\n width: 0,\n },\n shadowOpacity: 0.23,\n shadowRadius: 2.62,\n width: 36,\n },\n});\n\nexport type AudioAttachmentUploadPreviewPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessageInputContextValue<StreamChatGenerics>,\n 'fileUploads' | 'removeFile' | 'uploadFile'\n> & {\n index: number;\n item: FileUpload;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, status?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\nconst AudioAttachmentUploadPreviewWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const soundRef = React.useRef<SoundReturnType | null>(null);\n const { fileUploads, index, item, onLoad, onPlayPause, onProgress } = props;\n\n const handleLoad = (payload: VideoPayloadData) => {\n onLoad(item.id, payload.duration);\n };\n\n const handleProgress = (data: VideoProgressData) => {\n if (data.currentTime && data.seekableDuration) {\n onProgress(item.id, data.currentTime);\n }\n };\n\n const handlePlayPause = async (isPausedStatusAvailable?: boolean) => {\n if (soundRef.current) {\n if (isPausedStatusAvailable === undefined) {\n if (item.progress === 1) {\n // For native CLI\n if (soundRef.current.seek) soundRef.current.seek(0);\n // For expo CLI\n if (soundRef.current.setPositionAsync) soundRef.current.setPositionAsync(0);\n }\n if (item.paused) {\n if (soundRef.current.playAsync) await soundRef.current.playAsync();\n onPlayPause(item.id, false);\n } else {\n if (soundRef.current.pauseAsync) await soundRef.current.pauseAsync();\n onPlayPause(item.id, true);\n }\n } else {\n onPlayPause(item.id, isPausedStatusAvailable);\n }\n }\n };\n\n const handleProgressDrag = async (position: number) => {\n onProgress(item.id, position);\n if (soundRef.current?.seek) soundRef.current.seek(position);\n if (soundRef.current?.setPositionAsync) {\n await soundRef.current.setPositionAsync(position * 1000);\n }\n };\n\n const handleEnd = () => {\n onPlayPause(item.id, true);\n onProgress(item.id, item.duration, true);\n };\n\n const onPlaybackStatusUpdate = (playbackStatus: PlaybackStatus) => {\n if (!playbackStatus.isLoaded) {\n // Update your UI for the unloaded state\n if (playbackStatus.error) {\n console.log(`Encountered a fatal error during playback: ${playbackStatus.error}`);\n }\n } else {\n const { durationMillis, positionMillis } = playbackStatus;\n onLoad(item.id, durationMillis / 1000);\n // Update your UI for the loaded state\n if (playbackStatus.isPlaying) {\n // Update your UI for the playing state\n onProgress(item.id, positionMillis / 1000);\n } else {\n // Update your UI for the paused state\n }\n\n if (playbackStatus.isBuffering) {\n // Update your UI for the buffering state\n }\n\n if (playbackStatus.didJustFinish && !playbackStatus.isLooping) {\n // The player has just finished playing and will stop. Maybe you want to play something else?\n // status: opposite of pause,says i am playing\n handleEnd();\n }\n }\n };\n\n useEffect(() => {\n if (Sound.Player === null) {\n const initiateSound = async () => {\n if (item && item.file && item.file.uri) {\n soundRef.current = await Sound.initializeSound(\n { uri: item.file.uri },\n {},\n onPlaybackStatusUpdate,\n );\n }\n };\n initiateSound();\n }\n\n return () => {\n if (soundRef.current?.stopAsync && soundRef.current.unloadAsync) {\n soundRef.current.stopAsync();\n soundRef.current.unloadAsync();\n }\n };\n }, []);\n\n // This is needed for expo applications where the rerender doesn't occur on time thefore you need to update the state of the sound.\n useEffect(() => {\n const initalPlayPause = async () => {\n if (soundRef.current) {\n if (item.paused) {\n if (soundRef.current.pauseAsync) await soundRef.current.pauseAsync();\n } else {\n if (soundRef.current.playAsync) await soundRef.current.playAsync();\n }\n }\n };\n if (!Sound.Player) {\n initalPlayPause();\n }\n }, [item.paused]);\n\n const {\n theme: {\n colors: { accent_blue, black, grey_dark, grey_whisper, static_black, static_white },\n messageInput: {\n fileUploadPreview: {\n audioAttachmentUploadPreview: { progressControlView, progressDurationText, roundedView },\n fileContainer,\n fileContentContainer,\n filenameText,\n fileTextContainer,\n },\n },\n },\n } = useTheme();\n\n const progressValueInSeconds = (item.duration as number) * (item.progress as number);\n\n const progressDuration = progressValueInSeconds\n ? progressValueInSeconds / 3600 >= 1\n ? dayjs.duration(progressValueInSeconds, 'second').format('HH:mm:ss')\n : dayjs.duration(progressValueInSeconds, 'second').format('mm:ss')\n : '00:00';\n\n const lastIndexOfDot = item.file.name.lastIndexOf('.');\n\n return (\n <View\n style={[\n styles.fileContainer,\n index === fileUploads.length - 1\n ? {\n marginBottom: 0,\n }\n : {},\n {\n borderColor: grey_whisper,\n width: -16,\n },\n fileContainer,\n ]}\n testID='audio-attachment-upload-preview'\n >\n <View style={[styles.fileContentContainer, fileContentContainer]}>\n <TouchableOpacity\n accessibilityLabel='Play Pause Button'\n onPress={() => handlePlayPause()}\n style={[\n styles.roundedView,\n roundedView,\n { backgroundColor: static_white, shadowColor: black },\n ]}\n >\n {item.paused ? (\n <Play height={24} pathFill={static_black} width={24} />\n ) : (\n <Pause height={24} pathFill={static_black} width={24} />\n )}\n </TouchableOpacity>\n <View style={[styles.fileTextContainer, fileTextContainer]}>\n <Text\n accessibilityLabel='File Name'\n numberOfLines={1}\n style={[\n styles.filenameText,\n {\n color: black,\n width:\n 16 - // 16 = horizontal padding\n 40 - // 40 = file icon size\n 24 - // 24 = close icon size\n 24, // 24 = internal padding\n },\n I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },\n filenameText,\n ]}\n >\n {item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}\n </Text>\n <View\n style={{\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'row',\n }}\n >\n {/* <ExpoSoundPlayer filePaused={!!item.paused} soundRef={soundRef} /> */}\n {Sound.Player && (\n <Sound.Player\n onEnd={handleEnd}\n onLoad={handleLoad}\n onProgress={handleProgress}\n paused={item.paused as boolean}\n soundRef={soundRef}\n testID='sound-player'\n uri={item.file.uri}\n />\n )}\n <Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>\n {progressDuration}\n </Text>\n <View style={[styles.progressControlView, progressControlView]}>\n <ProgressControl\n duration={item.duration as number}\n filledColor={accent_blue}\n onPlayPause={handlePlayPause}\n onProgressDrag={handleProgressDrag}\n progress={item.progress as number}\n testID='progress-control'\n width={110}\n />\n </View>\n </View>\n </View>\n </View>\n </View>\n );\n};\n\nexport type AudioAttachmentUploadPreviewProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>> & {\n index: number;\n item: FileUpload;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, status?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\n/**\n * AudioAttachmentUploadPreview\n * UI Component to preview the audio files set for upload\n */\nexport const AudioAttachmentUploadPreview = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentUploadPreviewProps<StreamChatGenerics>,\n) => {\n const { fileUploads, removeFile, uploadFile } = useMessageInputContext<StreamChatGenerics>();\n\n return (\n <AudioAttachmentUploadPreviewWithContext\n {...{ fileUploads, removeFile, uploadFile }}\n {...props}\n />\n );\n};\n\nAudioAttachmentUploadPreview.displayName =\n 'AudioAttachmentUploadPreview{messageInput{autoAttachmentUploadPreview}}';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["AudioAttachmentUploadPreview.tsx"],"names":["dayjs","extend","duration","FILE_PREVIEW_HEIGHT","styles","StyleSheet","create","fileContainer","borderRadius","borderWidth","flexDirection","height","paddingLeft","paddingRight","fileContentContainer","filenameText","fontSize","fontWeight","fileTextContainer","justifyContent","flatList","marginBottom","maxHeight","overlay","marginLeft","marginRight","progressControlView","flex","progressDurationText","roundedView","alignItems","alignSelf","display","elevation","shadowOffset","width","shadowOpacity","shadowRadius","AudioAttachmentUploadPreviewWithContext","props","soundRef","React","useRef","fileUploads","index","item","onLoad","onPlayPause","onProgress","handleLoad","payload","id","handleProgress","data","currentTime","seekableDuration","handlePlayPause","isPausedStatusAvailable","current","undefined","progress","seek","setPositionAsync","paused","playAsync","pauseAsync","handleProgressDrag","position","handleEnd","onPlaybackStatusUpdate","playbackStatus","isLoaded","error","console","log","durationMillis","positionMillis","isPlaying","isBuffering","didJustFinish","isLooping","Sound","Player","initiateSound","file","uri","initializeSound","stopAsync","unloadAsync","initalPlayPause","theme","colors","accent_blue","black","grey_dark","grey_whisper","static_black","static_white","messageInput","fileUploadPreview","audioAttachmentUploadPreview","progressValueInSeconds","progressDuration","format","lastIndexOfDot","name","lastIndexOf","length","borderColor","backgroundColor","shadowColor","color","I18nManager","isRTL","writingDirection","slice","AudioAttachmentUploadPreview","removeFile","uploadFile","display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3E,IAAAA,WAAW,EAAXA,WADR;AACqB0E,IAAAA,UAAU,EAAVA,UADrB;AACiCC,IAAAA,UAAU,EAAVA;AADjC,KAEM/E,KAFN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KADF;AAMD,CAbM;;;AAeP6E,4BAA4B,CAACG,WAA7B,GACE,yEADF","sourcesContent":["import React, { useEffect } from 'react';\nimport { I18nManager, StyleSheet, Text, TouchableOpacity, View } from 'react-native';\n\nimport dayjs from 'dayjs';\nimport duration from 'dayjs/plugin/duration';\n\nimport {\n FileUpload,\n MessageInputContextValue,\n useMessageInputContext,\n useTheme,\n} from '../../contexts';\nimport { Pause, Play } from '../../icons';\nimport {\n PlaybackStatus,\n Sound,\n SoundReturnType,\n VideoPayloadData,\n VideoProgressData,\n} from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { ProgressControl } from '../ProgressControl/ProgressControl';\n\ndayjs.extend(duration);\n\nconst FILE_PREVIEW_HEIGHT = 70;\n\nconst styles = StyleSheet.create({\n fileContainer: {\n borderRadius: 12,\n borderWidth: 1,\n flexDirection: 'row',\n height: FILE_PREVIEW_HEIGHT,\n paddingLeft: 8,\n paddingRight: 8,\n },\n fileContentContainer: { flexDirection: 'row' },\n filenameText: {\n fontSize: 14,\n fontWeight: 'bold',\n paddingLeft: 10,\n },\n fileTextContainer: {\n justifyContent: 'space-around',\n },\n flatList: { marginBottom: 12, maxHeight: FILE_PREVIEW_HEIGHT * 2.5 + 16 },\n overlay: {\n borderRadius: 12,\n marginLeft: 8,\n marginRight: 8,\n },\n progressControlView: {\n flex: 8,\n },\n progressDurationText: {\n flex: 4,\n fontSize: 12,\n paddingLeft: 10,\n paddingRight: 8,\n },\n roundedView: {\n alignItems: 'center',\n alignSelf: 'center',\n borderRadius: 50,\n display: 'flex',\n elevation: 4,\n height: 36,\n justifyContent: 'center',\n shadowOffset: {\n height: 2,\n width: 0,\n },\n shadowOpacity: 0.23,\n shadowRadius: 2.62,\n width: 36,\n },\n});\n\nexport type AudioAttachmentUploadPreviewPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessageInputContextValue<StreamChatGenerics>,\n 'fileUploads' | 'removeFile' | 'uploadFile'\n> & {\n index: number;\n item: FileUpload;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, status?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\nconst AudioAttachmentUploadPreviewWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const soundRef = React.useRef<SoundReturnType | null>(null);\n const { fileUploads, index, item, onLoad, onPlayPause, onProgress } = props;\n\n const handleLoad = (payload: VideoPayloadData) => {\n onLoad(item.id, payload.duration);\n };\n\n const handleProgress = (data: VideoProgressData) => {\n if (data.currentTime && data.seekableDuration) {\n onProgress(item.id, data.currentTime);\n }\n };\n\n const handlePlayPause = async (isPausedStatusAvailable?: boolean) => {\n if (soundRef.current) {\n if (isPausedStatusAvailable === undefined) {\n if (item.progress === 1) {\n // For native CLI\n if (soundRef.current.seek) soundRef.current.seek(0);\n // For expo CLI\n if (soundRef.current.setPositionAsync) soundRef.current.setPositionAsync(0);\n }\n if (item.paused) {\n if (soundRef.current.playAsync) await soundRef.current.playAsync();\n onPlayPause(item.id, false);\n } else {\n if (soundRef.current.pauseAsync) await soundRef.current.pauseAsync();\n onPlayPause(item.id, true);\n }\n } else {\n onPlayPause(item.id, isPausedStatusAvailable);\n }\n }\n };\n\n const handleProgressDrag = async (position: number) => {\n onProgress(item.id, position);\n if (soundRef.current?.seek) soundRef.current.seek(position);\n if (soundRef.current?.setPositionAsync) {\n await soundRef.current.setPositionAsync(position * 1000);\n }\n };\n\n const handleEnd = () => {\n onPlayPause(item.id, true);\n onProgress(item.id, item.duration, true);\n };\n\n const onPlaybackStatusUpdate = (playbackStatus: PlaybackStatus) => {\n if (!playbackStatus.isLoaded) {\n // Update your UI for the unloaded state\n if (playbackStatus.error) {\n console.log(`Encountered a fatal error during playback: ${playbackStatus.error}`);\n }\n } else {\n const { durationMillis, positionMillis } = playbackStatus;\n onLoad(item.id, durationMillis / 1000);\n // Update your UI for the loaded state\n if (playbackStatus.isPlaying) {\n // Update your UI for the playing state\n onProgress(item.id, positionMillis / 1000);\n } else {\n // Update your UI for the paused state\n }\n\n if (playbackStatus.isBuffering) {\n // Update your UI for the buffering state\n }\n\n if (playbackStatus.didJustFinish && !playbackStatus.isLooping) {\n // The player has just finished playing and will stop. Maybe you want to play something else?\n // status: opposite of pause,says i am playing\n handleEnd();\n }\n }\n };\n\n useEffect(() => {\n if (Sound.Player === null) {\n const initiateSound = async () => {\n if (item && item.file && item.file.uri) {\n soundRef.current = await Sound.initializeSound(\n { uri: item.file.uri },\n {},\n onPlaybackStatusUpdate,\n );\n }\n };\n initiateSound();\n }\n\n return () => {\n if (soundRef.current?.stopAsync && soundRef.current.unloadAsync) {\n soundRef.current.stopAsync();\n soundRef.current.unloadAsync();\n }\n };\n }, []);\n\n // This is needed for expo applications where the rerender doesn't occur on time thefore you need to update the state of the sound.\n useEffect(() => {\n const initalPlayPause = async () => {\n if (soundRef.current) {\n if (item.paused) {\n if (soundRef.current.pauseAsync) await soundRef.current.pauseAsync();\n } else {\n if (soundRef.current.playAsync) await soundRef.current.playAsync();\n }\n }\n };\n if (!Sound.Player) {\n initalPlayPause();\n }\n }, [item.paused]);\n\n const {\n theme: {\n colors: { accent_blue, black, grey_dark, grey_whisper, static_black, static_white },\n messageInput: {\n fileUploadPreview: {\n audioAttachmentUploadPreview: { progressControlView, progressDurationText, roundedView },\n fileContainer,\n fileContentContainer,\n filenameText,\n fileTextContainer,\n },\n },\n },\n } = useTheme();\n\n const progressValueInSeconds = (item.duration as number) * (item.progress as number);\n\n const progressDuration = progressValueInSeconds\n ? progressValueInSeconds / 3600 >= 1\n ? dayjs.duration(progressValueInSeconds, 'second').format('HH:mm:ss')\n : dayjs.duration(progressValueInSeconds, 'second').format('mm:ss')\n : '00:00';\n\n const lastIndexOfDot = item.file.name.lastIndexOf('.');\n\n return (\n <View\n style={[\n styles.fileContainer,\n index === fileUploads.length - 1\n ? {\n marginBottom: 0,\n }\n : {},\n {\n borderColor: grey_whisper,\n width: -16,\n },\n fileContainer,\n ]}\n testID='audio-attachment-upload-preview'\n >\n <View style={[styles.fileContentContainer, fileContentContainer]}>\n <TouchableOpacity\n accessibilityLabel='Play Pause Button'\n onPress={() => handlePlayPause()}\n style={[\n styles.roundedView,\n roundedView,\n { backgroundColor: static_white, shadowColor: black },\n ]}\n >\n {item.paused ? (\n <Play height={24} pathFill={static_black} width={24} />\n ) : (\n <Pause height={24} pathFill={static_black} width={24} />\n )}\n </TouchableOpacity>\n <View style={[styles.fileTextContainer, fileTextContainer]}>\n <Text\n accessibilityLabel='File Name'\n numberOfLines={1}\n style={[\n styles.filenameText,\n {\n color: black,\n width:\n 16 - // 16 = horizontal padding\n 40 - // 40 = file icon size\n 24 - // 24 = close icon size\n 24, // 24 = internal padding\n },\n I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },\n filenameText,\n ]}\n >\n {item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}\n </Text>\n <View\n style={{\n alignItems: 'center',\n display: 'flex',\n flexDirection: 'row',\n }}\n >\n {/* <ExpoSoundPlayer filePaused={!!item.paused} soundRef={soundRef} /> */}\n {Sound.Player && (\n <Sound.Player\n onEnd={handleEnd}\n onLoad={handleLoad}\n onProgress={handleProgress}\n paused={item.paused as boolean}\n soundRef={soundRef}\n testID='sound-player'\n uri={item.file.uri}\n />\n )}\n <Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>\n {progressDuration}\n </Text>\n <View style={[styles.progressControlView, progressControlView]}>\n <ProgressControl\n duration={item.duration as number}\n filledColor={accent_blue}\n onPlayPause={handlePlayPause}\n onProgressDrag={handleProgressDrag}\n progress={item.progress as number}\n testID='progress-control'\n width={110}\n />\n </View>\n </View>\n </View>\n </View>\n </View>\n );\n};\n\nexport type AudioAttachmentUploadPreviewProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>> & {\n index: number;\n item: FileUpload;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, status?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\n/**\n * AudioAttachmentUploadPreview\n * UI Component to preview the audio files set for upload\n */\nexport const AudioAttachmentUploadPreview = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentUploadPreviewProps<StreamChatGenerics>,\n) => {\n const { fileUploads, removeFile, uploadFile } = useMessageInputContext<StreamChatGenerics>();\n\n return (\n <AudioAttachmentUploadPreviewWithContext\n {...{ fileUploads, removeFile, uploadFile }}\n {...props}\n />\n );\n};\n\nAudioAttachmentUploadPreview.displayName =\n 'AudioAttachmentUploadPreview{messageInput{autoAttachmentUploadPreview}}';\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FileUpload, MessageInputContextValue } from '../../contexts';
|
|
2
|
-
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
3
|
-
export declare type AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageInputContextValue<StreamChatGenerics>, 'fileUploads' | 'removeFile' | 'uploadFile'> & {
|
|
4
|
-
index: number;
|
|
5
|
-
item: FileUpload;
|
|
6
|
-
onLoad: (index: string, duration: number) => void;
|
|
7
|
-
onPlayPause: (index: string, status?: boolean) => void;
|
|
8
|
-
onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;
|
|
9
|
-
testID: string;
|
|
10
|
-
};
|
|
11
|
-
export declare type AudioAttachmentUploadPreviewProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>> & {
|
|
12
|
-
index: number;
|
|
13
|
-
item: FileUpload;
|
|
14
|
-
onLoad: (index: string, duration: number) => void;
|
|
15
|
-
onPlayPause: (index: string, status?: boolean) => void;
|
|
16
|
-
onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;
|
|
17
|
-
testID: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* AudioAttachmentUploadPreview
|
|
21
|
-
* UI Component to preview the audio files set for upload
|
|
22
|
-
*/
|
|
23
|
-
export declare const AudioAttachmentUploadPreview: {
|
|
24
|
-
<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: AudioAttachmentUploadPreviewProps<StreamChatGenerics>): JSX.Element;
|
|
25
|
-
displayName: string;
|
|
26
|
-
};
|