@smart-link/rn-im 1.0.23 → 1.0.26

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 (170) hide show
  1. package/assets/file-dir.jpg +0 -0
  2. package/dist/api/addressList.js +6 -17
  3. package/dist/api/backup.js +8 -20
  4. package/dist/api/file.js +6 -35
  5. package/dist/api/user.js +6 -16
  6. package/dist/components/CachedImage.js +14 -42
  7. package/dist/components/Camera/Camera.js +26 -54
  8. package/dist/components/Camera/CameraCapture.js +99 -128
  9. package/dist/components/Camera/CameraResult.js +33 -61
  10. package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
  11. package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
  12. package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
  13. package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
  14. package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
  15. package/dist/components/ChatAvatar/ChatAvatarLocal.js +22 -25
  16. package/dist/components/ChatAvatar/index.js +2 -23
  17. package/dist/components/Favicon.js +6 -34
  18. package/dist/components/FormatTimeText.js +5 -10
  19. package/dist/components/Highlighter.js +9 -34
  20. package/dist/components/IndicatorText.js +14 -39
  21. package/dist/components/LocalImage.js +7 -32
  22. package/dist/components/NetworkUnconnected.js +14 -42
  23. package/dist/components/PopoverWrapper.js +22 -47
  24. package/dist/components/VideoPlayer.js +111 -138
  25. package/dist/components/styles.js +10 -13
  26. package/dist/default-assets.d.ts +2 -0
  27. package/dist/default-assets.js +9 -10
  28. package/dist/hooks/useDownloadSource.js +7 -12
  29. package/dist/hooks/useFormatMsgTime.js +5 -13
  30. package/dist/hooks/useImReady.js +7 -10
  31. package/dist/hooks/useImSelector.js +34 -48
  32. package/dist/hooks/useTranslation.js +5 -10
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +8 -28
  35. package/dist/init.js +30 -40
  36. package/dist/interface.d.ts +9 -0
  37. package/dist/interface.js +1 -2
  38. package/dist/locales/en/addressList.js +1 -3
  39. package/dist/locales/index.js +4 -27
  40. package/dist/locales/lao/addressList.js +1 -3
  41. package/dist/locales/zh/addressList.js +1 -3
  42. package/dist/pages/address-list/AddressList.js +33 -61
  43. package/dist/pages/address-list/CardInfo.js +10 -18
  44. package/dist/pages/address-list/ChooseContact.js +50 -78
  45. package/dist/pages/address-list/Icons.js +7 -14
  46. package/dist/pages/address-list/Organization.js +59 -89
  47. package/dist/pages/address-list/UserDetail.js +55 -83
  48. package/dist/pages/address-list/UserJobs.js +31 -33
  49. package/dist/pages/address-list/UserSearch.js +29 -54
  50. package/dist/pages/address-list/addressList.routes.js +11 -16
  51. package/dist/pages/collection/Collection.js +53 -81
  52. package/dist/pages/collection/ContentFactory.js +53 -82
  53. package/dist/pages/collection/collection.routes.js +3 -9
  54. package/dist/pages/conversation/ForwardToConversation.js +63 -91
  55. package/dist/pages/conversation/List.js +74 -102
  56. package/dist/pages/conversation/components/ConversationCard.js +46 -74
  57. package/dist/pages/conversation/components/ConversationOption.js +27 -55
  58. package/dist/pages/conversation/conversation.routes.js +17 -23
  59. package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
  60. package/dist/pages/conversation/setting/OptionAvatars.d.ts +1 -1
  61. package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
  62. package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
  63. package/dist/pages/conversation/setting/OptionConversation.js +20 -48
  64. package/dist/pages/conversation/setting/OptionGroup.d.ts +1 -1
  65. package/dist/pages/conversation/setting/OptionGroup.js +20 -48
  66. package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
  67. package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
  68. package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
  69. package/dist/pages/conversation/setting/Setting.js +50 -56
  70. package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
  71. package/dist/pages/index.js +7 -27
  72. package/dist/pages/message/ChooseMember.js +56 -84
  73. package/dist/pages/message/FileSelector.d.ts +6 -0
  74. package/dist/pages/message/FileSelector.js +235 -0
  75. package/dist/pages/message/MessageBackup/Bar.js +18 -43
  76. package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
  77. package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
  78. package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
  79. package/dist/pages/message/MessageBackup/index.js +3 -12
  80. package/dist/pages/message/MessageBackup/utils.js +14 -22
  81. package/dist/pages/message/MessageList.js +151 -141
  82. package/dist/pages/message/MessageRecord.js +74 -87
  83. package/dist/pages/message/components/BusiNotifyCard.js +60 -85
  84. package/dist/pages/message/components/ChatBg.js +11 -36
  85. package/dist/pages/message/components/MessageItem.d.ts +2 -1
  86. package/dist/pages/message/components/MessageItem.js +85 -112
  87. package/dist/pages/message/components/MessageItemQuote.js +30 -58
  88. package/dist/pages/message/components/MessageItemTips.js +27 -55
  89. package/dist/pages/message/components/MessageOption.d.ts +7 -3
  90. package/dist/pages/message/components/MessageOption.js +107 -134
  91. package/dist/pages/message/components/MessagePayload.d.ts +2 -1
  92. package/dist/pages/message/components/MessagePayload.js +36 -64
  93. package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
  94. package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
  95. package/dist/pages/message/components/MessageUndo.js +18 -48
  96. package/dist/pages/message/components/MultipleBar/index.js +48 -76
  97. package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
  98. package/dist/pages/message/components/Payload/PayloadFile.d.ts +1 -1
  99. package/dist/pages/message/components/Payload/PayloadFile.js +44 -68
  100. package/dist/pages/message/components/Payload/PayloadMultiple.js +46 -70
  101. package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
  102. package/dist/pages/message/components/Payload/PayloadPicture.d.ts +1 -1
  103. package/dist/pages/message/components/Payload/PayloadPicture.js +21 -50
  104. package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
  105. package/dist/pages/message/components/Payload/PayloadText.js +39 -67
  106. package/dist/pages/message/components/Payload/PayloadVideo.js +30 -57
  107. package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
  108. package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +2 -1
  109. package/dist/pages/message/components/Payload/PayloadWrapper.js +24 -44
  110. package/dist/pages/message/components/Payload/type.d.ts +2 -1
  111. package/dist/pages/message/components/Payload/type.js +1 -2
  112. package/dist/pages/message/components/ReceiptBack.js +30 -60
  113. package/dist/pages/message/components/TextMixMessage.js +13 -38
  114. package/dist/pages/message/components/TextMixQuote.js +128 -162
  115. package/dist/pages/message/components/TextMixQuoteMessage.js +19 -47
  116. package/dist/pages/message/components/UploadProgress.js +12 -37
  117. package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
  118. package/dist/pages/message/components/messageBar/Icons.js +56 -74
  119. package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
  120. package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
  121. package/dist/pages/message/components/messageBar/OptionPanel.js +54 -107
  122. package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
  123. package/dist/pages/message/components/messageBar/index.js +2 -23
  124. package/dist/pages/message/message.routes.js +21 -40
  125. package/dist/pages/search/Search.js +38 -66
  126. package/dist/pages/search/SearchChatRecords.js +64 -92
  127. package/dist/pages/search/SearchFile.js +68 -96
  128. package/dist/pages/search/SearchManager.js +60 -65
  129. package/dist/pages/search/SearchPicturePage.js +16 -44
  130. package/dist/pages/search/components/ChatRecords.js +46 -74
  131. package/dist/pages/search/components/MyGroupChat.js +41 -69
  132. package/dist/pages/search/components/PictureMulipleBar.js +35 -63
  133. package/dist/pages/search/components/SearchFileList.js +59 -64
  134. package/dist/pages/search/components/SearchPictures.js +68 -98
  135. package/dist/pages/search/components/SearchShareLinkList.js +50 -55
  136. package/dist/pages/search/components/SearchUser.js +25 -53
  137. package/dist/pages/search/components/useSearchMessage.js +12 -16
  138. package/dist/pages/search/search.routes.js +11 -17
  139. package/dist/pages/search/utils.js +4 -12
  140. package/dist/pages/types.d.ts +4 -2
  141. package/dist/pages/types.js +1 -2
  142. package/dist/slice/contact/contact.slice.js +4 -8
  143. package/dist/slice/index.js +7 -13
  144. package/dist/slice/panel/panel.slice.d.ts +2 -1
  145. package/dist/slice/panel/panel.slice.js +8 -7
  146. package/dist/slice/video/video.action.d.ts +1 -0
  147. package/dist/slice/video/video.action.js +64 -38
  148. package/dist/slice/video/video.slice.d.ts +1 -1
  149. package/dist/slice/video/video.slice.js +7 -8
  150. package/dist/utils/audio.d.ts +3 -0
  151. package/dist/utils/audio.js +10 -0
  152. package/dist/utils/color.js +2 -9
  153. package/dist/utils/common-action-sheet.js +9 -14
  154. package/dist/utils/cookie.js +6 -14
  155. package/dist/utils/emoji.js +9 -12
  156. package/dist/utils/file-icon.js +33 -60
  157. package/dist/utils/file-operate.js +1 -2
  158. package/dist/utils/file.d.ts +10 -2
  159. package/dist/utils/file.js +188 -88
  160. package/dist/utils/golden-rectangle.js +3 -7
  161. package/dist/utils/phone.js +13 -22
  162. package/dist/utils/request.js +7 -15
  163. package/dist/utils/scroll.js +5 -9
  164. package/dist/utils/summary.js +4 -11
  165. package/dist/utils/take-camera.js +12 -19
  166. package/dist/utils/text-mix.js +4 -11
  167. package/dist/utils/upload.js +20 -41
  168. package/package.json +6 -7
  169. package/dist/slice/contact/contact.action.d.ts +0 -1
  170. package/dist/slice/contact/contact.action.js +0 -2
