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
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.AudioAttachment = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -30,7 +30,7 @@ var _native = require("../../native");
|
|
|
30
30
|
var _ProgressControl = require("../ProgressControl/ProgressControl");
|
|
31
31
|
|
|
32
32
|
var _this = this,
|
|
33
|
-
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/
|
|
33
|
+
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Attachment/AudioAttachment.tsx";
|
|
34
34
|
|
|
35
35
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
36
36
|
|
|
@@ -50,7 +50,8 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
50
50
|
paddingRight: 8
|
|
51
51
|
},
|
|
52
52
|
fileContentContainer: {
|
|
53
|
-
flexDirection: 'row'
|
|
53
|
+
flexDirection: 'row',
|
|
54
|
+
paddingRight: 40
|
|
54
55
|
},
|
|
55
56
|
filenameText: {
|
|
56
57
|
fontSize: 14,
|
|
@@ -96,12 +97,10 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
|
|
99
|
-
var
|
|
100
|
+
var AudioAttachmentWithContext = function AudioAttachmentWithContext(props) {
|
|
100
101
|
var soundRef = _react["default"].useRef(null);
|
|
101
102
|
|
|
102
|
-
var
|
|
103
|
-
index = props.index,
|
|
104
|
-
item = props.item,
|
|
103
|
+
var item = props.item,
|
|
105
104
|
onLoad = props.onLoad,
|
|
106
105
|
onPlayPause = props.onPlayPause,
|
|
107
106
|
onProgress = props.onProgress;
|
|
@@ -354,15 +353,13 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
354
353
|
accent_blue = _useTheme$theme$color.accent_blue,
|
|
355
354
|
black = _useTheme$theme$color.black,
|
|
356
355
|
grey_dark = _useTheme$theme$color.grey_dark,
|
|
357
|
-
grey_whisper = _useTheme$theme$color.grey_whisper,
|
|
358
356
|
static_black = _useTheme$theme$color.static_black,
|
|
359
357
|
static_white = _useTheme$theme$color.static_white,
|
|
360
358
|
_useTheme$theme$messa = _useTheme$theme.messageInput.fileUploadPreview,
|
|
361
|
-
_useTheme$theme$messa2 = _useTheme$theme$messa.
|
|
359
|
+
_useTheme$theme$messa2 = _useTheme$theme$messa.audioAttachment,
|
|
362
360
|
progressControlView = _useTheme$theme$messa2.progressControlView,
|
|
363
361
|
progressDurationText = _useTheme$theme$messa2.progressDurationText,
|
|
364
362
|
roundedView = _useTheme$theme$messa2.roundedView,
|
|
365
|
-
fileContainer = _useTheme$theme$messa.fileContainer,
|
|
366
363
|
fileContentContainer = _useTheme$theme$messa.fileContentContainer,
|
|
367
364
|
filenameText = _useTheme$theme$messa.filenameText,
|
|
368
365
|
fileTextContainer = _useTheme$theme$messa.fileTextContainer;
|
|
@@ -371,26 +368,12 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
371
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';
|
|
372
369
|
var lastIndexOfDot = item.file.name.lastIndexOf('.');
|
|
373
370
|
return _react["default"].createElement(_reactNative.View, {
|
|
374
|
-
style: [styles.fileContainer, index === fileUploads.length - 1 ? {
|
|
375
|
-
marginBottom: 0
|
|
376
|
-
} : {}, {
|
|
377
|
-
borderColor: grey_whisper,
|
|
378
|
-
width: -16
|
|
379
|
-
}, fileContainer],
|
|
380
|
-
testID: "audio-attachment-upload-preview",
|
|
381
|
-
__self: _this,
|
|
382
|
-
__source: {
|
|
383
|
-
fileName: _jsxFileName,
|
|
384
|
-
lineNumber: 239,
|
|
385
|
-
columnNumber: 5
|
|
386
|
-
}
|
|
387
|
-
}, _react["default"].createElement(_reactNative.View, {
|
|
388
371
|
style: [styles.fileContentContainer, fileContentContainer],
|
|
389
372
|
__self: _this,
|
|
390
373
|
__source: {
|
|
391
374
|
fileName: _jsxFileName,
|
|
392
|
-
lineNumber:
|
|
393
|
-
columnNumber:
|
|
375
|
+
lineNumber: 222,
|
|
376
|
+
columnNumber: 5
|
|
394
377
|
}
|
|
395
378
|
}, _react["default"].createElement(_reactNative.TouchableOpacity, {
|
|
396
379
|
accessibilityLabel: "Play Pause Button",
|
|
@@ -404,8 +387,8 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
404
387
|
__self: _this,
|
|
405
388
|
__source: {
|
|
406
389
|
fileName: _jsxFileName,
|
|
407
|
-
lineNumber:
|
|
408
|
-
columnNumber:
|
|
390
|
+
lineNumber: 223,
|
|
391
|
+
columnNumber: 7
|
|
409
392
|
}
|
|
410
393
|
}, item.paused ? _react["default"].createElement(_icons.Play, {
|
|
411
394
|
height: 24,
|
|
@@ -414,8 +397,8 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
414
397
|
__self: _this,
|
|
415
398
|
__source: {
|
|
416
399
|
fileName: _jsxFileName,
|
|
417
|
-
lineNumber:
|
|
418
|
-
columnNumber:
|
|
400
|
+
lineNumber: 233,
|
|
401
|
+
columnNumber: 11
|
|
419
402
|
}
|
|
420
403
|
}) : _react["default"].createElement(_icons.Pause, {
|
|
421
404
|
height: 24,
|
|
@@ -424,16 +407,16 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
424
407
|
__self: _this,
|
|
425
408
|
__source: {
|
|
426
409
|
fileName: _jsxFileName,
|
|
427
|
-
lineNumber:
|
|
428
|
-
columnNumber:
|
|
410
|
+
lineNumber: 235,
|
|
411
|
+
columnNumber: 11
|
|
429
412
|
}
|
|
430
413
|
})), _react["default"].createElement(_reactNative.View, {
|
|
431
414
|
style: [styles.fileTextContainer, fileTextContainer],
|
|
432
415
|
__self: _this,
|
|
433
416
|
__source: {
|
|
434
417
|
fileName: _jsxFileName,
|
|
435
|
-
lineNumber:
|
|
436
|
-
columnNumber:
|
|
418
|
+
lineNumber: 238,
|
|
419
|
+
columnNumber: 7
|
|
437
420
|
}
|
|
438
421
|
}, _react["default"].createElement(_reactNative.Text, {
|
|
439
422
|
accessibilityLabel: "File Name",
|
|
@@ -449,8 +432,8 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
449
432
|
__self: _this,
|
|
450
433
|
__source: {
|
|
451
434
|
fileName: _jsxFileName,
|
|
452
|
-
lineNumber:
|
|
453
|
-
columnNumber:
|
|
435
|
+
lineNumber: 239,
|
|
436
|
+
columnNumber: 9
|
|
454
437
|
}
|
|
455
438
|
}, item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)), _react["default"].createElement(_reactNative.View, {
|
|
456
439
|
style: {
|
|
@@ -461,8 +444,8 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
461
444
|
__self: _this,
|
|
462
445
|
__source: {
|
|
463
446
|
fileName: _jsxFileName,
|
|
464
|
-
lineNumber:
|
|
465
|
-
columnNumber:
|
|
447
|
+
lineNumber: 258,
|
|
448
|
+
columnNumber: 9
|
|
466
449
|
}
|
|
467
450
|
}, _native.Sound.Player && _react["default"].createElement(_native.Sound.Player, {
|
|
468
451
|
onEnd: handleEnd,
|
|
@@ -475,8 +458,8 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
475
458
|
__self: _this,
|
|
476
459
|
__source: {
|
|
477
460
|
fileName: _jsxFileName,
|
|
478
|
-
lineNumber:
|
|
479
|
-
columnNumber:
|
|
461
|
+
lineNumber: 267,
|
|
462
|
+
columnNumber: 13
|
|
480
463
|
}
|
|
481
464
|
}), _react["default"].createElement(_reactNative.Text, {
|
|
482
465
|
style: [styles.progressDurationText, {
|
|
@@ -485,16 +468,16 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
485
468
|
__self: _this,
|
|
486
469
|
__source: {
|
|
487
470
|
fileName: _jsxFileName,
|
|
488
|
-
lineNumber:
|
|
489
|
-
columnNumber:
|
|
471
|
+
lineNumber: 277,
|
|
472
|
+
columnNumber: 11
|
|
490
473
|
}
|
|
491
474
|
}, progressDuration), _react["default"].createElement(_reactNative.View, {
|
|
492
475
|
style: [styles.progressControlView, progressControlView],
|
|
493
476
|
__self: _this,
|
|
494
477
|
__source: {
|
|
495
478
|
fileName: _jsxFileName,
|
|
496
|
-
lineNumber:
|
|
497
|
-
columnNumber:
|
|
479
|
+
lineNumber: 280,
|
|
480
|
+
columnNumber: 11
|
|
498
481
|
}
|
|
499
482
|
}, _react["default"].createElement(_ProgressControl.ProgressControl, {
|
|
500
483
|
duration: item.duration,
|
|
@@ -503,36 +486,27 @@ var AudioAttachmentUploadPreviewWithContext = function AudioAttachmentUploadPrev
|
|
|
503
486
|
onProgressDrag: handleProgressDrag,
|
|
504
487
|
progress: item.progress,
|
|
505
488
|
testID: "progress-control",
|
|
506
|
-
width:
|
|
489
|
+
width: 120,
|
|
507
490
|
__self: _this,
|
|
508
491
|
__source: {
|
|
509
492
|
fileName: _jsxFileName,
|
|
510
|
-
lineNumber:
|
|
511
|
-
columnNumber:
|
|
493
|
+
lineNumber: 281,
|
|
494
|
+
columnNumber: 13
|
|
512
495
|
}
|
|
513
|
-
})))))
|
|
496
|
+
})))));
|
|
514
497
|
};
|
|
515
498
|
|
|
516
|
-
var
|
|
517
|
-
|
|
518
|
-
fileUploads = _useMessageInputConte.fileUploads,
|
|
519
|
-
removeFile = _useMessageInputConte.removeFile,
|
|
520
|
-
uploadFile = _useMessageInputConte.uploadFile;
|
|
521
|
-
|
|
522
|
-
return _react["default"].createElement(AudioAttachmentUploadPreviewWithContext, (0, _extends2["default"])({
|
|
523
|
-
fileUploads: fileUploads,
|
|
524
|
-
removeFile: removeFile,
|
|
525
|
-
uploadFile: uploadFile
|
|
526
|
-
}, props, {
|
|
499
|
+
var AudioAttachment = function AudioAttachment(props) {
|
|
500
|
+
return _react["default"].createElement(AudioAttachmentWithContext, (0, _extends2["default"])({}, props, {
|
|
527
501
|
__self: _this,
|
|
528
502
|
__source: {
|
|
529
503
|
fileName: _jsxFileName,
|
|
530
|
-
lineNumber:
|
|
531
|
-
columnNumber:
|
|
504
|
+
lineNumber: 310,
|
|
505
|
+
columnNumber: 3
|
|
532
506
|
}
|
|
533
507
|
}));
|
|
534
508
|
};
|
|
535
509
|
|
|
536
|
-
exports.
|
|
537
|
-
|
|
538
|
-
//# sourceMappingURL=
|
|
510
|
+
exports.AudioAttachment = AudioAttachment;
|
|
511
|
+
AudioAttachment.displayName = 'AudioAttachment{messageInput{autoAttachment}}';
|
|
512
|
+
//# sourceMappingURL=AudioAttachment.js.map
|
|
@@ -0,0 +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","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;;AACA;;AAEA;;AACA;;AACA;;AAOA;;;;;;;;;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,I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AQ,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"]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
2
|
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.FileAttachmentGroup = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
15
|
|
|
10
16
|
var _reactNative = require("react-native");
|
|
11
17
|
|
|
@@ -17,34 +23,111 @@ var _MessagesContext = require("../../contexts/messagesContext/MessagesContext")
|
|
|
17
23
|
|
|
18
24
|
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
|
|
19
25
|
|
|
26
|
+
var _native = require("../../native");
|
|
27
|
+
|
|
20
28
|
var _this = this,
|
|
21
29
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Attachment/FileAttachmentGroup.tsx";
|
|
22
30
|
|
|
31
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
+
|
|
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; }
|
|
34
|
+
|
|
35
|
+
var FILE_PREVIEW_HEIGHT = 60;
|
|
36
|
+
|
|
23
37
|
var styles = _reactNative.StyleSheet.create({
|
|
24
38
|
container: {
|
|
25
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
|
|
26
49
|
}
|
|
27
50
|
});
|
|
28
51
|
|
|
29
52
|
var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(props) {
|
|
30
53
|
var Attachment = props.Attachment,
|
|
54
|
+
AudioAttachment = props.AudioAttachment,
|
|
31
55
|
files = props.files,
|
|
32
56
|
messageId = props.messageId,
|
|
33
57
|
_props$styles = props.styles,
|
|
34
58
|
stylesProp = _props$styles === void 0 ? {} : _props$styles;
|
|
35
59
|
|
|
60
|
+
var _useState = (0, _react.useState)([]),
|
|
61
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
62
|
+
filesToDisplay = _useState2[0],
|
|
63
|
+
setFilesToDisplay = _useState2[1];
|
|
64
|
+
|
|
65
|
+
(0, _react.useEffect)(function () {
|
|
66
|
+
setFilesToDisplay(files.map(function (file) {
|
|
67
|
+
return (0, _extends2["default"])({}, file, {
|
|
68
|
+
duration: 0,
|
|
69
|
+
paused: true,
|
|
70
|
+
progress: 0
|
|
71
|
+
});
|
|
72
|
+
}));
|
|
73
|
+
}, [files]);
|
|
74
|
+
|
|
75
|
+
var onLoad = function onLoad(index, duration) {
|
|
76
|
+
setFilesToDisplay(function (prevFilesToDisplay) {
|
|
77
|
+
return prevFilesToDisplay.map(function (fileToDisplay, id) {
|
|
78
|
+
return (0, _extends2["default"])({}, fileToDisplay, {
|
|
79
|
+
duration: id.toString() === index ? duration : fileToDisplay.duration
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var onProgress = function onProgress(index, currentTime, hasEnd) {
|
|
86
|
+
setFilesToDisplay(function (prevFileUploads) {
|
|
87
|
+
return prevFileUploads.map(function (fileUpload, id) {
|
|
88
|
+
return (0, _extends2["default"])({}, fileUpload, {
|
|
89
|
+
progress: id.toString() === index ? hasEnd ? 1 : currentTime ? currentTime / fileUpload.duration : 0 : fileUpload.progress
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
var onPlayPause = function onPlayPause(index, pausedStatus) {
|
|
96
|
+
if (pausedStatus === false) {
|
|
97
|
+
setFilesToDisplay(function (prevFileUploads) {
|
|
98
|
+
return prevFileUploads.map(function (fileUpload, id) {
|
|
99
|
+
return (0, _extends2["default"])({}, fileUpload, {
|
|
100
|
+
paused: id.toString() === index ? false : true
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
setFilesToDisplay(function (prevFileUploads) {
|
|
106
|
+
return prevFileUploads.map(function (fileUpload) {
|
|
107
|
+
return (0, _extends2["default"])({}, fileUpload, {
|
|
108
|
+
paused: true
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
36
115
|
var _useTheme = (0, _ThemeContext.useTheme)(),
|
|
37
|
-
|
|
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;
|
|
38
121
|
|
|
39
122
|
return _react["default"].createElement(_reactNative.View, {
|
|
40
123
|
style: [styles.container, container, stylesProp.container],
|
|
41
124
|
__self: _this,
|
|
42
125
|
__source: {
|
|
43
126
|
fileName: _jsxFileName,
|
|
44
|
-
lineNumber:
|
|
127
|
+
lineNumber: 131,
|
|
45
128
|
columnNumber: 5
|
|
46
129
|
}
|
|
47
|
-
},
|
|
130
|
+
}, filesToDisplay.map(function (file, index) {
|
|
48
131
|
return _react["default"].createElement(_reactNative.View, {
|
|
49
132
|
key: messageId + "-" + index,
|
|
50
133
|
style: [{
|
|
@@ -53,16 +136,52 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
53
136
|
__self: _this,
|
|
54
137
|
__source: {
|
|
55
138
|
fileName: _jsxFileName,
|
|
56
|
-
lineNumber:
|
|
139
|
+
lineNumber: 133,
|
|
57
140
|
columnNumber: 9
|
|
58
141
|
}
|
|
59
|
-
}, _react["default"].createElement(
|
|
142
|
+
}, file.type === 'audio' && (0, _native.isAudioPackageAvailable)() ? _react["default"].createElement(_reactNative.View, {
|
|
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
|
+
}],
|
|
151
|
+
__self: _this,
|
|
152
|
+
__source: {
|
|
153
|
+
fileName: _jsxFileName,
|
|
154
|
+
lineNumber: 141,
|
|
155
|
+
columnNumber: 13
|
|
156
|
+
}
|
|
157
|
+
}, _react["default"].createElement(AudioAttachment, {
|
|
158
|
+
item: {
|
|
159
|
+
duration: file.duration,
|
|
160
|
+
file: {
|
|
161
|
+
name: file.title,
|
|
162
|
+
uri: file.asset_url
|
|
163
|
+
},
|
|
164
|
+
id: index.toString(),
|
|
165
|
+
paused: file.paused,
|
|
166
|
+
progress: file.progress
|
|
167
|
+
},
|
|
168
|
+
onLoad: onLoad,
|
|
169
|
+
onPlayPause: onPlayPause,
|
|
170
|
+
onProgress: onProgress,
|
|
171
|
+
testID: "audio-attachment-preview",
|
|
172
|
+
__self: _this,
|
|
173
|
+
__source: {
|
|
174
|
+
fileName: _jsxFileName,
|
|
175
|
+
lineNumber: 157,
|
|
176
|
+
columnNumber: 15
|
|
177
|
+
}
|
|
178
|
+
})) : _react["default"].createElement(Attachment, {
|
|
60
179
|
attachment: file,
|
|
61
180
|
__self: _this,
|
|
62
181
|
__source: {
|
|
63
182
|
fileName: _jsxFileName,
|
|
64
|
-
lineNumber:
|
|
65
|
-
columnNumber:
|
|
183
|
+
lineNumber: 172,
|
|
184
|
+
columnNumber: 13
|
|
66
185
|
}
|
|
67
186
|
}));
|
|
68
187
|
}));
|
|
@@ -71,8 +190,7 @@ var FileAttachmentGroupWithContext = function FileAttachmentGroupWithContext(pro
|
|
|
71
190
|
var areEqual = function areEqual(prevProps, nextProps) {
|
|
72
191
|
var prevFiles = prevProps.files;
|
|
73
192
|
var nextFiles = nextProps.files;
|
|
74
|
-
|
|
75
|
-
return filesEqual;
|
|
193
|
+
return prevFiles.length === nextFiles.length;
|
|
76
194
|
};
|
|
77
195
|
|
|
78
196
|
var MemoizedFileAttachmentGroup = _react["default"].memo(FileAttachmentGroupWithContext, areEqual);
|
|
@@ -86,18 +204,20 @@ var FileAttachmentGroup = function FileAttachmentGroup(props) {
|
|
|
86
204
|
|
|
87
205
|
var _useMessagesContext = (0, _MessagesContext.useMessagesContext)(),
|
|
88
206
|
_useMessagesContext$A = _useMessagesContext.Attachment,
|
|
89
|
-
Attachment = _useMessagesContext$A === void 0 ? _Attachment.Attachment : _useMessagesContext$A
|
|
207
|
+
Attachment = _useMessagesContext$A === void 0 ? _Attachment.Attachment : _useMessagesContext$A,
|
|
208
|
+
AudioAttachment = _useMessagesContext.AudioAttachment;
|
|
90
209
|
|
|
91
210
|
var files = propFiles || contextFiles;
|
|
92
211
|
if (!files.length) return null;
|
|
93
212
|
return _react["default"].createElement(MemoizedFileAttachmentGroup, {
|
|
94
213
|
Attachment: Attachment,
|
|
214
|
+
AudioAttachment: AudioAttachment,
|
|
95
215
|
files: files,
|
|
96
216
|
messageId: messageId,
|
|
97
217
|
__self: _this,
|
|
98
218
|
__source: {
|
|
99
219
|
fileName: _jsxFileName,
|
|
100
|
-
lineNumber:
|
|
220
|
+
lineNumber: 217,
|
|
101
221
|
columnNumber: 5
|
|
102
222
|
}
|
|
103
223
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FileAttachmentGroup.tsx"],"names":["styles","StyleSheet","create","container","padding","FileAttachmentGroupWithContext","props","Attachment","files","messageId","stylesProp","theme","messageSimple","fileAttachmentGroup","map","file","index","paddingBottom","length","attachmentContainer","areEqual","prevProps","nextProps","prevFiles","nextFiles","filesEqual","MemoizedFileAttachmentGroup","React","memo","FileAttachmentGroup","propFiles","contextFiles","AttachmentDefault","displayName"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AAIA;;AAIA;;;;;AAIA,IAAMA,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC/BC,EAAAA,SAAS,EAAE;AACTC,IAAAA,OAAO,EAAE;AADA;AADoB,CAAlB,CAAf;;AAoBA,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAGrCC,KAHqC,EAIlC;AACH,MAAQC,UAAR,GAAkED,KAAlE,CAAQC,U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IAAN,CAClCvB,8BADkC,EAElCe,QAFkC,CAApC;;AAUO,IAAMS,mBAAmB,GAAG,SAAtBA,mBAAsB,CAGjCvB,KAHiC,EAI9B;AACH,MAAewB,SAAf,GAAwCxB,KAAxC,CAAQE,KAAR;AAAA,MAA0BC,SAA1B,GAAwCH,KAAxC,CAA0BG,SAA1B;;AAEA,2BAAgC,wCAAhC;AAAA,MAAesB,YAAf,sBAAQvB,KAAR;;AAEA,4BAA2C,0CAA3C;AAAA,kDAAQD,UAAR;AAAA,MAAQA,UAAR,sCAAqByB,sBAArB;;AAEA,MAAMxB,KAAK,GAAGsB,SAAS,IAAIC,YAA3B;AAEA,MAAI,CAACvB,KAAK,CAACU,MAAX,EAAmB,OAAO,IAAP;AAEnB,SACE,gCAAC,2BAAD;AAEIX,IAAAA,UAAU,EAAVA,UAFJ;AAGIC,IAAAA,KAAK,EAALA,KAHJ;AAIIC,IAAAA,SAAS,EAATA,SAJJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF;AASD,CAxBM;;;AA0BPoB,mBAAmB,CAACI,WAApB,GAAkC,yDAAlC","sourcesContent":["import React from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\n\nimport { Attachment as AttachmentDefault } from './Attachment';\n\nimport {\n MessageContextValue,\n useMessageContext,\n} from '../../contexts/messageContext/MessageContext';\nimport {\n MessagesContextValue,\n useMessagesContext,\n} from '../../contexts/messagesContext/MessagesContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\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<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\nconst FileAttachmentGroupWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,\n) => {\n const { Attachment, files, messageId, styles: stylesProp = {} } = props;\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 {files.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 <Attachment attachment={file} />\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 const filesEqual = prevFiles.length === nextFiles.length;\n\n return filesEqual;\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 files = propFiles || contextFiles;\n\n if (!files.length) return null;\n\n return (\n <MemoizedFileAttachmentGroup\n {...{\n Attachment,\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","AttachmentDefault","displayName"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AAEA;;AAKA;;AAIA;;AACA;;;;;;;;;AAIA,IAAMA,mBAAmB,GAAG,EAA5B;;AAEA,IAAMC,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC/BC,EAAAA,SAAS,EAAE;AACTC,IAAAA,OAAO,EAAE;AADA,GADoB;AAI/BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,YAAY,EAAE,EADD;AAEbC,IAAAA,WAAW,EAAE,CAFA;AAGbC,IAAAA,aAAa,EAAE,KAHF;AAIbC,IAAAA,MAAM,EAAEV,mBAJK;AAKbW,IAAAA,cAAc,EAAE,eALH;AAMbC,IAAAA,WAAW,EAAE,CANA;AAObC,IAAAA,YAAY,EAAE;AAPD;AAJgB,CAAlB,CAAf;;AAqCA,IAAMC,8BAA8B,GAAG,SAAjCA,8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AmB,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"]}
|