@smart-link/rn-im 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/api/addressList.js +6 -17
  2. package/dist/api/backup.js +8 -20
  3. package/dist/api/file.js +6 -35
  4. package/dist/api/user.js +6 -16
  5. package/dist/components/CachedImage.js +14 -42
  6. package/dist/components/Camera/Camera.js +26 -54
  7. package/dist/components/Camera/CameraCapture.js +99 -128
  8. package/dist/components/Camera/CameraResult.js +33 -61
  9. package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
  10. package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
  11. package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
  12. package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
  13. package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
  14. package/dist/components/ChatAvatar/ChatAvatarLocal.js +23 -25
  15. package/dist/components/ChatAvatar/index.js +2 -23
  16. package/dist/components/Favicon.js +6 -34
  17. package/dist/components/FormatTimeText.js +5 -10
  18. package/dist/components/Highlighter.js +9 -34
  19. package/dist/components/IndicatorText.js +14 -39
  20. package/dist/components/LocalImage.js +7 -32
  21. package/dist/components/NetworkUnconnected.js +14 -42
  22. package/dist/components/PopoverWrapper.js +22 -47
  23. package/dist/components/VideoPlayer.js +111 -138
  24. package/dist/components/styles.js +10 -13
  25. package/dist/default-assets.d.ts +1 -0
  26. package/dist/default-assets.js +8 -10
  27. package/dist/hooks/useDownloadSource.js +7 -12
  28. package/dist/hooks/useFormatMsgTime.js +5 -13
  29. package/dist/hooks/useImReady.js +7 -10
  30. package/dist/hooks/useImSelector.js +34 -48
  31. package/dist/hooks/useTranslation.js +5 -10
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +8 -28
  34. package/dist/init.js +30 -40
  35. package/dist/interface.js +1 -2
  36. package/dist/locales/en/addressList.js +1 -3
  37. package/dist/locales/index.js +4 -27
  38. package/dist/locales/lao/addressList.js +1 -3
  39. package/dist/locales/zh/addressList.js +1 -3
  40. package/dist/pages/address-list/AddressList.js +33 -61
  41. package/dist/pages/address-list/CardInfo.js +10 -18
  42. package/dist/pages/address-list/ChooseContact.js +50 -78
  43. package/dist/pages/address-list/Icons.js +7 -14
  44. package/dist/pages/address-list/Organization.js +59 -89
  45. package/dist/pages/address-list/UserDetail.js +55 -83
  46. package/dist/pages/address-list/UserJobs.js +31 -33
  47. package/dist/pages/address-list/UserSearch.js +29 -54
  48. package/dist/pages/address-list/addressList.routes.js +11 -16
  49. package/dist/pages/collection/Collection.js +53 -81
  50. package/dist/pages/collection/ContentFactory.js +53 -82
  51. package/dist/pages/collection/collection.routes.js +3 -9
  52. package/dist/pages/conversation/ForwardToConversation.js +63 -91
  53. package/dist/pages/conversation/List.js +74 -102
  54. package/dist/pages/conversation/components/ConversationCard.js +46 -74
  55. package/dist/pages/conversation/components/ConversationOption.js +27 -55
  56. package/dist/pages/conversation/conversation.routes.js +17 -23
  57. package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
  58. package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
  59. package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
  60. package/dist/pages/conversation/setting/OptionConversation.js +20 -48
  61. package/dist/pages/conversation/setting/OptionGroup.js +20 -48
  62. package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
  63. package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
  64. package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
  65. package/dist/pages/conversation/setting/Setting.js +49 -54
  66. package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
  67. package/dist/pages/index.js +7 -27
  68. package/dist/pages/message/ChooseMember.js +56 -84
  69. package/dist/pages/message/MessageBackup/Bar.js +18 -43
  70. package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
  71. package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
  72. package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
  73. package/dist/pages/message/MessageBackup/index.js +3 -12
  74. package/dist/pages/message/MessageBackup/utils.js +14 -22
  75. package/dist/pages/message/MessageList.js +141 -135
  76. package/dist/pages/message/MessageRecord.js +49 -73
  77. package/dist/pages/message/components/BusiNotifyCard.js +60 -85
  78. package/dist/pages/message/components/ChatBg.js +11 -36
  79. package/dist/pages/message/components/MessageItem.js +82 -110
  80. package/dist/pages/message/components/MessageItemQuote.js +30 -58
  81. package/dist/pages/message/components/MessageItemTips.js +27 -55
  82. package/dist/pages/message/components/MessageOption.js +96 -120
  83. package/dist/pages/message/components/MessagePayload.js +36 -64
  84. package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
  85. package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
  86. package/dist/pages/message/components/MessageUndo.js +18 -48
  87. package/dist/pages/message/components/MultipleBar/index.js +48 -76
  88. package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
  89. package/dist/pages/message/components/Payload/PayloadFile.js +41 -65
  90. package/dist/pages/message/components/Payload/PayloadMultiple.js +38 -66
  91. package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
  92. package/dist/pages/message/components/Payload/PayloadPicture.js +21 -49
  93. package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
  94. package/dist/pages/message/components/Payload/PayloadText.js +39 -67
  95. package/dist/pages/message/components/Payload/PayloadVideo.js +28 -56
  96. package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
  97. package/dist/pages/message/components/Payload/PayloadWrapper.js +18 -43
  98. package/dist/pages/message/components/Payload/type.js +1 -2
  99. package/dist/pages/message/components/ReceiptBack.js +31 -61
  100. package/dist/pages/message/components/TextMixMessage.js +13 -38
  101. package/dist/pages/message/components/TextMixQuote.js +129 -158
  102. package/dist/pages/message/components/TextMixQuoteMessage.js +16 -44
  103. package/dist/pages/message/components/UploadProgress.js +12 -37
  104. package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
  105. package/dist/pages/message/components/messageBar/Icons.js +56 -74
  106. package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
  107. package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
  108. package/dist/pages/message/components/messageBar/OptionPanel.js +54 -82
  109. package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
  110. package/dist/pages/message/components/messageBar/index.js +2 -23
  111. package/dist/pages/message/message.routes.js +11 -40
  112. package/dist/pages/search/Search.js +38 -66
  113. package/dist/pages/search/SearchChatRecords.js +64 -92
  114. package/dist/pages/search/SearchFile.js +68 -96
  115. package/dist/pages/search/SearchManager.js +60 -65
  116. package/dist/pages/search/SearchPicturePage.js +16 -44
  117. package/dist/pages/search/components/ChatRecords.js +46 -74
  118. package/dist/pages/search/components/MyGroupChat.js +41 -69
  119. package/dist/pages/search/components/PictureMulipleBar.js +35 -63
  120. package/dist/pages/search/components/SearchFileList.js +59 -64
  121. package/dist/pages/search/components/SearchPictures.js +68 -98
  122. package/dist/pages/search/components/SearchShareLinkList.js +50 -55
  123. package/dist/pages/search/components/SearchUser.js +25 -53
  124. package/dist/pages/search/components/useSearchMessage.js +12 -16
  125. package/dist/pages/search/search.routes.js +11 -17
  126. package/dist/pages/search/utils.js +4 -12
  127. package/dist/pages/types.js +1 -2
  128. package/dist/slice/contact/contact.action.js +1 -2
  129. package/dist/slice/contact/contact.slice.js +4 -8
  130. package/dist/slice/index.js +7 -13
  131. package/dist/slice/panel/panel.slice.d.ts +2 -1
  132. package/dist/slice/panel/panel.slice.js +8 -7
  133. package/dist/slice/video/video.action.d.ts +1 -0
  134. package/dist/slice/video/video.action.js +56 -38
  135. package/dist/slice/video/video.slice.d.ts +1 -1
  136. package/dist/slice/video/video.slice.js +7 -8
  137. package/dist/utils/audio.d.ts +3 -0
  138. package/dist/utils/audio.js +10 -0
  139. package/dist/utils/color.js +2 -9
  140. package/dist/utils/common-action-sheet.js +9 -14
  141. package/dist/utils/cookie.js +6 -14
  142. package/dist/utils/emoji.js +9 -12
  143. package/dist/utils/file-icon.js +33 -60
  144. package/dist/utils/file-operate.js +1 -2
  145. package/dist/utils/file.d.ts +1 -1
  146. package/dist/utils/file.js +74 -87
  147. package/dist/utils/golden-rectangle.js +3 -7
  148. package/dist/utils/phone.js +13 -22
  149. package/dist/utils/request.js +7 -15
  150. package/dist/utils/scroll.js +5 -9
  151. package/dist/utils/summary.js +4 -11
  152. package/dist/utils/take-camera.js +12 -19
  153. package/dist/utils/text-mix.js +4 -11
  154. package/dist/utils/upload.js +20 -41
  155. package/package.json +6 -7