@@ -1,80 +1,53 @@
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
- exports.findSvgIcon = void 0;
27
- const react_native_svg_1 = __importStar(require("react-native-svg"));
1
+ import Svg, { Path } from "react-native-svg";
28
2
  const fileTypeIcons = [
29
3
  {
30
4
  suffixes: ['zip', 'rar', 'tar'],
31
- svg: ({ style }) => (<react_native_svg_1.default viewBox={'0 0 1024 1024'} width="48" height="48" style={style}>
32
- <react_native_svg_1.Path d="M748 183.5V0H96v1024h836V183.5z" fill="#DBB375"/>
33
- <react_native_svg_1.Path d="M932 184H748V0" fill="#FFD597"/>
34
- <react_native_svg_1.Path d="M223 0h96v96h-96zM319 96h96v96h-96zM223 192h96v96h-96zM319 288h96v96h-96zM223 384h96v96h-96zM319 480h96v96h-96z" fill="#FFFFFF"/>
35
- </react_native_svg_1.default>),
5
+ svg: ({ style }) => (<Svg viewBox={'0 0 1024 1024'} width="48" height="48" style={style}>
6
+ <Path d="M748 183.5V0H96v1024h836V183.5z" fill="#DBB375"/>
7
+ <Path d="M932 184H748V0" fill="#FFD597"/>
8
+ <Path d="M223 0h96v96h-96zM319 96h96v96h-96zM223 192h96v96h-96zM319 288h96v96h-96zM223 384h96v96h-96zM319 480h96v96h-96z" fill="#FFFFFF"/>
9
+ </Svg>),
36
10
  },
37
11
  {
38
12
  suffixes: ['doc', 'docx', 'wps'],
39
- svg: ({ style }) => (<react_native_svg_1.default viewBox="0 0 1024 1024" width="48" height="48" style={style}>
40
- <react_native_svg_1.Path d="M745 186V3H93v1021h836V186z" fill="#6CA2FF"/>
41
- <react_native_svg_1.Path d="M929 186H745V3" fill="#A2CBFC"/>
42
- <react_native_svg_1.Path d="M490.4 344.2H542l65.2 227.3L651 344.2h66.1L638.5 685H578l-60.5-238.1L454.3 685h-60.5l-78.5-340.8h66.1l43.8 227.3 65.2-227.3z" fill="#FCFCFC"/>
43
- </react_native_svg_1.default>),
13
+ svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
14
+ <Path d="M745 186V3H93v1021h836V186z" fill="#6CA2FF"/>
15
+ <Path d="M929 186H745V3" fill="#A2CBFC"/>
16
+ <Path d="M490.4 344.2H542l65.2 227.3L651 344.2h66.1L638.5 685H578l-60.5-238.1L454.3 685h-60.5l-78.5-340.8h66.1l43.8 227.3 65.2-227.3z" fill="#FCFCFC"/>
17
+ </Svg>),
44
18
  },
