stream-chat-react-native-core 4.12.0-beta.3 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/AudioAttachment.js +27 -56
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +31 -14
- 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/Channel/Channel.js +14 -14
- 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/MessageInput/FileUploadPreview.js +31 -16
- 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/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/version.json +1 -1
- package/lib/module/components/Attachment/AudioAttachment.js +27 -56
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +31 -14
- 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/Channel/Channel.js +14 -14
- 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/MessageInput/FileUploadPreview.js +31 -16
- 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/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/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +4 -7
- package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts +1 -2
- 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/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/package.json +1 -1
- package/src/components/Attachment/AudioAttachment.tsx +72 -116
- package/src/components/Attachment/FileAttachmentGroup.tsx +32 -11
- package/src/components/Attachment/Gallery.tsx +7 -1
- package/src/components/Channel/Channel.tsx +2 -1
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +0 -2
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/MessageInput/FileUploadPreview.tsx +29 -12
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +13 -3
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +13 -3
- package/src/components/MessageOverlay/MessageOverlay.tsx +1 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +0 -4
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +0 -2
- package/src/contexts/messagesContext/MessagesContext.tsx +3 -0
- package/src/version.json +1 -1
|
@@ -100,9 +100,7 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
100
100
|
var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
101
101
|
var soundRef = _react["default"].useRef(null);
|
|
102
102
|
|
|
103
|
-
var
|
|
104
|
-
index = props.index,
|
|
105
|
-
item = props.item,
|
|
103
|
+
var item = props.item,
|
|
106
104
|
onLoad = props.onLoad,
|
|
107
105
|
onPlayPause = props.onPlayPause,
|
|
108
106
|
onProgress = props.onProgress;
|
|
@@ -355,16 +353,13 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
355
353
|
accent_blue = _useTheme$theme$color.accent_blue,
|
|
356
354
|
black = _useTheme$theme$color.black,
|
|
357
355
|
grey_dark = _useTheme$theme$color.grey_dark,
|
|
358
|
-
grey_whisper = _useTheme$theme$color.grey_whisper,
|
|
359
356
|
static_black = _useTheme$theme$color.static_black,
|
|
360
357
|
static_white = _useTheme$theme$color.static_white,
|
|
361
|
-
white = _useTheme$theme$color.white,
|
|
362
358
|
_useTheme$theme$messa = _useTheme$theme.messageInput.fileUploadPreview,
|
|
363
359
|
_useTheme$theme$messa2 = _useTheme$theme$messa.audioAttachment,
|
|
364
360
|
progressControlView = _useTheme$theme$messa2.progressControlView,
|
|
365
361
|
progressDurationText = _useTheme$theme$messa2.progressDurationText,
|
|
366
362
|
roundedView = _useTheme$theme$messa2.roundedView,
|
|
367
|
-
fileContainer = _useTheme$theme$messa.fileContainer,
|
|
368
363
|
fileContentContainer = _useTheme$theme$messa.fileContentContainer,
|
|
369
364
|
filenameText = _useTheme$theme$messa.filenameText,
|
|
370
365
|
fileTextContainer = _useTheme$theme$messa.fileTextContainer;
|
|
@@ -373,27 +368,12 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
373
368
|
var progressDuration = progressValueInSeconds ? progressValueInSeconds / 3600 >= 1 ? _dayjs["default"].duration(progressValueInSeconds, 'second').format('HH:mm:ss') : _dayjs["default"].duration(progressValueInSeconds, 'second').format('mm:ss') : '00:00';
|
|
374
369
|
var lastIndexOfDot = item.file.name.lastIndexOf('.');
|
|
375
370
|
return _react["default"].createElement(_reactNative.View, {
|
|
376
|
-
style: [styles.fileContainer, index === fileUploads.length - 1 ? {
|
|
377
|
-
marginBottom: 0
|
|
378
|
-
} : {}, {
|
|
379
|
-
backgroundColor: white,
|
|
380
|
-
borderColor: grey_whisper,
|
|
381
|
-
width: -16
|
|
382
|
-
}, fileContainer],
|
|
383
|
-
testID: "audio-attachment-upload-preview",
|
|
384
|
-
__self: _this,
|
|
385
|
-
__source: {
|
|
386
|
-
fileName: _jsxFileName,
|
|
387
|
-
lineNumber: 239,
|
|
388
|
-
columnNumber: 5
|
|
389
|
-
}
|
|
390
|
-
}, _react["default"].createElement(_reactNative.View, {
|
|
391
371
|
style: [styles.fileContentContainer, fileContentContainer],
|
|
392
372
|
__self: _this,
|
|
393
373
|
__source: {
|
|
394
374
|
fileName: _jsxFileName,
|
|
395
|
-
lineNumber:
|
|
396
|
-
columnNumber:
|
|
375
|
+
lineNumber: 222,
|
|
376
|
+
columnNumber: 5
|
|
397
377
|
}
|
|
398
378
|
}, _react["default"].createElement(_reactNative.TouchableOpacity, {
|
|
399
379
|
accessibilityLabel: "Play Pause Button",
|
|
@@ -407,8 +387,8 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
407
387
|
__self: _this,
|
|
408
388
|
__source: {
|
|
409
389
|
fileName: _jsxFileName,
|
|
410
|
-
lineNumber:
|
|
411
|
-
columnNumber:
|
|
390
|
+
lineNumber: 223,
|
|
391
|
+
columnNumber: 7
|
|
412
392
|
}
|
|
413
393
|
}, item.paused ? _react["default"].createElement(_icons.Play, {
|
|
414
394
|
height: 24,
|
|
@@ -417,8 +397,8 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
417
397
|
__self: _this,
|
|
418
398
|
__source: {
|
|
419
399
|
fileName: _jsxFileName,
|
|
420
|
-
lineNumber:
|
|
421
|
-
columnNumber:
|
|
400
|
+
lineNumber: 233,
|
|
401
|
+
columnNumber: 11
|
|
422
402
|
}
|
|
423
403
|
}) : _react["default"].createElement(_icons.Pause, {
|
|
424
404
|
height: 24,
|
|
@@ -427,16 +407,16 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
427
407
|
__self: _this,
|
|
428
408
|
__source: {
|
|
429
409
|
fileName: _jsxFileName,
|
|
430
|
-
lineNumber:
|
|
431
|
-
columnNumber:
|
|
410
|
+
lineNumber: 235,
|
|
411
|
+
columnNumber: 11
|
|
432
412
|
}
|
|
433
413
|
})), _react["default"].createElement(_reactNative.View, {
|
|
434
414
|
style: [styles.fileTextContainer, fileTextContainer],
|
|
435
415
|
__self: _this,
|
|
436
416
|
__source: {
|
|
437
417
|
fileName: _jsxFileName,
|
|
438
|
-
lineNumber:
|
|
439
|
-
columnNumber:
|
|
418
|
+
lineNumber: 238,
|
|
419
|
+
columnNumber: 7
|
|
440
420
|
}
|
|
441
421
|
}, _react["default"].createElement(_reactNative.Text, {
|
|
442
422
|
accessibilityLabel: "File Name",
|
|
@@ -452,8 +432,8 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
452
432
|
__self: _this,
|
|
453
433
|
__source: {
|
|
454
434
|
fileName: _jsxFileName,
|
|
455
|
-
lineNumber:
|
|
456
|
-
columnNumber:
|
|
435
|
+
lineNumber: 239,
|
|
436
|
+
columnNumber: 9
|
|
457
437
|
}
|
|
458
438
|
}, item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)), _react["default"].createElement(_reactNative.View, {
|
|
459
439
|
style: {
|
|
@@ -464,8 +444,8 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
464
444
|
__self: _this,
|
|
465
445
|
__source: {
|
|
466
446
|
fileName: _jsxFileName,
|
|
467
|
-
lineNumber:
|
|
468
|
-
columnNumber:
|
|
447
|
+
lineNumber: 258,
|
|
448
|
+
columnNumber: 9
|
|
469
449
|
}
|
|
470
450
|
}, _native.Sound.Player && _react["default"].createElement(_native.Sound.Player, {
|
|
471
451
|
onEnd: handleEnd,
|
|
@@ -478,8 +458,8 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
478
458
|
__self: _this,
|
|
479
459
|
__source: {
|
|
480
460
|
fileName: _jsxFileName,
|
|
481
|
-
lineNumber:
|
|
482
|
-
columnNumber:
|
|
461
|
+
lineNumber: 267,
|
|
462
|
+
columnNumber: 13
|
|
483
463
|
}
|
|
484
464
|
}), _react["default"].createElement(_reactNative.Text, {
|
|
485
465
|
style: [styles.progressDurationText, {
|
|
@@ -488,16 +468,16 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
488
468
|
__self: _this,
|
|
489
469
|
__source: {
|
|
490
470
|
fileName: _jsxFileName,
|
|
491
|
-
lineNumber:
|
|
492
|
-
columnNumber:
|
|
471
|
+
lineNumber: 277,
|
|
472
|
+
columnNumber: 11
|
|
493
473
|
}
|
|
494
474
|
}, progressDuration), _react["default"].createElement(_reactNative.View, {
|
|
495
475
|
style: [styles.progressControlView, progressControlView],
|
|
496
476
|
__self: _this,
|
|
497
477
|
__source: {
|
|
498
478
|
fileName: _jsxFileName,
|
|
499
|
-
lineNumber:
|
|
500
|
-
columnNumber:
|
|
479
|
+
lineNumber: 280,
|
|
480
|
+
columnNumber: 11
|
|
501
481
|
}
|
|
502
482
|
}, _react["default"].createElement(_ProgressControl.ProgressControl, {
|
|
503
483
|
duration: item.duration,
|
|
@@ -510,28 +490,19 @@ var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
|
510
490
|
__self: _this,
|
|
511
491
|
__source: {
|
|
512
492
|
fileName: _jsxFileName,
|
|
513
|
-
lineNumber:
|
|
514
|
-
columnNumber:
|
|
493
|
+
lineNumber: 281,
|
|
494
|
+
columnNumber: 13
|
|
515
495
|
}
|
|
516
|
-
})))))
|
|
496
|
+
})))));
|
|
517
497
|
};
|
|
518
498
|
|
|
519
499
|
var AudioAttachment = function AudioAttachment(props) {
|
|
520
|
-
|
|
521
|
-
fileUploads = _useMessageInputConte.fileUploads,
|
|
522
|
-
removeFile = _useMessageInputConte.removeFile,
|
|
523
|
-
uploadFile = _useMessageInputConte.uploadFile;
|
|
524
|
-
|
|
525
|
-
return _react["default"].createElement(AudioAttachmentWithContext, (0, _extends2["default"])({
|
|
526
|
-
fileUploads: fileUploads,
|
|
527
|
-
removeFile: removeFile,
|
|
528
|
-
uploadFile: uploadFile
|
|
529
|
-
}, props, {
|
|
500
|
+
return _react["default"].createElement(AudioAttachmentWithContext, (0, _extends2["default"])({}, props, {
|
|
530
501
|
__self: _this,
|
|
531
502
|
__source: {
|
|
532
503
|
fileName: _jsxFileName,
|
|
533
|
-
lineNumber:
|
|
534
|
-
columnNumber:
|
|
504
|
+
lineNumber: 310,
|
|
505
|
+
columnNumber: 3
|
|
535
506
|
}
|
|
536
507
|
}));
|
|
537
508
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AudioAttachment.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","AudioAttachmentWithContext","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","white","messageInput","fileUploadPreview","audioAttachment","progressValueInSeconds","progressDuration","format","lastIndexOfDot","name","lastIndexOf","length","backgroundColor","borderColor","shadowColor","color","I18nManager","isRTL","writingDirection","slice","AudioAttachment","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,EAA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ity, 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', paddingRight: 40 },\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 AudioAttachmentPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessageInputContextValue<StreamChatGenerics>,\n 'fileUploads' | 'removeFile' | 'uploadFile'\n> & {\n index: number;\n item: Omit<FileUpload, 'state'>;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, pausedStatus?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID?: string;\n};\n\nconst AudioAttachmentWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentPropsWithContext<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, white },\n messageInput: {\n fileUploadPreview: {\n audioAttachment: { 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 backgroundColor: white,\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={120}\n />\n </View>\n </View>\n </View>\n </View>\n </View>\n );\n};\n\nexport type AudioAttachmentProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<AudioAttachmentPropsWithContext<StreamChatGenerics>> & {\n index: number;\n item: Omit<FileUpload, 'state'>;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, pausedStatus?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\n/**\n * AudioAttachment\n * UI Component to preview the audio files\n */\nexport const AudioAttachment = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AudioAttachmentProps<StreamChatGenerics>,\n) => {\n const { fileUploads, removeFile, uploadFile } = useMessageInputContext<StreamChatGenerics>();\n\n return <AudioAttachmentWithContext {...{ fileUploads, removeFile, uploadFile }} {...props} />;\n};\n\nAudioAttachment.displayName = 'AudioAttachment{messageInput{autoAttachment}}';\n"]}
|
|
1
|
+
{"version":3,"sources":["AudioAttachment.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","AudioAttachmentWithContext","props","soundRef","React","useRef","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","static_black","static_white","messageInput","fileUploadPreview","audioAttachment","progressValueInSeconds","progressDuration","format","lastIndexOfDot","name","lastIndexOf","backgroundColor","shadowColor","color","I18nManager","isRTL","writingDirection","slice","AudioAttachment","displayName"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;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AAM,CAACsB,mBAAR,EAA6BA,mBAA7B,CAAb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,gCAAD;AACE,IAAA,QAAQ,EAAEiB,IAAI,CAACzC,QADjB;AAEE,IAAA,WAAW,EAAEwF,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,CADF;AA0ED,CAtND;;AAoOO,IAAMqD,eAAe,GAAG,SAAlBA,eAAkB,CAACxE,KAAD;AAAA,SAC7B,gCAAC,0BAAD,gCAAgCA,KAAhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAD6B;AAAA,CAAxB;;;AAIPwE,eAAe,CAACC,WAAhB,GAA8B,+CAA9B","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 { FileUpload, useTheme } from '../../contexts';\nimport { Pause, Play } from '../../icons';\nimport {\n PlaybackStatus,\n Sound,\n SoundReturnType,\n VideoPayloadData,\n VideoProgressData,\n} from '../../native';\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', paddingRight: 40 },\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 AudioAttachmentPropsWithContext = {\n item: Omit<FileUpload, 'state'>;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, pausedStatus?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID?: string;\n};\n\nconst AudioAttachmentWithContext = (props: AudioAttachmentPropsWithContext) => {\n const soundRef = React.useRef<SoundReturnType | null>(null);\n const { 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, static_black, static_white },\n messageInput: {\n fileUploadPreview: {\n audioAttachment: { progressControlView, progressDurationText, roundedView },\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 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={120}\n />\n </View>\n </View>\n </View>\n </View>\n );\n};\n\nexport type AudioAttachmentProps = Partial<AudioAttachmentPropsWithContext> & {\n item: Omit<FileUpload, 'state'>;\n onLoad: (index: string, duration: number) => void;\n onPlayPause: (index: string, pausedStatus?: boolean) => void;\n onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;\n testID: string;\n};\n\n/**\n * AudioAttachment\n * UI Component to preview the audio files\n */\nexport const AudioAttachment = (props: AudioAttachmentProps) => (\n <AudioAttachmentWithContext {...props} />\n);\n\nAudioAttachment.displayName = 'AudioAttachment{messageInput{autoAttachment}}';\n"]}
|
|
@@ -19,8 +19,6 @@ var _Attachment = require("./Attachment");
|
|
|
19
19
|
|
|
20
20
|
var _MessageContext = require("../../contexts/messageContext/MessageContext");
|
|
21
21
|
|
|
22
|
-
var _MessageInputContext = require("../../contexts/messageInputContext/MessageInputContext");
|
|
23
|
-
|
|
24
22
|
var _MessagesContext = require("../../contexts/messagesContext/MessagesContext");
|
|
25
23
|
|
|
26
24
|
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
|
|
@@ -34,9 +32,20 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
34
32
|
|
|
35
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
36
34
|
|
|
35
|
+
var FILE_PREVIEW_HEIGHT = 60;
|
|
36
|
+
|
|
37
37
|
var styles = _reactNative.StyleSheet.create({
|
|
38
38
|
container: {
|
|
39
39
|
padding: 4
|
|
40
|
+
},
|
|
41
|
+
fileContainer: {
|
|
42
|
+
borderRadius: 12,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
height: FILE_PREVIEW_HEIGHT,
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
paddingLeft: 8,
|
|
48
|
+
paddingRight: 8
|
|
40
49
|
}
|
|
41
50
|
});
|
|
42
51
|
|
|
@@ -104,14 +113,18 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
104
113
|
};
|
|
105
114
|
|
|
106
115
|
var _useTheme = (0, _ThemeContext.useTheme)(),
|
|
107
|
-
|
|
116
|
+
_useTheme$theme = _useTheme.theme,
|
|
117
|
+
_useTheme$theme$color = _useTheme$theme.colors,
|
|
118
|
+
grey_whisper = _useTheme$theme$color.grey_whisper,
|
|
119
|
+
white = _useTheme$theme$color.white,
|
|
120
|
+
container = _useTheme$theme.messageSimple.fileAttachmentGroup.container;
|
|
108
121
|
|
|
109
122
|
return _react["default"].createElement(_reactNative.View, {
|
|
110
123
|
style: [styles.container, container, stylesProp.container],
|
|
111
124
|
__self: _this,
|
|
112
125
|
__source: {
|
|
113
126
|
fileName: _jsxFileName,
|
|
114
|
-
lineNumber:
|
|
127
|
+
lineNumber: 131,
|
|
115
128
|
columnNumber: 5
|
|
116
129
|
}
|
|
117
130
|
}, filesToDisplay.map(function (file, index) {
|
|
@@ -123,19 +136,25 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
123
136
|
__self: _this,
|
|
124
137
|
__source: {
|
|
125
138
|
fileName: _jsxFileName,
|
|
126
|
-
lineNumber:
|
|
139
|
+
lineNumber: 133,
|
|
127
140
|
columnNumber: 9
|
|
128
141
|
}
|
|
129
142
|
}, file.type === 'audio' && (0, _native.isAudioPackageAvailable)() ? _react["default"].createElement(_reactNative.View, {
|
|
130
143
|
accessibilityLabel: "audio-attachment-preview",
|
|
144
|
+
style: [styles.fileContainer, index === filesToDisplay.length - 1 ? {
|
|
145
|
+
marginBottom: 0
|
|
146
|
+
} : {}, {
|
|
147
|
+
backgroundColor: white,
|
|
148
|
+
borderColor: grey_whisper,
|
|
149
|
+
width: -16
|
|
150
|
+
}],
|
|
131
151
|
__self: _this,
|
|
132
152
|
__source: {
|
|
133
153
|
fileName: _jsxFileName,
|
|
134
|
-
lineNumber:
|
|
154
|
+
lineNumber: 141,
|
|
135
155
|
columnNumber: 13
|
|
136
156
|
}
|
|
137
157
|
}, _react["default"].createElement(AudioAttachment, {
|
|
138
|
-
index: index,
|
|
139
158
|
item: {
|
|
140
159
|
duration: file.duration,
|
|
141
160
|
file: {
|
|
@@ -153,7 +172,7 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
153
172
|
__self: _this,
|
|
154
173
|
__source: {
|
|
155
174
|
fileName: _jsxFileName,
|
|
156
|
-
lineNumber:
|
|
175
|
+
lineNumber: 157,
|
|
157
176
|
columnNumber: 15
|
|
158
177
|
}
|
|
159
178
|
})) : _react["default"].createElement(Attachment, {
|
|
@@ -161,7 +180,7 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
161
180
|
__self: _this,
|
|
162
181
|
__source: {
|
|
163
182
|
fileName: _jsxFileName,
|
|
164
|
-
lineNumber:
|
|
183
|
+
lineNumber: 172,
|
|
165
184
|
columnNumber: 13
|
|
166
185
|
}
|
|
167
186
|
}));
|
|
@@ -185,10 +204,8 @@ var FileAttachmentGroup = function FileAttachmentGroup(props) {
|
|
|
185
204
|
|
|
186
205
|
var _useMessagesContext = (0, _MessagesContext.useMessagesContext)(),
|
|
187
206
|
_useMessagesContext$A = _useMessagesContext.Attachment,
|
|
188
|
-
Attachment = _useMessagesContext$A === void 0 ? _Attachment.Attachment : _useMessagesContext$A
|
|
189
|
-
|
|
190
|
-
var _useMessageInputConte = (0, _MessageInputContext.useMessageInputContext)(),
|
|
191
|
-
AudioAttachment = _useMessageInputConte.AudioAttachment;
|
|
207
|
+
Attachment = _useMessagesContext$A === void 0 ? _Attachment.Attachment : _useMessagesContext$A,
|
|
208
|
+
AudioAttachment = _useMessagesContext.AudioAttachment;
|
|
192
209
|
|
|
193
210
|
var files = propFiles || contextFiles;
|
|
194
211
|
if (!files.length) return null;
|
|
@@ -200,7 +217,7 @@ var FileAttachmentGroup = function FileAttachmentGroup(props) {
|
|
|
200
217
|
__self: _this,
|
|
201
218
|
__source: {
|
|
202
219
|
fileName: _jsxFileName,
|
|
203
|
-
lineNumber:
|
|
220
|
+
lineNumber: 217,
|
|
204
221
|
columnNumber: 5
|
|
205
222
|
}
|
|
206
223
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FileAttachmentGroup.tsx"],"names":["styles","StyleSheet","create","container","padding","FileAttachmentGroupWithContext","props","Attachment","AudioAttachment","files","messageId","stylesProp","filesToDisplay","setFilesToDisplay","map","file","duration","paused","progress","onLoad","index","prevFilesToDisplay","fileToDisplay","id","toString","onProgress","currentTime","hasEnd","prevFileUploads","fileUpload","onPlayPause","pausedStatus","theme","messageSimple","fileAttachmentGroup","paddingBottom","length","attachmentContainer","type","name","title","uri","asset_url","areEqual","prevProps","nextProps","prevFiles","nextFiles","MemoizedFileAttachmentGroup","React","memo","FileAttachmentGroup","propFiles","contextFiles","AttachmentDefault","displayName"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AAEA;;AAIA;;AAIA;;AAIA;;AACA;;;;;;;;;AAIA,IAAMA,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC/BC,EAAAA,SAAS,EAAE;AACTC,IAAAA,OAAO,EAAE;AADA;AADoB,CAAlB,CAAf;;AA6BA,IAAMC,8BAA8B,GAA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,GAA6BF,SAA7B,CAAQpC,KAAR;AAEA,SAAOqC,SAAS,CAACV,MAAV,KAAqBW,SAAS,CAACX,MAAtC;AACD,CARD;;AAUA,IAAMY,2BAA2B,GAAGC,kBAAMC,IAAN,CAClC7C,8BADkC,EAElCsC,QAFkC,CAApC;;AAUO,IAAMQ,mBAAmB,GAAG,SAAtBA,mBAAsB,CAGjC7C,KAHiC,EAI9B;AACH,MAAe8C,SAAf,GAAwC9C,KAAxC,CAAQG,KAAR;AAAA,MAA0BC,SAA1B,GAAwCJ,KAAxC,CAA0BI,SAA1B;;AAEA,2BAAgC,wCAAhC;AAAA,MAAe2C,YAAf,sBAAQ5C,KAAR;;AAEA,4BAA2C,0CAA3C;AAAA,kDAAQF,UAAR;AAAA,MAAQA,UAAR,sCAAqB+C,sBAArB;;AAEA,8BAA4B,kDAA5B;AAAA,MAAQ9C,eAAR,yBAAQA,eAAR;;AAEA,MAAMC,KAAK,GAAG2C,SAAS,IAAIC,YAA3B;AAEA,MAAI,CAAC5C,KAAK,CAAC2B,MAAX,EAAmB,OAAO,IAAP;AAEnB,SACE,gCAAC,2BAAD;AAEI7B,IAAAA,UAAU,EAAVA,UAFJ;AAGIC,IAAAA,eAAe,EAAfA,eAHJ;AAIIC,IAAAA,KAAK,EAALA,KAJJ;AAKIC,IAAAA,SAAS,EAATA,SALJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF;AAUD,CA3BM;;;AA6BPyC,mBAAmB,CAACI,WAApB,GAAkC,yDAAlC","sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\n\nimport type { Attachment } from 'stream-chat';\n\nimport { Attachment as AttachmentDefault } from './Attachment';\n\nimport {\n MessageContextValue,\n useMessageContext,\n} from '../../contexts/messageContext/MessageContext';\nimport {\n MessageInputContextValue,\n useMessageInputContext,\n} from '../../contexts/messageInputContext/MessageInputContext';\nimport {\n MessagesContextValue,\n useMessagesContext,\n} from '../../contexts/messagesContext/MessagesContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { isAudioPackageAvailable } from '../../native';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\n\nconst styles = StyleSheet.create({\n container: {\n padding: 4,\n },\n});\n\nexport type FileAttachmentGroupPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<MessageContextValue<StreamChatGenerics>, 'files'> &\n Pick<MessageInputContextValue<StreamChatGenerics>, 'AudioAttachment'> &\n Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment'> & {\n /**\n * The unique id for the message with file attachments\n */\n messageId: string;\n styles?: Partial<{\n attachmentContainer: StyleProp<ViewStyle>;\n container: StyleProp<ViewStyle>;\n }>;\n };\n\ntype FilesToDisplayType<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Attachment<StreamChatGenerics> & {\n duration: number;\n paused: boolean;\n progress: number;\n};\n\nconst FileAttachmentGroupWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n) => {\n const { Attachment, AudioAttachment, files, messageId, styles: stylesProp = {} } = props;\n const [filesToDisplay, setFilesToDisplay] = useState<FilesToDisplayType[]>([]);\n\n useEffect(() => {\n setFilesToDisplay(files.map((file) => ({ ...file, duration: 0, paused: true, progress: 0 })));\n }, [files]);\n\n // Handler triggered when an audio is loaded in the message input. The initial state is defined for the audio here and the duration is set.\n const onLoad = (index: string, duration: number) => {\n setFilesToDisplay((prevFilesToDisplay) =>\n prevFilesToDisplay.map((fileToDisplay, id) => ({\n ...fileToDisplay,\n duration: id.toString() === index ? duration : fileToDisplay.duration,\n })),\n );\n };\n\n // The handler which is triggered when the audio progresses/ the thumb is dragged in the progress control. The progressed duration is set here.\n const onProgress = (index: string, currentTime?: number, hasEnd?: boolean) => {\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload, id) => ({\n ...fileUpload,\n progress:\n id.toString() === index\n ? hasEnd\n ? 1\n : currentTime\n ? currentTime / (fileUpload.duration as number)\n : 0\n : fileUpload.progress,\n })),\n );\n };\n\n // The handler which controls or sets the paused/played state of the audio.\n const onPlayPause = (index: string, pausedStatus?: boolean) => {\n if (pausedStatus === false) {\n // If the status is false we set the audio with the index as playing and the others as paused.\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload, id) => ({\n ...fileUpload,\n paused: id.toString() === index ? false : true,\n })),\n );\n } else {\n // If the status is true we simply set all the audio's paused state as true.\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload) => ({\n ...fileUpload,\n paused: true,\n })),\n );\n }\n };\n\n const {\n theme: {\n messageSimple: {\n fileAttachmentGroup: { container },\n },\n },\n } = useTheme();\n\n return (\n <View style={[styles.container, container, stylesProp.container]}>\n {filesToDisplay.map((file, index) => (\n <View\n key={`${messageId}-${index}`}\n style={[\n { paddingBottom: index !== files.length - 1 ? 4 : 0 },\n stylesProp.attachmentContainer,\n ]}\n >\n {file.type === 'audio' && isAudioPackageAvailable() ? (\n <View accessibilityLabel='audio-attachment-preview'>\n <AudioAttachment\n index={index}\n item={{\n duration: file.duration,\n file: { name: file.title as string, uri: file.asset_url },\n id: index.toString(),\n paused: file.paused,\n progress: file.progress,\n }}\n onLoad={onLoad}\n onPlayPause={onPlayPause}\n onProgress={onProgress}\n testID='audio-attachment-preview'\n />\n </View>\n ) : (\n <Attachment attachment={file} />\n )}\n </View>\n ))}\n </View>\n );\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n nextProps: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n) => {\n const { files: prevFiles } = prevProps;\n const { files: nextFiles } = nextProps;\n\n return prevFiles.length === nextFiles.length;\n};\n\nconst MemoizedFileAttachmentGroup = React.memo(\n FileAttachmentGroupWithContext,\n areEqual,\n) as typeof FileAttachmentGroupWithContext;\n\nexport type FileAttachmentGroupProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<Omit<FileAttachmentGroupPropsWithContext<StreamChatGenerics>, 'messageId'>> &\n Pick<FileAttachmentGroupPropsWithContext<StreamChatGenerics>, 'messageId'>;\n\nexport const FileAttachmentGroup = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: FileAttachmentGroupProps<StreamChatGenerics>,\n) => {\n const { files: propFiles, messageId } = props;\n\n const { files: contextFiles } = useMessageContext<StreamChatGenerics>();\n\n const { Attachment = AttachmentDefault } = useMessagesContext<StreamChatGenerics>();\n\n const { AudioAttachment } = useMessageInputContext<StreamChatGenerics>();\n\n const files = propFiles || contextFiles;\n\n if (!files.length) return null;\n\n return (\n <MemoizedFileAttachmentGroup\n {...{\n Attachment,\n AudioAttachment,\n files,\n messageId,\n }}\n />\n );\n};\n\nFileAttachmentGroup.displayName = 'FileAttachmentGroup{messageSimple{fileAttachmentGroup}}';\n"]}
|
|
1
|
+
{"version":3,"sources":["FileAttachmentGroup.tsx"],"names":["FILE_PREVIEW_HEIGHT","styles","StyleSheet","create","container","padding","fileContainer","borderRadius","borderWidth","flexDirection","height","justifyContent","paddingLeft","paddingRight","FileAttachmentGroupWithContext","props","Attachment","AudioAttachment","files","messageId","stylesProp","filesToDisplay","setFilesToDisplay","map","file","duration","paused","progress","onLoad","index","prevFilesToDisplay","fileToDisplay","id","toString","onProgress","currentTime","hasEnd","prevFileUploads","fileUpload","onPlayPause","pausedStatus","theme","colors","grey_whisper","white","messageSimple","fileAttachmentGroup","paddingBottom","length","attachmentContainer","type","marginBottom","backgroundColor","borderColor","width","name","title","uri","asset_url","areEqual","prevProps","nextProps","prevFiles","nextFiles","MemoizedFileAttachmentGroup","React","memo","FileAttachmentGroup","propFiles","contextFiles","AttachmentDef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KAAxC,CAA0BI,SAA1B;;AAEA,2BAAgC,wCAAhC;AAAA,MAAekD,YAAf,sBAAQnD,KAAR;;AAEA,4BACE,0CADF;AAAA,kDAAQF,UAAR;AAAA,MAAQA,UAAR,sCAAqBsD,sBAArB;AAAA,MAAwCrD,eAAxC,uBAAwCA,eAAxC;;AAGA,MAAMC,KAAK,GAAGkD,SAAS,IAAIC,YAA3B;AAEA,MAAI,CAACnD,KAAK,CAAC8B,MAAX,EAAmB,OAAO,IAAP;AAEnB,SACE,gCAAC,2BAAD;AAEIhC,IAAAA,UAAU,EAAVA,UAFJ;AAGIC,IAAAA,eAAe,EAAfA,eAHJ;AAIIC,IAAAA,KAAK,EAALA,KAJJ;AAKIC,IAAAA,SAAS,EAATA,SALJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF;AAUD,CA1BM;;;AA4BPgD,mBAAmB,CAACI,WAApB,GAAkC,yDAAlC","sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\n\nimport type { Attachment } from 'stream-chat';\n\nimport { Attachment as AttachmentDefault } from './Attachment';\n\nimport {\n MessageContextValue,\n useMessageContext,\n} from '../../contexts/messageContext/MessageContext';\n\nimport {\n MessagesContextValue,\n useMessagesContext,\n} from '../../contexts/messagesContext/MessagesContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { isAudioPackageAvailable } from '../../native';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\n\nconst FILE_PREVIEW_HEIGHT = 60;\n\nconst styles = StyleSheet.create({\n container: {\n padding: 4,\n },\n fileContainer: {\n borderRadius: 12,\n borderWidth: 1,\n flexDirection: 'row',\n height: FILE_PREVIEW_HEIGHT,\n justifyContent: 'space-between',\n paddingLeft: 8,\n paddingRight: 8,\n },\n});\n\nexport type FileAttachmentGroupPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<MessageContextValue<StreamChatGenerics>, 'files'> &\n Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment' | 'AudioAttachment'> & {\n /**\n * The unique id for the message with file attachments\n */\n messageId: string;\n styles?: Partial<{\n attachmentContainer: StyleProp<ViewStyle>;\n container: StyleProp<ViewStyle>;\n }>;\n };\n\ntype FilesToDisplayType<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Attachment<StreamChatGenerics> & {\n duration: number;\n paused: boolean;\n progress: number;\n};\n\nconst FileAttachmentGroupWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n) => {\n const { Attachment, AudioAttachment, files, messageId, styles: stylesProp = {} } = props;\n const [filesToDisplay, setFilesToDisplay] = useState<FilesToDisplayType[]>([]);\n\n useEffect(() => {\n setFilesToDisplay(files.map((file) => ({ ...file, duration: 0, paused: true, progress: 0 })));\n }, [files]);\n\n // Handler triggered when an audio is loaded in the message input. The initial state is defined for the audio here and the duration is set.\n const onLoad = (index: string, duration: number) => {\n setFilesToDisplay((prevFilesToDisplay) =>\n prevFilesToDisplay.map((fileToDisplay, id) => ({\n ...fileToDisplay,\n duration: id.toString() === index ? duration : fileToDisplay.duration,\n })),\n );\n };\n\n // The handler which is triggered when the audio progresses/ the thumb is dragged in the progress control. The progressed duration is set here.\n const onProgress = (index: string, currentTime?: number, hasEnd?: boolean) => {\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload, id) => ({\n ...fileUpload,\n progress:\n id.toString() === index\n ? hasEnd\n ? 1\n : currentTime\n ? currentTime / (fileUpload.duration as number)\n : 0\n : fileUpload.progress,\n })),\n );\n };\n\n // The handler which controls or sets the paused/played state of the audio.\n const onPlayPause = (index: string, pausedStatus?: boolean) => {\n if (pausedStatus === false) {\n // If the status is false we set the audio with the index as playing and the others as paused.\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload, id) => ({\n ...fileUpload,\n paused: id.toString() === index ? false : true,\n })),\n );\n } else {\n // If the status is true we simply set all the audio's paused state as true.\n setFilesToDisplay((prevFileUploads) =>\n prevFileUploads.map((fileUpload) => ({\n ...fileUpload,\n paused: true,\n })),\n );\n }\n };\n\n const {\n theme: {\n colors: { grey_whisper, white },\n messageSimple: {\n fileAttachmentGroup: { container },\n },\n },\n } = useTheme();\n\n return (\n <View style={[styles.container, container, stylesProp.container]}>\n {filesToDisplay.map((file, index) => (\n <View\n key={`${messageId}-${index}`}\n style={[\n { paddingBottom: index !== files.length - 1 ? 4 : 0 },\n stylesProp.attachmentContainer,\n ]}\n >\n {file.type === 'audio' && isAudioPackageAvailable() ? (\n <View\n accessibilityLabel='audio-attachment-preview'\n style={[\n styles.fileContainer,\n index === filesToDisplay.length - 1\n ? {\n marginBottom: 0,\n }\n : {},\n {\n backgroundColor: white,\n borderColor: grey_whisper,\n width: -16,\n },\n ]}\n >\n <AudioAttachment\n item={{\n duration: file.duration,\n file: { name: file.title as string, uri: file.asset_url },\n id: index.toString(),\n paused: file.paused,\n progress: file.progress,\n }}\n onLoad={onLoad}\n onPlayPause={onPlayPause}\n onProgress={onProgress}\n testID='audio-attachment-preview'\n />\n </View>\n ) : (\n <Attachment attachment={file} />\n )}\n </View>\n ))}\n </View>\n );\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n nextProps: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n) => {\n const { files: prevFiles } = prevProps;\n const { files: nextFiles } = nextProps;\n\n return prevFiles.length === nextFiles.length;\n};\n\nconst MemoizedFileAttachmentGroup = React.memo(\n FileAttachmentGroupWithContext,\n areEqual,\n) as typeof FileAttachmentGroupWithContext;\n\nexport type FileAttachmentGroupProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<Omit<FileAttachmentGroupPropsWithContext<StreamChatGenerics>, 'messageId'>> &\n Pick<FileAttachmentGroupPropsWithContext<StreamChatGenerics>, 'messageId'>;\n\nexport const FileAttachmentGroup = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: FileAttachmentGroupProps<StreamChatGenerics>,\n) => {\n const { files: propFiles, messageId } = props;\n\n const { files: contextFiles } = useMessageContext<StreamChatGenerics>();\n\n const { Attachment = AttachmentDefault, AudioAttachment } =\n useMessagesContext<StreamChatGenerics>();\n\n const files = propFiles || contextFiles;\n\n if (!files.length) return null;\n\n return (\n <MemoizedFileAttachmentGroup\n {...{\n Attachment,\n AudioAttachment,\n files,\n messageId,\n }}\n />\n );\n};\n\nFileAttachmentGroup.displayName = 'FileAttachmentGroup{messageSimple{fileAttachmentGroup}}';\n"]}
|
|
@@ -78,6 +78,12 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
78
78
|
left: 4,
|
|
79
79
|
position: 'absolute'
|
|
80
80
|
},
|
|
81
|
+
imageLoadingIndicatorContainer: {
|
|
82
|
+
height: '100%',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
width: '100%'
|
|
86
|
+
},
|
|
81
87
|
imageLoadingIndicatorStyle: {
|
|
82
88
|
alignItems: 'center',
|
|
83
89
|
justifyContent: 'center',
|
|
@@ -161,7 +167,7 @@ var GalleryWithContext = function GalleryWithContext(props) {
|
|
|
161
167
|
__self: _this,
|
|
162
168
|
__source: {
|
|
163
169
|
fileName: _jsxFileName,
|
|
164
|
-
lineNumber:
|
|
170
|
+
lineNumber: 192,
|
|
165
171
|
columnNumber: 5
|
|
166
172
|
}
|
|
167
173
|
}, thumbnailGrid.map(function (rows, colIndex) {
|
|
@@ -175,7 +181,7 @@ var GalleryWithContext = function GalleryWithContext(props) {
|
|
|
175
181
|
__self: _this,
|
|
176
182
|
__source: {
|
|
177
183
|
fileName: _jsxFileName,
|
|
178
|
-
lineNumber:
|
|
184
|
+
lineNumber: 209,
|
|
179
185
|
columnNumber: 11
|
|
180
186
|
}
|
|
181
187
|
}, rows.map(function (thumbnail, rowIndex) {
|
|
@@ -225,7 +231,7 @@ var GalleryWithContext = function GalleryWithContext(props) {
|
|
|
225
231
|
__self: _this,
|
|
226
232
|
__source: {
|
|
227
233
|
fileName: _jsxFileName,
|
|
228
|
-
lineNumber:
|
|
234
|
+
lineNumber: 241,
|
|
229
235
|
columnNumber: 17
|
|
230
236
|
}
|
|
231
237
|
});
|
|
@@ -329,7 +335,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
329
335
|
__self: _this,
|
|
330
336
|
__source: {
|
|
331
337
|
fileName: _jsxFileName,
|
|
332
|
-
lineNumber:
|
|
338
|
+
lineNumber: 365,
|
|
333
339
|
columnNumber: 5
|
|
334
340
|
}
|
|
335
341
|
}), thumbnail.type === 'video' ? _react["default"].createElement(VideoThumbnail, {
|
|
@@ -341,7 +347,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
341
347
|
__self: _this,
|
|
342
348
|
__source: {
|
|
343
349
|
fileName: _jsxFileName,
|
|
344
|
-
lineNumber:
|
|
350
|
+
lineNumber: 407,
|
|
345
351
|
columnNumber: 9
|
|
346
352
|
}
|
|
347
353
|
}) : _react["default"].createElement(_reactNative.View, {
|
|
@@ -349,7 +355,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
349
355
|
__self: _this,
|
|
350
356
|
__source: {
|
|
351
357
|
fileName: _jsxFileName,
|
|
352
|
-
lineNumber:
|
|
358
|
+
lineNumber: 419,
|
|
353
359
|
columnNumber: 9
|
|
354
360
|
}
|
|
355
361
|
}, _react["default"].createElement(GalleryImageThumbnail, {
|
|
@@ -360,7 +366,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
360
366
|
__self: _this,
|
|
361
367
|
__source: {
|
|
362
368
|
fileName: _jsxFileName,
|
|
363
|
-
lineNumber:
|
|
369
|
+
lineNumber: 420,
|
|
364
370
|
columnNumber: 11
|
|
365
371
|
}
|
|
366
372
|
})), colIndex === numOfColumns - 1 && rowIndex === numOfRows - 1 && imagesAndVideos.length > 4 ? _react["default"].createElement(_reactNative.View, {
|
|
@@ -370,7 +376,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
370
376
|
__self: _this,
|
|
371
377
|
__source: {
|
|
372
378
|
fileName: _jsxFileName,
|
|
373
|
-
lineNumber:
|
|
379
|
+
lineNumber: 429,
|
|
374
380
|
columnNumber: 9
|
|
375
381
|
}
|
|
376
382
|
}, _react["default"].createElement(_reactNative.Text, {
|
|
@@ -378,7 +384,7 @@ var GalleryThumbnail = function GalleryThumbnail(_ref) {
|
|
|
378
384
|
__self: _this,
|
|
379
385
|
__source: {
|
|
380
386
|
fileName: _jsxFileName,
|
|
381
|
-
lineNumber:
|
|
387
|
+
lineNumber: 437,
|
|
382
388
|
columnNumber: 11
|
|
383
389
|
}
|
|
384
390
|
}, "+" + (imagesAndVideos.length - 4))) : null);
|
|
@@ -407,7 +413,7 @@ var GalleryImageThumbnail = function GalleryImageThumbnail(_ref2) {
|
|
|
407
413
|
__self: _this,
|
|
408
414
|
__source: {
|
|
409
415
|
fileName: _jsxFileName,
|
|
410
|
-
lineNumber:
|
|
416
|
+
lineNumber: 469,
|
|
411
417
|
columnNumber: 5
|
|
412
418
|
}
|
|
413
419
|
}, isLoadingImageError ? _react["default"].createElement(ImageLoadingFailedIndicator, {
|
|
@@ -415,7 +421,7 @@ var GalleryImageThumbnail = function GalleryImageThumbnail(_ref2) {
|
|
|
415
421
|
__self: _this,
|
|
416
422
|
__source: {
|
|
417
423
|
fileName: _jsxFileName,
|
|
418
|
-
lineNumber:
|
|
424
|
+
lineNumber: 476,
|
|
419
425
|
columnNumber: 9
|
|
420
426
|
}
|
|
421
427
|
}) : _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(MemoizedGalleryImage, {
|
|
@@ -439,17 +445,15 @@ var GalleryImageThumbnail = function GalleryImageThumbnail(_ref2) {
|
|
|
439
445
|
__self: _this,
|
|
440
446
|
__source: {
|
|
441
447
|
fileName: _jsxFileName,
|
|
442
|
-
lineNumber:
|
|
448
|
+
lineNumber: 479,
|
|
443
449
|
columnNumber: 11
|
|
444
450
|
}
|
|
445
451
|
}), isLoadingImage && _react["default"].createElement(_reactNative.View, {
|
|
446
|
-
style:
|
|
447
|
-
position: 'absolute'
|
|
448
|
-
},
|
|
452
|
+
style: [styles.imageLoadingIndicatorContainer],
|
|
449
453
|
__self: _this,
|
|
450
454
|
__source: {
|
|
451
455
|
fileName: _jsxFileName,
|
|
452
|
-
lineNumber:
|
|
456
|
+
lineNumber: 499,
|
|
453
457
|
columnNumber: 13
|
|
454
458
|
}
|
|
455
459
|
}, _react["default"].createElement(ImageLoadingIndicator, {
|
|
@@ -457,7 +461,7 @@ var GalleryImageThumbnail = function GalleryImageThumbnail(_ref2) {
|
|
|
457
461
|
__self: _this,
|
|
458
462
|
__source: {
|
|
459
463
|
fileName: _jsxFileName,
|
|
460
|
-
lineNumber:
|
|
464
|
+
lineNumber: 500,
|
|
461
465
|
columnNumber: 15
|
|
462
466
|
}
|
|
463
467
|
}))));
|
|
@@ -577,7 +581,7 @@ var Gallery = function Gallery(props) {
|
|
|
577
581
|
__self: _this,
|
|
578
582
|
__source: {
|
|
579
583
|
fileName: _jsxFileName,
|
|
580
|
-
lineNumber:
|
|
584
|
+
lineNumber: 636,
|
|
581
585
|
columnNumber: 5
|
|
582
586
|
}
|
|
583
587
|
});
|