@@ -1,55 +1,27 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const rn_ui_1 = require("@smart-link/rn-ui");
30
- const react_1 = __importStar(require("react"));
31
- const react_native_1 = require("react-native");
32
- const useTranslation_1 = __importDefault(require("../hooks/useTranslation"));
33
- const NetworkUnconnected = (0, react_1.memo)(() => {
34
- const { t } = (0, useTranslation_1.default)();
35
- return (<react_native_1.View style={styles.network}>
36
- <react_native_1.Text style={styles.text} numberOfLines={1}>
1
+ import { dp } from '@smart-link/rn-ui';
2
+ import React, { memo } from 'react';
3
+ import { StyleSheet, Text, View } from 'react-native';
4
+ import useTranslation from '../hooks/useTranslation';
5
+ const NetworkUnconnected = memo(() => {
6
+ const { t } = useTranslation();
7
+ return (<View style={styles.network}>
8
+ <Text style={styles.text} numberOfLines={1}>
37
9
  {t('checkNetwork')}
38
- </react_native_1.Text>
39
- </react_native_1.View>);
10
+ </Text>
11
+ </View>);
40
12
  });
41
- const styles = react_native_1.StyleSheet.create({
13
+ const styles = StyleSheet.create({
42
14
  network: {
43
15
  flexDirection: 'row',
44
- paddingVertical: (0, rn_ui_1.dp)(10),
16
+ paddingVertical: dp(10),
45
17
  backgroundColor: '#feebeb',
46
18
  justifyContent: 'center',
47
19
  },
48
20
  text: {
49
21
  color: '#666',
50
- lineHeight: (0, rn_ui_1.dp)(21),
22
+ lineHeight: dp(21),
51
23
  alignItems: 'center',
52
24
  justifyContent: 'center',
53
25
  },
54
26
  });
55
- exports.default = NetworkUnconnected;
27
+ export default NetworkUnconnected;
@@ -1,48 +1,23 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const react_1 = __importStar(require("react"));
27
- const react_native_1 = require("react-native");
28
- const popover_1 = require("@smart-link/rn-ui/dist/components/popover");
29
- const rn_ui_1 = require("@smart-link/rn-ui");
30
- const elements_1 = require("@react-navigation/elements");
1
+ import React, { memo, useCallback, useEffect, useState } from 'react';
2
+ import { Dimensions, NativeModules, StatusBar, StyleSheet, View, } from 'react-native';
3
+ import { PopoverBase } from '@smart-link/rn-ui/dist/components/popover';
4
+ import { dp } from '@smart-link/rn-ui';
5
+ import { useHeaderHeight } from '@react-navigation/elements';
31
6
  const PopoverWrapper = ({ showArrow = true, measureTarget = true, visible, fullscreen, nativeEvent, children, onClose }) => {
32
7
  var _a, _b;
33
- const { height, width } = react_native_1.Dimensions.get('window');
34
- const headerHeight = (0, elements_1.useHeaderHeight)();
35
- const [contentHeight, setContentHeight] = (0, react_1.useState)(0);
36
- const [fromRect, setFromRect] = (0, react_1.useState)({ x: (_a = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageX) !== null && _a !== void 0 ? _a : 0,
8
+ const { height, width } = Dimensions.get('window');
9
+ const headerHeight = useHeaderHeight();
10
+ const [contentHeight, setContentHeight] = useState(0);
11
+ const [fromRect, setFromRect] = useState({ x: (_a = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageX) !== null && _a !== void 0 ? _a : 0,
37
12
  y: (_b = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageY) !== null && _b !== void 0 ? _b : 0,
38
13
  width: 0,
39
14
  height: 0, });
40
- const onLayout = (0, react_1.useCallback)((event) => {
15
+ const onLayout = useCallback((event) => {
41
16
  setContentHeight(event.nativeEvent.layout.height);
42
17
  }, []);
43
- (0, react_1.useEffect)(() => {
18
+ useEffect(() => {
44
19
  if (!measureTarget && (nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageX)) {
45
- setFromRect(prev => { var _a, _b; return (Object.assign(Object.assign({}, prev), { x: (_a = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageX) !== null && _a !== void 0 ? _a : 0, y: ((_b = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageY) !== null && _b !== void 0 ? _b : 0) - react_native_1.StatusBar.currentHeight })); });
20
+ setFromRect(prev => { var _a, _b; return (Object.assign(Object.assign({}, prev), { x: (_a = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageX) !== null && _a !== void 0 ? _a : 0, y: ((_b = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.pageY) !== null && _b !== void 0 ? _b : 0) - StatusBar.currentHeight })); });
46
21
  }
47
22
  if (!measureTarget || !(nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.target))
48
23
  return;
@@ -54,25 +29,25 @@ const PopoverWrapper = ({ showArrow = true, measureTarget = true, visible, fulls
54
29
  height,
55
30
  });
56
31
  };
57
- react_native_1.NativeModules.UIManager.measure(nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.target, callback);
32
+ NativeModules.UIManager.measure(nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.target, callback);
58
33
  }, [visible, measureTarget, nativeEvent]);
59
- const padding = (0, rn_ui_1.dp)(12);
60
- const viewHeight = height - react_native_1.StatusBar.currentHeight - 46 - 48 - padding * 2;
61
- return (<popover_1.PopoverBase calculateStatusBar useNativeDriver showArrow={showArrow} duration={100} contentStyle={styles.content} backgroundStyle={styles.bg} visible={visible} fromRect={fromRect} placement={fromRect.y + contentHeight > viewHeight ? 'top' : 'bottom'} displayArea={measureTarget ? {
34
+ const padding = dp(12);
35
+ const viewHeight = height - StatusBar.currentHeight - 46 - 48 - padding * 2;
36
+ return (<PopoverBase calculateStatusBar useNativeDriver showArrow={showArrow} duration={100} contentStyle={styles.content} backgroundStyle={styles.bg} visible={visible} fromRect={fromRect} placement={fromRect.y + contentHeight > viewHeight ? 'top' : 'bottom'} displayArea={measureTarget ? {
62
37
  x: padding,
63
38
  y: headerHeight,
64
39
  width: width - padding * 2,
65
- height: height - react_native_1.StatusBar.currentHeight - 46 - headerHeight - padding * 2,
40
+ height: height - StatusBar.currentHeight - 46 - headerHeight - padding * 2,
66
41
  } : undefined} onClose={onClose}>
67
- <react_native_1.View onLayout={onLayout}>{children}</react_native_1.View>
68
- </popover_1.PopoverBase>);
42
+ <View onLayout={onLayout}>{children}</View>
43
+ </PopoverBase>);
69
44
  };
70
- const styles = react_native_1.StyleSheet.create({
45
+ const styles = StyleSheet.create({
71
46
  bg: {
72
47
  backgroundColor: 'transparent',
73
48
  },
74
49
  content: {
75
- borderRadius: (0, rn_ui_1.dp)(6),
50
+ borderRadius: dp(6),
76
51
  },
77
52
  });
78
- exports.default = (0, react_1.memo)(PopoverWrapper);
53
+ export default memo(PopoverWrapper);
@@ -1,70 +1,39 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const react_native_1 = require("react-native");
31
- const react_native_video_1 = __importDefault(require("react-native-video"));
32
- const MaterialIcons_1 = __importDefault(require("react-native-vector-icons/MaterialIcons"));
33
- const AntDesign_1 = __importDefault(require("react-native-vector-icons/AntDesign"));
34
- const FontAwesome_1 = __importDefault(require("react-native-vector-icons/FontAwesome"));
35
- const Progress = __importStar(require("react-native-progress"));
36
- const slider_1 = __importDefault(require("@react-native-community/slider"));
37
- const rn_ui_1 = require("@smart-link/rn-ui");
38
- const file_1 = require("../utils/file");
39
- const im_base_1 = require("@smart-link/im-base");
40
- const useTranslation_1 = __importDefault(require("../hooks/useTranslation"));
41
- const useImSelector_1 = require("../hooks/useImSelector");
42
- const video_slice_1 = require("../slice/video/video.slice");
43
- const react_redux_1 = require("react-redux");
44
- const { width: screenWidth } = react_native_1.Dimensions.get('screen');
45
- const VideoPlayer = (0, react_1.memo)(() => {
46
- const { showVideoPlay = false, videoLocalPath, videoImagePath, videoImageHeight, videoImageWidth, videoDownloadError, videoDownloadProgress = 0, } = (0, useImSelector_1.useVideo)();
1
+ import React, { memo, useEffect, useState } from 'react';
2
+ import { Modal, StyleSheet, Text, TouchableOpacity, View, ImageBackground, StatusBar, Platform, Dimensions, } from 'react-native';
3
+ import Video from 'react-native-video';
4
+ import MaterialIcons from "react-native-vector-icons/MaterialIcons";
5
+ import AntDesign from "react-native-vector-icons/AntDesign";
6
+ import FontAwesome from "react-native-vector-icons/FontAwesome";
7
+ import * as Progress from "react-native-progress";
8
+ import Slider from '@react-native-community/slider';
9
+ import { dp } from '@smart-link/rn-ui';
10
+ import { toAbsolutePath } from '../utils/file';
11
+ import { numberToTime } from '@smart-link/im-base';
12
+ import useTranslation from '../hooks/useTranslation';
13
+ import { useVideo } from '../hooks/useImSelector';
14
+ import { stopVideoPlayer } from "../slice/video/video.action";
15
+ import { getImManager } from "../init";
16
+ const { width: screenWidth } = Dimensions.get('screen');
17
+ const VideoPlayer = memo(() => {
18
+ const { showVideoPlay = false, videoLocalPath, videoImagePath, videoImageHeight, videoImageWidth, videoDownloadError, videoDownloadProgress = 0, } = useVideo();
47
19
  // @ts-ignore
48
- const player = react_1.default.useRef(null);
49
- const dispatch = (0, react_redux_1.useDispatch)();
50
- const { t } = (0, useTranslation_1.default)();
20
+ const player = React.useRef(null);
21
+ const { t } = useTranslation();
51
22
  const videoImageSize = {
52
23
  width: screenWidth,
53
- height: (videoImageHeight > 500 ? (0, rn_ui_1.dp)(500) : videoImageHeight * videoImageWidth / screenWidth)
54
- };
55
- const [isError, setIsError] = (0, react_1.useState)(false);
56
- const [duration, setDuration] = (0, react_1.useState)(0);
57
- const [currentTime, setCurrentTime] = (0, react_1.useState)(0);
58
- const [paused, setPaused] = (0, react_1.useState)(false);
59
- const [pageX, setPageX] = (0, react_1.useState)(0);
60
- const [pageXTime, setPageXTime] = (0, react_1.useState)(0);
61
- const onBuffer = () => {
24
+ height: (videoImageHeight > 500 ? dp(500) : videoImageHeight * videoImageWidth / screenWidth)
62
25
  };
26
+ const [isError, setIsError] = useState(false);
27
+ const [duration, setDuration] = useState(0);
28
+ const [currentTime, setCurrentTime] = useState(0);
29
+ const [paused, setPaused] = useState(false);
30
+ const [pageX, setPageX] = useState(0);
31
+ const [pageXTime, setPageXTime] = useState(0);
63
32
  const onLoad = (data) => {
64
- console.log('onLoad: ', data);
65
33
  setDuration(data.duration);
66
34
  };
67
- const videoError = () => {
35
+ const videoError = (e) => {
36
+ console.log(e);
68
37
  setIsError(true);
69
38
  };
70
39
  const onProgress = (data) => {
@@ -84,7 +53,7 @@ const VideoPlayer = (0, react_1.memo)(() => {
84
53
  setPaused(false);
85
54
  };
86
55
  const onPressSeek = (evt) => {
87
- if (react_native_1.Platform.OS === 'ios') {
56
+ if (Platform.OS === 'ios') {
88
57
  let { nativeEvent } = evt;
89
58
  setPageX(nativeEvent.pageX);
90
59
  setPageXTime(currentTime);
@@ -96,9 +65,9 @@ const VideoPlayer = (0, react_1.memo)(() => {
96
65
  setPaused(true);
97
66
  };
98
67
  const onMoveSeek = (evt) => {
99
- if (react_native_1.Platform.OS === 'ios') {
68
+ if (Platform.OS === 'ios') {
100
69
  let { nativeEvent } = evt;
101
- let time = (nativeEvent.pageX - pageX) / (0, rn_ui_1.dp)(200) * duration + pageXTime;
70
+ let time = (nativeEvent.pageX - pageX) / dp(200) * duration + pageXTime;
102
71
  if (time < 0) {
103
72
  time = 0;
104
73
  }
@@ -116,7 +85,7 @@ const VideoPlayer = (0, react_1.memo)(() => {
116
85
  setPageXTime(0);
117
86
  setPaused(false);
118
87
  };
119
- (0, react_1.useEffect)(() => {
88
+ useEffect(() => {
120
89
  var _a;
121
90
  if (showVideoPlay) {
122
91
  (_a = player.current) === null || _a === void 0 ? void 0 : _a.seek(0);
@@ -124,73 +93,77 @@ const VideoPlayer = (0, react_1.memo)(() => {
124
93
  setPaused(false);
125
94
  setPageX(0);
126
95
  setPageXTime(0);
96
+ setIsError(false);
127
97
  }
128
98
  }, [showVideoPlay]);
99
+ const stop = () => {
100
+ getImManager().store.dispatch(stopVideoPlayer());
101
+ setIsError(false);
102
+ };
129
103
  if (!videoLocalPath && !videoImagePath) {
130
104
  return null;
131
105
  }
132
- return (<react_native_1.Modal animationType="fade" transparent={false} visible={showVideoPlay} onRequestClose={() => {
133
- }}>
134
- {react_native_1.Platform.OS === 'android' &&
135
- <react_native_1.StatusBar backgroundColor={'#000'}/>}
136
- <react_native_1.View style={styles.video}>
106
+ return (<Modal animationType="fade" transparent={false} visible={showVideoPlay} onRequestClose={stop}>
107
+ {Platform.OS === 'android' &&
108
+ <StatusBar backgroundColor={'#000'}/>}
109
+ <View style={styles.video}>
137
110
 
138
111
  {!videoLocalPath && videoImagePath &&
139
- <react_native_1.ImageBackground style={[styles.videoImage, videoImageSize]} source={{ uri: (0, file_1.toAbsolutePath)(videoImagePath) }}>
140
- <Progress.Pie progress={videoDownloadProgress} size={(0, rn_ui_1.dp)(60)} borderWidth={(0, rn_ui_1.dp)(3)} color={'#fff'}/>
141
- </react_native_1.ImageBackground>}
112
+ <ImageBackground style={[styles.videoImage, videoImageSize]} source={{ uri: toAbsolutePath(videoImagePath) }}>
113
+ <Progress.Pie progress={videoDownloadProgress} size={64} borderWidth={3} color={'#fff'}/>
114
+ </ImageBackground>}
142
115
 
143
116
  {(isError || videoDownloadError) &&
144
- <react_native_1.View style={styles.error}>
145
- <MaterialIcons_1.default name={'error'} size={(0, rn_ui_1.dp)(50)} color={'#fff'}/>
146
- <react_native_1.Text style={styles.errorText}>{t('videoLoadingError')}</react_native_1.Text>
147
- </react_native_1.View>}
117
+ <View style={styles.error}>
118
+ <MaterialIcons name={'error'} size={dp(50)} color={'#fff'}/>
119
+ <Text style={styles.errorText}>{t('videoLoadingError')}</Text>
120
+ </View>}
148
121
  {!isError && videoLocalPath &&
149
- <react_native_video_1.default ref={player} source={{ uri: (0, file_1.toAbsolutePath)(videoLocalPath) }} paused={paused} resizeMode={'contain'} progressUpdateInterval={100} onLoad={onLoad} onProgress={onProgress} onEnd={onEnd} onBuffer={onBuffer} onError={videoError} style={styles.player}/>}
150
- <react_native_1.TouchableOpacity style={styles.cancel} onPress={() => dispatch((0, video_slice_1.cancelVideoPlayer)())}>
151
- <AntDesign_1.default name='close' size={(0, rn_ui_1.dp)(25)} color={'#fff'}/>
152
- </react_native_1.TouchableOpacity>
122
+ <Video ref={player} source={{ uri: toAbsolutePath(videoLocalPath) }} paused={paused} resizeMode={'contain'} progressUpdateInterval={100} onLoad={onLoad} onProgress={onProgress} onEnd={onEnd} onError={videoError} style={styles.player}/>}
123
+ <TouchableOpacity activeOpacity={0.75} style={styles.cancel} onPress={stop}>
124
+ <AntDesign name='close' size={dp(25)} color={'#fff'}/>
125
+ </TouchableOpacity>
153
126
  <PlayBar paused={paused} currentTime={currentTime} duration={duration} onPause={onPause} onResume={onResume} onPressSeek={onPressSeek} onMoveSeek={onMoveSeek} onReleaseSeek={onReleaseSeek}/>
154
- </react_native_1.View>
155
- </react_native_1.Modal>);
127
+ </View>
128
+ </Modal>);
156
129
  });
157
- const PlayBar = (0, react_1.memo)(props => {
130
+ const PlayBar = memo(props => {
158
131
  const { paused = false, currentTime, duration, onPause, onResume, onPressSeek, onMoveSeek, onReleaseSeek, } = props;
159
132
  let percentWidth = 0;
160
133
  if (duration !== 0) {
161
- percentWidth = (0, rn_ui_1.dp)(200) * currentTime / duration;
134
+ percentWidth = dp(200) * currentTime / duration;
162
135
  }
163
- return (<react_native_1.View style={styles.playBar}>
136
+ return (<View style={styles.playBar}>
164
137
  {paused &&
165
- <react_native_1.TouchableOpacity style={styles.pauseResume} onPress={onResume}>
166
- <FontAwesome_1.default name='play' size={(0, rn_ui_1.dp)(13)} color={'#fff'}/>
167
- </react_native_1.TouchableOpacity>}
138
+ <TouchableOpacity style={styles.pauseResume} onPress={onResume}>
139
+ <FontAwesome name='play' size={dp(13)} color={'#fff'}/>
140
+ </TouchableOpacity>}
168
141
  {!paused &&
169
- <react_native_1.TouchableOpacity style={styles.pauseResume} onPress={onPause}>
170
- <FontAwesome_1.default name='pause' size={(0, rn_ui_1.dp)(13)} color={'#fff'}/>
171
- </react_native_1.TouchableOpacity>}
172
- <react_native_1.View style={{ width: (0, rn_ui_1.dp)(5) }}/>
173
- <react_native_1.Text style={styles.time}>{(0, im_base_1.numberToTime)(currentTime)}</react_native_1.Text>
174
- <react_native_1.View style={{ width: (0, rn_ui_1.dp)(10) }}/>
175
- {react_native_1.Platform.OS === 'ios' ? <react_native_1.View style={styles.progress}>
176
- <react_native_1.View style={[styles.percent, { width: percentWidth }]}>
142
+ <TouchableOpacity style={styles.pauseResume} onPress={onPause}>
143
+ <FontAwesome name='pause' size={dp(13)} color={'#fff'}/>
144
+ </TouchableOpacity>}
145
+ <View style={{ width: dp(5) }}/>
146
+ <Text style={styles.time}>{numberToTime(currentTime)}</Text>
147
+ <View style={{ width: dp(10) }}/>
148
+ {Platform.OS === 'ios' ? <View style={styles.progress}>
149
+ <View style={[styles.percent, { width: percentWidth }]}>
177
150
  <SeekBottom onPressSeek={onPressSeek} onMoveSeek={onMoveSeek} onReleaseSeek={onReleaseSeek}/>
178
- </react_native_1.View>
179
- </react_native_1.View> :
180
- <slider_1.default style={{ width: (0, rn_ui_1.dp)(200), height: (0, rn_ui_1.dp)(30) }} disabled={duration === 0} value={currentTime} minimumValue={0} maximumValue={duration} minimumTrackTintColor="#fff" thumbTintColor="#fff" onSlidingStart={onPressSeek} onValueChange={onMoveSeek} onSlidingComplete={onReleaseSeek}/>}
181
- <react_native_1.View style={{ width: (0, rn_ui_1.dp)(10) }}/>
182
- <react_native_1.Text style={styles.time}>{(0, im_base_1.numberToTime)(duration)}</react_native_1.Text>
183
- </react_native_1.View>);
151
+ </View>
152
+ </View> :
153
+ <Slider style={{ width: dp(200), height: dp(30) }} disabled={duration === 0} value={currentTime} minimumValue={0} maximumValue={duration} minimumTrackTintColor="#fff" thumbTintColor="#fff" onSlidingStart={onPressSeek} onValueChange={onMoveSeek} onSlidingComplete={onReleaseSeek}/>}
154
+ <View style={{ width: dp(10) }}/>
155
+ <Text style={styles.time}>{numberToTime(duration)}</Text>
156
+ </View>);
184
157
  });
185
- const SeekBottom = (0, react_1.memo)(props => {
158
+ const SeekBottom = memo(props => {
186
159
  const { onPressSeek, onMoveSeek, onReleaseSeek, } = props;
187
160
  return (<>
188
- <react_native_1.View style={styles.seekRange} onStartShouldSetResponder={() => true} onMoveShouldSetResponder={() => true} onResponderGrant={onPressSeek} onResponderMove={onMoveSeek} onResponderRelease={onReleaseSeek} onResponderTerminationRequest={() => false}>
189
- </react_native_1.View>
190
- <react_native_1.View style={styles.seek}/>
161
+ <View style={styles.seekRange} onStartShouldSetResponder={() => true} onMoveShouldSetResponder={() => true} onResponderGrant={onPressSeek} onResponderMove={onMoveSeek} onResponderRelease={onReleaseSeek} onResponderTerminationRequest={() => false}>
162
+ </View>
163
+ <View style={styles.seek}/>
191
164
  </>);
192
165
  });
193
- const styles = react_native_1.StyleSheet.create({
166
+ const styles = StyleSheet.create({
194
167
  video: {
195
168
  flex: 1,
196
169
  backgroundColor: '#000',
@@ -206,9 +179,9 @@ const styles = react_native_1.StyleSheet.create({
206
179
  alignItems: 'center',
207
180
  },
208
181
  errorText: {
209
- fontSize: (0, rn_ui_1.dp)(18),
182
+ fontSize: dp(18),
210
183
  color: '#fff',
211
- lineHeight: (0, rn_ui_1.dp)(40),
184
+ lineHeight: dp(40),
212
185
  },
213
186
  player: {
214
187
  position: 'absolute',
@@ -218,71 +191,71 @@ const styles = react_native_1.StyleSheet.create({
218
191
  right: 0,
219
192
  },
220
193
  cancel: {
221
- height: (0, rn_ui_1.dp)(40),
222
- width: (0, rn_ui_1.dp)(40),
223
- borderRadius: (0, rn_ui_1.dp)(5),
224
- backgroundColor: '#333',
194
+ height: dp(40),
195
+ width: dp(40),
196
+ borderRadius: dp(5),
197
+ backgroundColor: '#999',
225
198
  position: 'absolute',
226
- top: (0, rn_ui_1.dp)(70),
227
- right: (0, rn_ui_1.dp)(30),
199
+ top: dp(70),
200
+ right: dp(30),
228
201
  justifyContent: 'center',
229
202
  alignItems: 'center',
230
203
  opacity: 0.7,
231
204
  },
232
205
  playBar: {
233
206
  position: 'absolute',
234
- bottom: (0, rn_ui_1.dp)(80),
207
+ bottom: dp(80),
235
208
  backgroundColor: 'rgba(51,51,51,0.7)',
236
209
  flexDirection: 'row',
237
- paddingVertical: react_native_1.Platform.select({
238
- ios: (0, rn_ui_1.dp)(10),
239
- default: (0, rn_ui_1.dp)(5)
210
+ paddingVertical: Platform.select({
211
+ ios: dp(10),
212
+ default: dp(5)
240
213
  }),
241
- paddingHorizontal: (0, rn_ui_1.dp)(10),
242
- borderRadius: (0, rn_ui_1.dp)(5),
214
+ paddingHorizontal: dp(10),
215
+ borderRadius: dp(5),
243
216
  justifyContent: 'center',
244
217
  alignItems: 'center',
245
218
  },
246
219
  pauseResume: {
247
220
  justifyContent: 'center',
248
221
  alignItems: 'center',
249
- width: (0, rn_ui_1.dp)(20),
222
+ width: dp(20),
250
223
  },
251
224
  progress: {
252
225
  flexDirection: 'row',
253
- height: (0, rn_ui_1.dp)(2),
254
- width: (0, rn_ui_1.dp)(200),
255
- borderRadius: (0, rn_ui_1.dp)(1),
226
+ height: dp(2),
227
+ width: dp(200),
228
+ borderRadius: dp(1),
256
229
  backgroundColor: '#666',
257
230
  },
258
231
  percent: {
259
232
  height: (2),
260
- width: (0, rn_ui_1.dp)(100),
233
+ width: dp(100),
261
234
  backgroundColor: '#fff'
262
235
  },
263
236
  time: {
264
- fontSize: (0, rn_ui_1.dp)(12),
237
+ fontSize: dp(12),
265
238
  color: '#fff'
266
239
  },
267
240
  seekRange: {
268
- height: (0, rn_ui_1.dp)(50),
269
- width: (0, rn_ui_1.dp)(50),
270
- borderRadius: (0, rn_ui_1.dp)(25),
241
+ height: dp(50),
242
+ width: dp(50),
243
+ borderRadius: dp(25),
271
244
  position: 'absolute',
272
- top: (0, rn_ui_1.dp)(-23),
273
- right: (0, rn_ui_1.dp)(-25),
245
+ top: dp(-23),
246
+ right: dp(-25),
274
247
  opacity: 0,
275
248
  zIndex: 999,
276
249
  },
277
250
  seek: {
278
251
  backgroundColor: '#fff',
279
- height: (0, rn_ui_1.dp)(12),
280
- width: (0, rn_ui_1.dp)(12),
281
- borderRadius: (0, rn_ui_1.dp)(6),
282
- top: (0, rn_ui_1.dp)(-5),
283
- right: (0, rn_ui_1.dp)(-6),
252
+ height: dp(12),
253
+ width: dp(12),
254
+ borderRadius: dp(6),
255
+ top: dp(-5),
256
+ right: dp(-6),
284
257
  position: 'absolute',
285
258
  zIndex: 1,
286
259
  }
287
260
  });
288
- exports.default = VideoPlayer;
261
+ export default VideoPlayer;
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plain = exports.borderStyle = exports.shadowStyle = void 0;
4
- const rn_ui_1 = require("@smart-link/rn-ui");
5
- exports.shadowStyle = {
1
+ import { dp } from '@smart-link/rn-ui';
2
+ export const shadowStyle = {
6
3
  shadowColor: 'rgba(0, 0, 0, 0.08)',
7
4
  shadowOffset: {
8
5
  width: 0,
9
- height: (0, rn_ui_1.dp)(3),
6
+ height: dp(3),
10
7
  },
11
- shadowRadius: (0, rn_ui_1.dp)(3),
8
+ shadowRadius: dp(3),
12
9
  shadowOpacity: 1,
13
10
  elevation: 1.5,
14
11
  };
15
- exports.borderStyle = {
16
- borderRadius: (0, rn_ui_1.dp)(5),
12
+ export const borderStyle = {
13
+ borderRadius: dp(5),
17
14
  };
18
- exports.plain = {
15
+ export const plain = {
19
16
  color: '#000',
20
- fontSize: (0, rn_ui_1.dp)(14),
21
- paddingHorizontal: (0, rn_ui_1.dp)(12),
22
- paddingVertical: (0, rn_ui_1.dp)(10),
17
+ fontSize: dp(14),
18
+ paddingHorizontal: dp(12),
19
+ paddingVertical: dp(10),
23
20
  };
@@ -16,3 +16,4 @@ export declare const messageBackupImg: {
16
16
  cloud: any;
17
17
  cloud_begin: any;
18
18
  };
19
+ export declare const noMessageImg: any;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.messageBackupImg = exports.receiptStatus = exports.defaultAvatars = void 0;
4
- const im_base_1 = require("@smart-link/im-base");
5
- exports.defaultAvatars = {
1
+ import { MessageStatus } from "@smart-link/im-base";
2
+ export const defaultAvatars = {
6
3
  MAN: require('../assets/avatars-man.jpg'),
7
4
  WOMAN: require('../assets/avatars-woman.jpg'),
8
5
  EMPTY: require('../assets/avatars-empty.png'),
@@ -11,12 +8,13 @@ exports.defaultAvatars = {
11
8
  GROUP_OWNER: require('../assets/group-owner.png'),
12
9
  GROUP_MGR: require('../assets/group-mgr.png'),
13
10
  };
14
- exports.receiptStatus = {
15
- [im_base_1.MessageStatus.READ]: require('../assets/hook-blue-double.png'),
16
- [im_base_1.MessageStatus.ARRIVED]: require('../assets/hook-black-double.png'),
17
- [im_base_1.MessageStatus.EMITTED]: require('../assets/hook-black.png'),
11
+ export const receiptStatus = {
12
+ [MessageStatus.READ]: require('../assets/hook-blue-double.png'),
13
+ [MessageStatus.ARRIVED]: require('../assets/hook-black-double.png'),
14
+ [MessageStatus.EMITTED]: require('../assets/hook-black.png'),
18
15
  };
19
- exports.messageBackupImg = {
16
+ export const messageBackupImg = {
20
17
  cloud: require('../assets/cloud-backup.png'),
21
18
  cloud_begin: require('../assets/cloud-backup-begin.png'),
22
19
  };
20
+ export const noMessageImg = require('../assets/no_message.png');