45
19
  {
46
20
  suffixes: ['xls', 'xlsx', 'csv'],
47
- svg: ({ style }) => (<react_native_svg_1.default viewBox="0 0 1024 1024" width="48" height="48" style={style}>
48
- <react_native_svg_1.Path d="M745 184.3V1H93v1022.5h836V184.3z" fill="#72DCA2"/>
49
- <react_native_svg_1.Path d="M928.8 184h-184V0.8" fill="#A9FFCE"/>
50
- <react_native_svg_1.Path d="M500.8 476.2l76.6-131h67.7L532.5 537.9 445.7 686H378l122.8-209.8z m-0.7 70.3l-6.6-11-112.7-190.3h67.7L525 474.4l8.9 15.2L650.3 686h-67.7l-82.5-139.5z" fill="#FCFCFC"/>
51
- </react_native_svg_1.default>),
21
+ svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
22
+ <Path d="M745 184.3V1H93v1022.5h836V184.3z" fill="#72DCA2"/>
23
+ <Path d="M928.8 184h-184V0.8" fill="#A9FFCE"/>
24
+ <Path d="M500.8 476.2l76.6-131h67.7L532.5 537.9 445.7 686H378l122.8-209.8z m-0.7 70.3l-6.6-11-112.7-190.3h67.7L525 474.4l8.9 15.2L650.3 686h-67.7l-82.5-139.5z" fill="#FCFCFC"/>
25
+ </Svg>),
52
26
  },
53
27
  {
54
28
  suffixes: ['ppt', 'pptx'],
55
- svg: ({ style }) => (<react_native_svg_1.default viewBox="0 0 1024 1024" width="48" height="48" style={style}>
56
- <react_native_svg_1.Path d="M745 186V3H93v1021h836V186z" fill="#FF8278"/>
57
- <react_native_svg_1.Path d="M929 186H745V2.7" fill="#FFB7B3"/>
58
- <react_native_svg_1.Path d="M390.5 341.2h64.2V682h-64.2V341.2z m29.3 146.7h109c7.7 0 14.4-1.8 20.3-5.3s10.4-8.5 13.7-14.9 4.9-13.7 4.9-22c0-8.4-1.6-15.9-4.8-22.4s-7.7-11.5-13.6-15-12.7-5.3-20.5-5.3h-109v-61.9h107.3c21.2 0 40 4.3 56.1 13s28.7 20.9 37.6 36.7c8.9 15.8 13.4 34.1 13.4 54.8 0 20.8-4.5 39-13.4 54.7s-21.4 27.9-37.6 36.4c-16.2 8.6-34.9 12.9-56.1 12.9H419.8v-61.7z" fill="#FFFFFF"/>
59
- </react_native_svg_1.default>),
29
+ svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
30
+ <Path d="M745 186V3H93v1021h836V186z" fill="#FF8278"/>
31
+ <Path d="M929 186H745V2.7" fill="#FFB7B3"/>
32
+ <Path d="M390.5 341.2h64.2V682h-64.2V341.2z m29.3 146.7h109c7.7 0 14.4-1.8 20.3-5.3s10.4-8.5 13.7-14.9 4.9-13.7 4.9-22c0-8.4-1.6-15.9-4.8-22.4s-7.7-11.5-13.6-15-12.7-5.3-20.5-5.3h-109v-61.9h107.3c21.2 0 40 4.3 56.1 13s28.7 20.9 37.6 36.7c8.9 15.8 13.4 34.1 13.4 54.8 0 20.8-4.5 39-13.4 54.7s-21.4 27.9-37.6 36.4c-16.2 8.6-34.9 12.9-56.1 12.9H419.8v-61.7z" fill="#FFFFFF"/>
33
+ </Svg>),
60
34
  },
61
35
  {
62
36
  suffixes: ['pdf'],
63
- svg: ({ style }) => (<react_native_svg_1.default viewBox="0 0 1024 1024" width="48" height="48" style={style}>
64
- <react_native_svg_1.Path d="M748 183.5V0H96v1024h836V183.5z" fill="#FF5562"/>
65
- <react_native_svg_1.Path d="M932 184H748V0" fill="#FF9292"/>
66
- <react_native_svg_1.Path d="M657.9 606.1c-29.4-1.9-57.4-12.9-79.9-31.3-44.2 9.4-86.3 22.9-128.4 39.6-33.5 57.4-64.8 86.6-91.8 86.6-5.4 0-11.9-1-16.2-4.2-11.3-5.1-18.5-16.1-18.3-28.2 0-9.4 2.1-35.5 104.7-78.2 23.3-41.3 42.4-84.6 57.2-129.4-12.9-25-41-86.6-21.6-117.9 6.5-11.5 19.4-17.7 33.5-16.7 11 0.1 21.4 5.1 28.1 13.6 14 18.8 12.9 58.4-5.4 116.8 17.3 31.3 39.9 59.5 66.9 83.5 22.7-4.2 45.3-7.3 68-7.3 50.7 1 58.3 24 57.2 37.5 0 35.6-35.7 35.6-54 35.6z m-302.2 64.6l3.2-1c15.1-5.2 27-15.6 35.6-29.2-16.2 6.3-29.1 16.6-38.8 30.2z m143.5-312.9H496c-1.1 0-3.3 0-4.3 1-4.3 17.7-1.1 36.5 6.5 53.2 6.2-17.5 6.6-36.5 1-54.2z m7.6 151.2l-1.1 2.1-1.1-1.1c-9.7 24-20.5 48-32.4 70.9l2.1-1v2.1c24-8.4 48.5-15.3 73.4-20.9l-1-1h3.3c-16.2-15.5-30.7-32.6-43.2-51.1z m146.8 55.3c-9.7 0-18.3 0-28 2.1 10.8 5.2 21.6 7.3 32.4 8.3 7.6 1 15.1 0 21.6-2.1-0.1-3-4.4-8.3-26-8.3z" fill="#FFFFFF"/>
67
- </react_native_svg_1.default>),
37
+ svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
38
+ <Path d="M748 183.5V0H96v1024h836V183.5z" fill="#FF5562"/>
39
+ <Path d="M932 184H748V0" fill="#FF9292"/>
40
+ <Path d="M657.9 606.1c-29.4-1.9-57.4-12.9-79.9-31.3-44.2 9.4-86.3 22.9-128.4 39.6-33.5 57.4-64.8 86.6-91.8 86.6-5.4 0-11.9-1-16.2-4.2-11.3-5.1-18.5-16.1-18.3-28.2 0-9.4 2.1-35.5 104.7-78.2 23.3-41.3 42.4-84.6 57.2-129.4-12.9-25-41-86.6-21.6-117.9 6.5-11.5 19.4-17.7 33.5-16.7 11 0.1 21.4 5.1 28.1 13.6 14 18.8 12.9 58.4-5.4 116.8 17.3 31.3 39.9 59.5 66.9 83.5 22.7-4.2 45.3-7.3 68-7.3 50.7 1 58.3 24 57.2 37.5 0 35.6-35.7 35.6-54 35.6z m-302.2 64.6l3.2-1c15.1-5.2 27-15.6 35.6-29.2-16.2 6.3-29.1 16.6-38.8 30.2z m143.5-312.9H496c-1.1 0-3.3 0-4.3 1-4.3 17.7-1.1 36.5 6.5 53.2 6.2-17.5 6.6-36.5 1-54.2z m7.6 151.2l-1.1 2.1-1.1-1.1c-9.7 24-20.5 48-32.4 70.9l2.1-1v2.1c24-8.4 48.5-15.3 73.4-20.9l-1-1h3.3c-16.2-15.5-30.7-32.6-43.2-51.1z m146.8 55.3c-9.7 0-18.3 0-28 2.1 10.8 5.2 21.6 7.3 32.4 8.3 7.6 1 15.1 0 21.6-2.1-0.1-3-4.4-8.3-26-8.3z" fill="#FFFFFF"/>
41
+ </Svg>),
68
42
  },
69
43
  ];
70
- const unknownSvgIcon = ({ style }) => (<react_native_svg_1.default viewBox="0 0 1024 1024" width="48" height="48" style={style}>
71
- <react_native_svg_1.Path d="m945.85,927.48a54.07,48.76 0 0 1 -54.07,48.76l-757.05,0a54.07,48.76 0 0 1 -54.07,-48.76l0,-877.72a54.07,48.76 0 0 1 54.07,-48.76l463.96,0a54.07,48.76 0 0 1 38.39,14.14l293.08,263.8a54.07,48.76 0 0 1 15.68,34.62l0,613.92z" fill="#EBECF0" id="svg_1"/>
72
- <react_native_svg_1.Path d="m936.85,912.48l0,48.76a53.26,48.76 0 0 1 -53.26,48.76l-745.67,0a53.26,48.76 0 0 1 -53.26,-48.76l0,-48.76a53.26,48.76 0 0 0 53.26,48.76l745.67,0a53.26,48.76 0 0 0 53.26,-48.76z" fill="#ebecf0" id="svg_2"/>
73
- <react_native_svg_1.Path d="m476.65,659.75l71.68,0l0,71.68l-71.68,0l0,-71.68zm35.11,-367.18a142.87,142.87 0 0 0 -142.88,142.87l71.68,0a71.68,71.68 0 0 1 142.88,0c0,71.68 -106.79,62.91 -106.79,178.96l71.19,0c0,-80.46 106.79,-89.23 106.79,-178.96a142.87,142.87 0 0 0 -142.87,-142.87z" data-spm-anchor-id="a313x.search_index.0.i12.79b93a81n6ELU2" fill="#5E6C84" id="svg_3"/>
74
- <react_native_svg_1.Path d="m944.85,312.65l0,6.74l-274.77,0a50.79,48.15 0 0 1 -50.79,-48.15l0,-267.24a50.79,48.15 0 0 1 36.06,13.96l275.28,260.5a50.79,48.15 0 0 1 14.22,34.19z" fill="#C1C7D0" id="svg_4" transform="matrix(1 0 0 1 0 0)"/>
75
- </react_native_svg_1.default>);
76
- const findSvgIcon = (suffix) => {
44
+ const unknownSvgIcon = ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
45
+ <Path d="m945.85,927.48a54.07,48.76 0 0 1 -54.07,48.76l-757.05,0a54.07,48.76 0 0 1 -54.07,-48.76l0,-877.72a54.07,48.76 0 0 1 54.07,-48.76l463.96,0a54.07,48.76 0 0 1 38.39,14.14l293.08,263.8a54.07,48.76 0 0 1 15.68,34.62l0,613.92z" fill="#EBECF0" id="svg_1"/>
46
+ <Path d="m936.85,912.48l0,48.76a53.26,48.76 0 0 1 -53.26,48.76l-745.67,0a53.26,48.76 0 0 1 -53.26,-48.76l0,-48.76a53.26,48.76 0 0 0 53.26,48.76l745.67,0a53.26,48.76 0 0 0 53.26,-48.76z" fill="#ebecf0" id="svg_2"/>
47
+ <Path d="m476.65,659.75l71.68,0l0,71.68l-71.68,0l0,-71.68zm35.11,-367.18a142.87,142.87 0 0 0 -142.88,142.87l71.68,0a71.68,71.68 0 0 1 142.88,0c0,71.68 -106.79,62.91 -106.79,178.96l71.19,0c0,-80.46 106.79,-89.23 106.79,-178.96a142.87,142.87 0 0 0 -142.87,-142.87z" data-spm-anchor-id="a313x.search_index.0.i12.79b93a81n6ELU2" fill="#5E6C84" id="svg_3"/>
48
+ <Path d="m944.85,312.65l0,6.74l-274.77,0a50.79,48.15 0 0 1 -50.79,-48.15l0,-267.24a50.79,48.15 0 0 1 36.06,13.96l275.28,260.5a50.79,48.15 0 0 1 14.22,34.19z" fill="#C1C7D0" id="svg_4" transform="matrix(1 0 0 1 0 0)"/>
49
+ </Svg>);
50
+ export const findSvgIcon = (suffix) => {
77
51
  const icon = fileTypeIcons.find(item => item.suffixes.includes(suffix));
78
52
  return (icon === null || icon === void 0 ? void 0 : icon.svg) || unknownSvgIcon;
79
53
  };
80
- exports.findSvgIcon = findSvgIcon;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  // import {NativeModules, PermissionsAndroid, Platform} from "react-native";
3
2
  // import CameraRoll from '@react-native-community/cameraroll';
4
- Object.defineProperty(exports, "__esModule", { value: true });
3
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { IUser, IDownloadOptions, ImManager, ResourceType } from '@smart-link/im-base';
2
+ import { IPathItem } from "../interface";
2
3
  declare const resourceDirBase: {
3
4
  readonly avatars: "/avatars";
4
5
  readonly voice: "/voice";
@@ -14,10 +15,17 @@ export declare function toAbsolutePath(filePath: string): string;
14
15
  export declare function toRelativePath(filePath: string): string;
15
16
  export declare const numberToFileSize: (number: number) => string;
16
17
  export declare const moveFile: (filePath: string, filename: string, resourceType: ResourceDir) => Promise<string>;
17
- export declare const copyFile: (localPath: string, filename: string, resourceType?: ResourceDir) => Promise<string>;
18
+ export declare const copyFile: (localPath: string, filename: string, resourceType: ResourceDir) => Promise<string>;
18
19
  export declare const getSuffix: (filename: string) => string;
19
- export declare const download: ({ fileId, fileSize, resourceType, filename, onProgress }: IDownloadOptions) => Promise<string>;
20
+ export declare const download: ({ fileId, resourceType, filename, onProgress, onStart }: IDownloadOptions) => Promise<string>;
20
21
  export declare function saveToAlbum(imManager: ImManager, localPath: string, showTips?: boolean): Promise<boolean>;
21
22
  export declare function requestSaveFilePermissionIfAndroid(imManager: ImManager): Promise<boolean>;
22
23
  export declare function getExtensionFromMime(mime: string): string;
24
+ export declare function selectFile(imManager: ImManager, filePath: string, filename: string): Promise<string | undefined>;
25
+ export declare function readFileDir(imManager: ImManager, path: string, keyword?: string): Promise<IPathItem[]>;
26
+ export declare function getChildrenCount(imManager: ImManager, isDir: boolean, path: string): Promise<number>;
27
+ export declare function getFileRootItem(imManager: ImManager): Promise<IPathItem[]>;
28
+ export declare function createRootItem(imManager: ImManager, name: string, path: string): Promise<IPathItem>;
29
+ export declare function getFileType(path: string): string;
30
+ export declare function isImage(path: string): boolean;
23
31
  export {};
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,18 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getExtensionFromMime = exports.requestSaveFilePermissionIfAndroid = exports.saveToAlbum = exports.download = exports.getSuffix = exports.copyFile = exports.moveFile = exports.numberToFileSize = exports.toRelativePath = exports.toAbsolutePath = exports.getResourcePath = exports.initDir = void 0;
16
- const react_native_fs_1 = __importDefault(require("react-native-fs"));
17
- const camera_roll_1 = require("@react-native-camera-roll/camera-roll");
18
- const cookie_1 = require("./cookie");
19
- const file_1 = require("../api/file");
20
- const react_native_compressor_1 = require("react-native-compressor");
21
- const react_native_1 = require("react-native");
22
- const documentPath = react_native_fs_1.default.DocumentDirectoryPath;
10
+ import RNFS from 'react-native-fs';
11
+ import { CameraRoll } from '@react-native-camera-roll/camera-roll';
12
+ import { getCookieString } from './cookie';
13
+ import { getDownloadUrl } from '../api/file';
14
+ import { uuidv4 } from 'react-native-compressor';
15
+ import { PermissionsAndroid, Platform } from 'react-native';
16
+ const documentPath = RNFS.DocumentDirectoryPath;
23
17
  const resourceDirBase = {
24
18
  avatars: '/avatars',
25
19
  voice: '/voice',
@@ -30,41 +24,37 @@ const resourceDirBase = {
30
24
  };
31
25
  const resourceDir = {};
32
26
  let userPath = '';
33
- function initDir(user) {
27
+ export function initDir(user) {
34
28
  return __awaiter(this, void 0, void 0, function* () {
35
29
  userPath = documentPath + '/' + user.userId;
36
30
  const tasks = Object.keys(resourceDirBase).reduce((task, currentValue) => {
37
31
  resourceDir[currentValue] = '/' + user.userId + resourceDirBase[currentValue];
38
- task.push(react_native_fs_1.default.mkdir(documentPath + resourceDir[currentValue]));
32
+ task.push(RNFS.mkdir(documentPath + resourceDir[currentValue]));
39
33
  return task;
40
34
  }, []);
41
35
  yield Promise.all(tasks);
42
36
  console.log('initDir success');
43
37
  });
44
38
  }
45
- exports.initDir = initDir;
46
- const getResourcePath = (fileName, resourceType) => {
47
- return `${userPath}/${resourceDirBase[resourceType]}/${fileName}`;
39
+ export const getResourcePath = (fileName, resourceType) => {
40
+ return `${userPath}${resourceDirBase[resourceType]}/${fileName}`;
48
41
  };
49
- exports.getResourcePath = getResourcePath;
50
- function toAbsolutePath(filePath) {
42
+ export function toAbsolutePath(filePath) {
51
43
  if (filePath.startsWith('Documents')) {
52
44
  return filePath;
53
45
  }
54
46
  if (filePath.startsWith('file://')) {
55
47
  return filePath;
56
48
  }
57
- return 'file://' + filePath;
49
+ return 'file://' + documentPath + filePath;
58
50
  }
59
- exports.toAbsolutePath = toAbsolutePath;
60
- function toRelativePath(filePath) {
51
+ export function toRelativePath(filePath) {
61
52
  if (filePath.startsWith(documentPath)) {
62
53
  return filePath.slice(documentPath.length);
63
54
  }
64
55
  return filePath;
65
56
  }
66
- exports.toRelativePath = toRelativePath;
67
- const numberToFileSize = (number) => {
57
+ export const numberToFileSize = (number) => {
68
58
  let size = Number(number);
69
59
  const unit = ['B', 'KB', 'MB', 'GB', 'TB'];
70
60
  let count = 0;
@@ -74,78 +64,63 @@ const numberToFileSize = (number) => {
74
64
  }
75
65
  return size.toFixed(2) + unit[count];
76
66
  };
77
- exports.numberToFileSize = numberToFileSize;
78
- const moveFile = (filePath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
67
+ export const moveFile = (filePath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
79
68
  const relativePath = resourceDir[resourceType] + "/" + filename;
80
69
  const destPath = documentPath + relativePath;
81
- if (yield react_native_fs_1.default.exists(destPath)) {
70
+ if (yield RNFS.exists(destPath)) {
82
71
  return destPath;
83
72
  }
84
- yield react_native_fs_1.default.moveFile(filePath, destPath);
73
+ yield RNFS.moveFile(filePath, destPath);
85
74
  return destPath;
86
75
  });
87
- exports.moveFile = moveFile;
88
- const copyFile = (localPath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
89
- let destPath = documentPath + '/' + (0, react_native_compressor_1.uuidv4)() + (0, exports.getSuffix)(filename);
76
+ export const copyFile = (localPath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
77
+ let destPath = documentPath + '/' + uuidv4() + getSuffix(filename);
90
78
  if (resourceType) {
91
79
  destPath = documentPath + resourceDir[resourceType] + "/" + filename;
92
80
  }
93
- yield react_native_fs_1.default.copyFile(localPath, destPath);
81
+ yield RNFS.copyFile(localPath, destPath);
94
82
  return destPath;
95
83
  });
96
- exports.copyFile = copyFile;
97
- const getSuffix = (filename) => {
84
+ export const getSuffix = (filename) => {
98
85
  const index = filename.lastIndexOf('.');
99
86
  return filename.substring(index);
100
87
  };
101
- exports.getSuffix = getSuffix;
102
- const download = ({ fileId, fileSize, resourceType, filename, onProgress }) => __awaiter(void 0, void 0, void 0, function* () {
103
- const cookie = yield (0, cookie_1.getCookieString)();
104
- const fileUrl = (0, file_1.getDownloadUrl)(fileId);
88
+ export const download = ({ fileId, resourceType, filename, onProgress, onStart }) => __awaiter(void 0, void 0, void 0, function* () {
89
+ const cookie = yield getCookieString();
90
+ const fileUrl = getDownloadUrl(fileId);
105
91
  console.log('download url: ', fileUrl);
106
- if (react_native_1.Platform.OS === 'android') {
107
- const destPath = react_native_fs_1.default.DocumentDirectoryPath + resourceDir[resourceType] + '/' + fileId + (0, exports.getSuffix)(filename);
108
- const { jobId, promise } = react_native_fs_1.default.downloadFile({
109
- fromUrl: fileUrl,
110
- toFile: destPath,
111
- headers: {
112
- 'Cookie': cookie,
113
- },
114
- // 设置 background 为 false,确保 progress 回调能够正常触发
115
- background: true,
116
- progress: (e) => {
117
- // console.log('download progress: ', e);
118
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({ loaded: e.bytesWritten, total: e.contentLength });
119
- }
120
- });
121
- try {
122
- yield promise;
123
- console.log('下载完成');
124
- return destPath;
125
- }
126
- catch (error) {
127
- console.error('下载失败:', error);
128
- throw error;
92
+ const relativePath = resourceDir[resourceType] + "/" + filename;
93
+ const destPath = documentPath + relativePath;
94
+ const { jobId, promise } = RNFS.downloadFile({
95
+ fromUrl: fileUrl,
96
+ toFile: destPath,
97
+ headers: {
98
+ 'Cookie': cookie,
99
+ },
100
+ progressInterval: 300,
101
+ progressDivider: 5,
102
+ begin: (e) => {
103
+ // 这个方法不能注释,否则 ios 不响应进度
104
+ // console.log('download begin: ', e);
105
+ },
106
+ progress: (e) => {
107
+ // console.log('download progress: ', e);
108
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({ loaded: e.bytesWritten, total: e.contentLength, jobId });
129
109
  }
110
+ });
111
+ onStart === null || onStart === void 0 ? void 0 : onStart(() => {
112
+ RNFS.stopDownload(jobId);
113
+ });
114
+ try {
115
+ yield promise;
116
+ return relativePath;
130
117
  }
131
- else {
132
- const resp = yield fetch(fileUrl, {
133
- method: 'HEAD',
134
- });
135
- if (resp.status !== 200) {
136
- console.error('下载失败:', resp.status);
137
- throw new Error('下载失败');
138
- }
139
- const contentLength = resp.headers.get('Content-Length') || fileSize;
140
- const result = yield (0, react_native_compressor_1.download)(fileUrl, (progress) => {
141
- // console.log('download progress: ', progress);
142
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({ loaded: progress * Number(contentLength), total: Number(contentLength) });
143
- });
144
- return yield (0, exports.moveFile)(result, filename, resourceType);
118
+ catch (error) {
119
+ console.error('下载失败:', error);
120
+ throw error;
145
121
  }
146
122
  });
147
- exports.download = download;
148
- function saveToAlbum(imManager, localPath, showTips = true) {
123
+ export function saveToAlbum(imManager, localPath, showTips = true) {
149
124
  var _a, _b;
150
125
  return __awaiter(this, void 0, void 0, function* () {
151
126
  const absolutePath = toAbsolutePath(localPath);
@@ -154,7 +129,7 @@ function saveToAlbum(imManager, localPath, showTips = true) {
154
129
  if (!success) {
155
130
  return false;
156
131
  }
157
- yield camera_roll_1.CameraRoll.saveToCameraRoll(absolutePath);
132
+ yield CameraRoll.saveToCameraRoll(absolutePath);
158
133
  showTips && ((_a = imManager.toast) === null || _a === void 0 ? void 0 : _a.call(imManager, imManager.t('saved'), 'success'));
159
134
  }
160
135
  catch (e) {
@@ -165,12 +140,11 @@ function saveToAlbum(imManager, localPath, showTips = true) {
165
140
  return true;
166
141
  });
167
142
  }
168
- exports.saveToAlbum = saveToAlbum;
169
- function requestSaveFilePermissionIfAndroid(imManager) {
143
+ export function requestSaveFilePermissionIfAndroid(imManager) {
170
144
  var _a;
171
145
  return __awaiter(this, void 0, void 0, function* () {
172
- if (react_native_1.Platform.OS === 'android') {
173
- let granted = yield react_native_1.PermissionsAndroid.check(react_native_1.PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
146
+ if (Platform.OS === 'android') {
147
+ let granted = yield PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
174
148
  if (!granted) {
175
149
  let granted = yield requestSaveFilePermission();
176
150
  console.log('requestSaveFilePermissionIfAndroid: ', granted);
@@ -183,12 +157,11 @@ function requestSaveFilePermissionIfAndroid(imManager) {
183
157
  return true;
184
158
  });
185
159
  }
186
- exports.requestSaveFilePermissionIfAndroid = requestSaveFilePermissionIfAndroid;
187
160
  function requestSaveFilePermission() {
188
- return react_native_1.PermissionsAndroid.request(react_native_1.PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
161
+ return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
189
162
  }
190
163
  function requestReadFilePermission() {
191
- return react_native_1.PermissionsAndroid.request(react_native_1.PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
164
+ return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
192
165
  }
193
166
  // 获取主流的文件扩展名
194
167
  const extensions = {
@@ -254,7 +227,134 @@ const extensions = {
254
227
  'application/vnd.android.package-archive': '.apk',
255
228
  'application/x-apk': '.apk',
256
229
  };
257
- function getExtensionFromMime(mime) {
230
+ export function getExtensionFromMime(mime) {
258
231
  return extensions[mime] || '';
259
232
  }
260
- exports.getExtensionFromMime = getExtensionFromMime;
233
+ export function selectFile(imManager, filePath, filename) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const success = yield requestSaveFilePermissionIfAndroid(imManager);
236
+ console.log("获取写入内存的权限", success);
237
+ if (!success) {
238
+ return;
239
+ }
240
+ let relativePath;
241
+ if (filePath.indexOf(documentPath) >= 0) {
242
+ return filePath.replace(documentPath, '');
243
+ }
244
+ relativePath = resourceDir.file + "/" + filename;
245
+ const destPath = documentPath + relativePath;
246
+ console.log('destPath: ', filePath, destPath);
247
+ if (yield RNFS.exists(destPath)) {
248
+ return destPath;
249
+ }
250
+ yield RNFS.copyFile(filePath, destPath);
251
+ return relativePath;
252
+ });
253
+ }
254
+ function filterUserPath(imManager, path, items = []) {
255
+ if (path !== userPath) {
256
+ return items;
257
+ }
258
+ return items.filter(item => {
259
+ switch (item.path) {
260
+ case userPath + resourceDirBase.file:
261
+ item.name = imManager.t('file');
262
+ return true;
263
+ case userPath + resourceDirBase.video:
264
+ item.name = imManager.t('video');
265
+ return true;
266
+ case userPath + resourceDirBase.picture:
267
+ item.name = imManager.t('picture');
268
+ return true;
269
+ default:
270
+ return false;
271
+ }
272
+ });
273
+ }
274
+ function filterThumbPicture(imManager, path, items) {
275
+ if (path !== userPath + resourceDirBase.video) {
276
+ return items;
277
+ }
278
+ return items.filter(item => {
279
+ if (getFileType(item.path) === 'jpg') {
280
+ return false;
281
+ }
282
+ let thumbPath = item.path.replace('video_', 'thumb_');
283
+ thumbPath = thumbPath.substring(0, thumbPath.lastIndexOf('.'));
284
+ thumbPath = thumbPath + '.jpg';
285
+ item.thumbPath = thumbPath;
286
+ return true;
287
+ });
288
+ }
289
+ export function readFileDir(imManager, path, keyword = '') {
290
+ return __awaiter(this, void 0, void 0, function* () {
291
+ let items = yield RNFS.readDir(path);
292
+ items = filterUserPath(imManager, path, items);
293
+ items = filterThumbPicture(imManager, path, items);
294
+ const list = [];
295
+ for (let i = 0; i < items.length; i++) {
296
+ const item = items[i];
297
+ const mapItem = {
298
+ name: item.name,
299
+ time: item.mtime.getTime(),
300
+ isDir: item.isDirectory(),
301
+ path: item.path,
302
+ size: item.size,
303
+ thumbPath: item.thumbPath,
304
+ };
305
+ mapItem.childrenCount = yield getChildrenCount(imManager, item.isDirectory(), item.path);
306
+ list.push(mapItem);
307
+ }
308
+ if (keyword === '') {
309
+ return list;
310
+ }
311
+ else {
312
+ return list.filter(item => item.name.indexOf(keyword) >= 0);
313
+ }
314
+ });
315
+ }
316
+ export function getChildrenCount(imManager, isDir, path) {
317
+ return __awaiter(this, void 0, void 0, function* () {
318
+ if (!isDir) {
319
+ return 0;
320
+ }
321
+ let children = yield RNFS.readDir(path);
322
+ children = filterUserPath(imManager, path, children);
323
+ children = filterThumbPicture(imManager, path, children);
324
+ return children.length;
325
+ });
326
+ }
327
+ export function getFileRootItem(imManager) {
328
+ return __awaiter(this, void 0, void 0, function* () {
329
+ const rootList = [];
330
+ if (Platform.OS === 'android') {
331
+ const item = yield createRootItem(imManager, imManager.t('storage'), '/storage/emulated/0');
332
+ rootList.push(item);
333
+ }
334
+ const item = yield createRootItem(imManager, imManager.t('user'), userPath);
335
+ rootList.push(item);
336
+ return rootList;
337
+ });
338
+ }
339
+ export function createRootItem(imManager, name, path) {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ let item = {
342
+ name,
343
+ isDir: true,
344
+ path,
345
+ };
346
+ item.childrenCount = yield getChildrenCount(imManager, true, path);
347
+ return item;
348
+ });
349
+ }
350
+ export function getFileType(path) {
351
+ if (path.lastIndexOf('.') === -1) {
352
+ return '';
353
+ }
354
+ return path.slice(path.lastIndexOf('.') + 1);
355
+ }
356
+ export function isImage(path) {
357
+ const imageTypes = ['jpg', 'jpeg', 'gif', 'bmp', 'png', 'webp'];
358
+ const fileType = getFileType(path);
359
+ return imageTypes.includes(fileType);
360
+ }
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculate = void 0;
4
- const rn_ui_1 = require("@smart-link/rn-ui");
5
- const imageMaxSizeDefault = (0, rn_ui_1.dp)(200);
1
+ import { dp } from '@smart-link/rn-ui';
2
+ const imageMaxSizeDefault = dp(200);
6
3
  const goldRate = 0.618;
7
- function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
4
+ export function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
8
5
  let sizeStyle;
9
6
  if (height > width) {
10
7
  let rate = goldRate;
@@ -31,4 +28,3 @@ function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
31
28
  }
32
29
  return sizeStyle;
33
30
  }
34
- exports.calculate = calculate;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,42 +7,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ import Clipboard from '@react-native-clipboard/clipboard';
11
+ import { Linking, PermissionsAndroid, Platform } from 'react-native';
12
+ import Contacts from 'react-native-contacts';
13
+ export const copyPhone = (phoneNum) => {
14
+ Clipboard.setString(phoneNum);
13
15
  };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.addContacts = exports.callPhone = exports.copyPhone = void 0;
16
- const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard"));
17
- const react_native_1 = require("react-native");
18
- const react_native_contacts_1 = __importDefault(require("react-native-contacts"));
19
- const copyPhone = (phoneNum) => {
20
- clipboard_1.default.setString(phoneNum);
21
- };
22
- exports.copyPhone = copyPhone;
23
- const callPhone = (phoneNum) => {
16
+ export const callPhone = (phoneNum) => {
24
17
  let tel = `tel:${phoneNum}`; //目标电话:'tel:1008611'
25
- react_native_1.Linking.canOpenURL(tel).then((supported) => {
18
+ Linking.canOpenURL(tel).then((supported) => {
26
19
  if (!supported) {
27
20
  console.log('Can not handle tel:' + tel);
28
21
  }
29
22
  else {
30
- return react_native_1.Linking.openURL(tel);
23
+ return Linking.openURL(tel);
31
24
  }
32
25
  }).catch(error => console.log('tel error', error));
33
26
  };
34
- exports.callPhone = callPhone;
35
- const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* () {
27
+ export const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* () {
36
28
  const add = () => {
37
- react_native_contacts_1.default.openContactForm({
29
+ Contacts.openContactForm({
38
30
  phoneNumbers: [{
39
31
  label: 'mobile',
40
32
  number: phoneNum
41
33
  }]
42
34
  });
43
35
  };
44
- if (react_native_1.Platform.OS === 'android') {
45
- const granted = yield react_native_1.PermissionsAndroid.request(react_native_1.PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS);
46
- if (granted === react_native_1.PermissionsAndroid.RESULTS.GRANTED) {
36
+ if (Platform.OS === 'android') {
37
+ const granted = yield PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS);
38
+ if (granted === PermissionsAndroid.RESULTS.GRANTED) {
47
39
  console.log('You can use the contacts');
48
40
  add();
49
41
  }
@@ -55,4 +47,3 @@ const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* ()
55
47
  add();
56
48
  }
57
49
  });
58
- exports.addContacts = addContacts;