@smart-link/rn-im 1.0.1
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/README.md +34 -0
- package/assets/avatars-busi-notify.png +0 -0
- package/assets/avatars-empty.png +0 -0
- package/assets/avatars-group.jpg +0 -0
- package/assets/avatars-man.jpg +0 -0
- package/assets/avatars-woman.jpg +0 -0
- package/assets/cloud-backup-begin.png +0 -0
- package/assets/cloud-backup.png +0 -0
- package/assets/group-mgr.png +0 -0
- package/assets/group-owner.png +0 -0
- package/assets/hook-black-double.png +0 -0
- package/assets/hook-black.png +0 -0
- package/assets/hook-blue-double.png +0 -0
- package/assets/hook-blue.png +0 -0
- package/assets/hook-green.png +0 -0
- package/assets/no_message.png +0 -0
- package/assets/share.jpeg +0 -0
- package/assets/voice-left-playing.gif +0 -0
- package/assets/voice-left.png +0 -0
- package/dist/api/addressList.d.ts +27 -0
- package/dist/api/addressList.js +18 -0
- package/dist/api/backup.d.ts +18 -0
- package/dist/api/backup.js +29 -0
- package/dist/api/file.d.ts +4 -0
- package/dist/api/file.js +49 -0
- package/dist/api/user.d.ts +8 -0
- package/dist/api/user.js +16 -0
- package/dist/components/CachedImage.d.ts +11 -0
- package/dist/components/CachedImage.js +48 -0
- package/dist/components/Camera/Camera.d.ts +10 -0
- package/dist/components/Camera/Camera.js +100 -0
- package/dist/components/Camera/CameraCapture.d.ts +32 -0
- package/dist/components/Camera/CameraCapture.js +360 -0
- package/dist/components/Camera/CameraResult.d.ts +11 -0
- package/dist/components/Camera/CameraResult.js +102 -0
- package/dist/components/ChatAvatar/ChatAvatar.d.ts +15 -0
- package/dist/components/ChatAvatar/ChatAvatar.js +134 -0
- package/dist/components/ChatAvatar/ChatAvatarId.d.ts +8 -0
- package/dist/components/ChatAvatar/ChatAvatarId.js +92 -0
- package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +9 -0
- package/dist/components/ChatAvatar/ChatAvatarLocal.js +76 -0
- package/dist/components/ChatAvatar/index.d.ts +2 -0
- package/dist/components/ChatAvatar/index.js +23 -0
- package/dist/components/Favicon.d.ts +7 -0
- package/dist/components/Favicon.js +74 -0
- package/dist/components/FormatTimeText.d.ts +8 -0
- package/dist/components/FormatTimeText.js +24 -0
- package/dist/components/Highlighter.d.ts +9 -0
- package/dist/components/Highlighter.js +42 -0
- package/dist/components/IndicatorText.d.ts +10 -0
- package/dist/components/IndicatorText.js +47 -0
- package/dist/components/LocalImage.d.ts +10 -0
- package/dist/components/LocalImage.js +37 -0
- package/dist/components/NetworkUnconnected.d.ts +3 -0
- package/dist/components/NetworkUnconnected.js +55 -0
- package/dist/components/PopoverWrapper.d.ts +13 -0
- package/dist/components/PopoverWrapper.js +78 -0
- package/dist/components/VideoPlayer.d.ts +13 -0
- package/dist/components/VideoPlayer.js +288 -0
- package/dist/components/styles.d.ts +19 -0
- package/dist/components/styles.js +23 -0
- package/dist/default-assets.d.ts +18 -0
- package/dist/default-assets.js +22 -0
- package/dist/hooks/useFormatMsgTime.d.ts +4 -0
- package/dist/hooks/useFormatMsgTime.js +53 -0
- package/dist/hooks/useImSelector.d.ts +15 -0
- package/dist/hooks/useImSelector.js +48 -0
- package/dist/hooks/useTranslation.d.ts +13 -0
- package/dist/hooks/useTranslation.js +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +28 -0
- package/dist/init.d.ts +17 -0
- package/dist/init.js +116 -0
- package/dist/interface.d.ts +47 -0
- package/dist/interface.js +2 -0
- package/dist/locales/en/addressList.d.ts +3 -0
- package/dist/locales/en/addressList.js +31 -0
- package/dist/locales/index.d.ts +4 -0
- package/dist/locales/index.js +27 -0
- package/dist/locales/lao/addressList.d.ts +3 -0
- package/dist/locales/lao/addressList.js +31 -0
- package/dist/locales/zh/addressList.d.ts +30 -0
- package/dist/locales/zh/addressList.js +32 -0
- package/dist/pages/address-list/AddressList.d.ts +6 -0
- package/dist/pages/address-list/AddressList.js +158 -0
- package/dist/pages/address-list/CardInfo.d.ts +15 -0
- package/dist/pages/address-list/CardInfo.js +42 -0
- package/dist/pages/address-list/ChooseContact.d.ts +6 -0
- package/dist/pages/address-list/ChooseContact.js +197 -0
- package/dist/pages/address-list/Icons.d.ts +5 -0
- package/dist/pages/address-list/Icons.js +16 -0
- package/dist/pages/address-list/Organization.d.ts +13 -0
- package/dist/pages/address-list/Organization.js +221 -0
- package/dist/pages/address-list/UserDetail.d.ts +6 -0
- package/dist/pages/address-list/UserDetail.js +131 -0
- package/dist/pages/address-list/UserJobs.d.ts +6 -0
- package/dist/pages/address-list/UserJobs.js +50 -0
- package/dist/pages/address-list/UserSearch.d.ts +6 -0
- package/dist/pages/address-list/UserSearch.js +82 -0
- package/dist/pages/address-list/addressList.routes.d.ts +50 -0
- package/dist/pages/address-list/addressList.routes.js +50 -0
- package/dist/pages/collection/Collection.d.ts +3 -0
- package/dist/pages/collection/Collection.js +136 -0
- package/dist/pages/collection/ContentFactory.d.ts +6 -0
- package/dist/pages/collection/ContentFactory.js +167 -0
- package/dist/pages/collection/collection.routes.d.ts +9 -0
- package/dist/pages/collection/collection.routes.js +17 -0
- package/dist/pages/conversation/ForwardToConversation.d.ts +6 -0
- package/dist/pages/conversation/ForwardToConversation.js +172 -0
- package/dist/pages/conversation/List.d.ts +6 -0
- package/dist/pages/conversation/List.js +204 -0
- package/dist/pages/conversation/components/ConversationCard.d.ts +12 -0
- package/dist/pages/conversation/components/ConversationCard.js +142 -0
- package/dist/pages/conversation/components/ConversationOption.d.ts +11 -0
- package/dist/pages/conversation/components/ConversationOption.js +99 -0
- package/dist/pages/conversation/conversation.routes.d.ts +2 -0
- package/dist/pages/conversation/conversation.routes.js +74 -0
- package/dist/pages/conversation/setting/GroupTransfer.d.ts +6 -0
- package/dist/pages/conversation/setting/GroupTransfer.js +88 -0
- package/dist/pages/conversation/setting/OptionAvatars.d.ts +22 -0
- package/dist/pages/conversation/setting/OptionAvatars.js +152 -0
- package/dist/pages/conversation/setting/OptionCancelGroup.d.ts +6 -0
- package/dist/pages/conversation/setting/OptionCancelGroup.js +49 -0
- package/dist/pages/conversation/setting/OptionConversation.d.ts +19 -0
- package/dist/pages/conversation/setting/OptionConversation.js +71 -0
- package/dist/pages/conversation/setting/OptionGroup.d.ts +17 -0
- package/dist/pages/conversation/setting/OptionGroup.js +76 -0
- package/dist/pages/conversation/setting/OptionGroupManage.d.ts +6 -0
- package/dist/pages/conversation/setting/OptionGroupManage.js +68 -0
- package/dist/pages/conversation/setting/OptionGroupMoreMember.d.ts +4 -0
- package/dist/pages/conversation/setting/OptionGroupMoreMember.js +124 -0
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.d.ts +6 -0
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +149 -0
- package/dist/pages/conversation/setting/Setting.d.ts +6 -0
- package/dist/pages/conversation/setting/Setting.js +184 -0
- package/dist/pages/conversation/setting/SettingChatBg.d.ts +6 -0
- package/dist/pages/conversation/setting/SettingChatBg.js +95 -0
- package/dist/pages/index.d.ts +8 -0
- package/dist/pages/index.js +27 -0
- package/dist/pages/message/ChooseMember.d.ts +6 -0
- package/dist/pages/message/ChooseMember.js +185 -0
- package/dist/pages/message/MessageBackup/Bar.d.ts +8 -0
- package/dist/pages/message/MessageBackup/Bar.js +77 -0
- package/dist/pages/message/MessageBackup/MessageBackup.d.ts +10 -0
- package/dist/pages/message/MessageBackup/MessageBackup.js +133 -0
- package/dist/pages/message/MessageBackup/RestoreBackupPage.d.ts +6 -0
- package/dist/pages/message/MessageBackup/RestoreBackupPage.js +135 -0
- package/dist/pages/message/MessageBackup/StartBackupPage.d.ts +6 -0
- package/dist/pages/message/MessageBackup/StartBackupPage.js +135 -0
- package/dist/pages/message/MessageBackup/index.d.ts +3 -0
- package/dist/pages/message/MessageBackup/index.js +12 -0
- package/dist/pages/message/MessageBackup/utils.d.ts +46 -0
- package/dist/pages/message/MessageBackup/utils.js +239 -0
- package/dist/pages/message/MessageList.d.ts +6 -0
- package/dist/pages/message/MessageList.js +175 -0
- package/dist/pages/message/MessageRecord.d.ts +6 -0
- package/dist/pages/message/MessageRecord.js +97 -0
- package/dist/pages/message/components/BusiNotifyCard.d.ts +6 -0
- package/dist/pages/message/components/BusiNotifyCard.js +132 -0
- package/dist/pages/message/components/ChatBg.d.ts +7 -0
- package/dist/pages/message/components/ChatBg.js +65 -0
- package/dist/pages/message/components/MessageItem.d.ts +16 -0
- package/dist/pages/message/components/MessageItem.js +205 -0
- package/dist/pages/message/components/MessageItemQuote.d.ts +7 -0
- package/dist/pages/message/components/MessageItemQuote.js +83 -0
- package/dist/pages/message/components/MessageItemTips.d.ts +9 -0
- package/dist/pages/message/components/MessageItemTips.js +67 -0
- package/dist/pages/message/components/MessageOption.d.ts +11 -0
- package/dist/pages/message/components/MessageOption.js +360 -0
- package/dist/pages/message/components/MessagePayload.d.ts +14 -0
- package/dist/pages/message/components/MessagePayload.js +96 -0
- package/dist/pages/message/components/MessagePictureAlbum.d.ts +10 -0
- package/dist/pages/message/components/MessagePictureAlbum.js +105 -0
- package/dist/pages/message/components/MessageReceiptStatus.d.ts +6 -0
- package/dist/pages/message/components/MessageReceiptStatus.js +61 -0
- package/dist/pages/message/components/MessageUndo.d.ts +10 -0
- package/dist/pages/message/components/MessageUndo.js +75 -0
- package/dist/pages/message/components/MultipleBar/index.d.ts +5 -0
- package/dist/pages/message/components/MultipleBar/index.js +116 -0
- package/dist/pages/message/components/Payload/PayloadContact.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadContact.js +86 -0
- package/dist/pages/message/components/Payload/PayloadFile.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadFile.js +115 -0
- package/dist/pages/message/components/Payload/PayloadMultiple.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadMultiple.js +102 -0
- package/dist/pages/message/components/Payload/PayloadNotify.d.ts +9 -0
- package/dist/pages/message/components/Payload/PayloadNotify.js +92 -0
- package/dist/pages/message/components/Payload/PayloadPicture.d.ts +7 -0
- package/dist/pages/message/components/Payload/PayloadPicture.js +69 -0
- package/dist/pages/message/components/Payload/PayloadShare.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadShare.js +100 -0
- package/dist/pages/message/components/Payload/PayloadText.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadText.js +128 -0
- package/dist/pages/message/components/Payload/PayloadVideo.d.ts +4 -0
- package/dist/pages/message/components/Payload/PayloadVideo.js +78 -0
- package/dist/pages/message/components/Payload/PayloadVoice.d.ts +6 -0
- package/dist/pages/message/components/Payload/PayloadVoice.js +155 -0
- package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +12 -0
- package/dist/pages/message/components/Payload/PayloadWrapper.js +73 -0
- package/dist/pages/message/components/Payload/type.d.ts +9 -0
- package/dist/pages/message/components/Payload/type.js +2 -0
- package/dist/pages/message/components/ReceiptBack.d.ts +7 -0
- package/dist/pages/message/components/ReceiptBack.js +82 -0
- package/dist/pages/message/components/TextMixMessage.d.ts +9 -0
- package/dist/pages/message/components/TextMixMessage.js +62 -0
- package/dist/pages/message/components/TextMixQuote.d.ts +61 -0
- package/dist/pages/message/components/TextMixQuote.js +276 -0
- package/dist/pages/message/components/TextMixQuoteMessage.d.ts +14 -0
- package/dist/pages/message/components/TextMixQuoteMessage.js +74 -0
- package/dist/pages/message/components/UploadProgress.d.ts +9 -0
- package/dist/pages/message/components/UploadProgress.js +51 -0
- package/dist/pages/message/components/messageBar/EmojiPanel.d.ts +11 -0
- package/dist/pages/message/components/messageBar/EmojiPanel.js +101 -0
- package/dist/pages/message/components/messageBar/Icons.d.ts +18 -0
- package/dist/pages/message/components/messageBar/Icons.js +88 -0
- package/dist/pages/message/components/messageBar/MessageBar.d.ts +12 -0
- package/dist/pages/message/components/messageBar/MessageBar.js +273 -0
- package/dist/pages/message/components/messageBar/MessageInput.d.ts +21 -0
- package/dist/pages/message/components/messageBar/MessageInput.js +203 -0
- package/dist/pages/message/components/messageBar/OptionPanel.d.ts +8 -0
- package/dist/pages/message/components/messageBar/OptionPanel.js +240 -0
- package/dist/pages/message/components/messageBar/VoiceBar.d.ts +3 -0
- package/dist/pages/message/components/messageBar/VoiceBar.js +272 -0
- package/dist/pages/message/components/messageBar/index.d.ts +2 -0
- package/dist/pages/message/components/messageBar/index.js +23 -0
- package/dist/pages/message/message.routes.d.ts +2 -0
- package/dist/pages/message/message.routes.js +79 -0
- package/dist/pages/search/Search.d.ts +6 -0
- package/dist/pages/search/Search.js +84 -0
- package/dist/pages/search/SearchChatRecords.d.ts +3 -0
- package/dist/pages/search/SearchChatRecords.js +173 -0
- package/dist/pages/search/SearchFile.d.ts +3 -0
- package/dist/pages/search/SearchFile.js +202 -0
- package/dist/pages/search/SearchManager.d.ts +6 -0
- package/dist/pages/search/SearchManager.js +111 -0
- package/dist/pages/search/SearchPicturePage.d.ts +6 -0
- package/dist/pages/search/SearchPicturePage.js +56 -0
- package/dist/pages/search/components/ChatRecords.d.ts +6 -0
- package/dist/pages/search/components/ChatRecords.js +151 -0
- package/dist/pages/search/components/MyGroupChat.d.ts +6 -0
- package/dist/pages/search/components/MyGroupChat.js +128 -0
- package/dist/pages/search/components/PictureMulipleBar.d.ts +10 -0
- package/dist/pages/search/components/PictureMulipleBar.js +105 -0
- package/dist/pages/search/components/SearchFileList.d.ts +7 -0
- package/dist/pages/search/components/SearchFileList.js +173 -0
- package/dist/pages/search/components/SearchPictures.d.ts +8 -0
- package/dist/pages/search/components/SearchPictures.js +220 -0
- package/dist/pages/search/components/SearchShareLinkList.d.ts +7 -0
- package/dist/pages/search/components/SearchShareLinkList.js +112 -0
- package/dist/pages/search/components/SearchUser.d.ts +6 -0
- package/dist/pages/search/components/SearchUser.js +83 -0
- package/dist/pages/search/components/useSearchMessage.d.ts +11 -0
- package/dist/pages/search/components/useSearchMessage.js +68 -0
- package/dist/pages/search/search.routes.d.ts +2 -0
- package/dist/pages/search/search.routes.js +48 -0
- package/dist/pages/search/utils.d.ts +12 -0
- package/dist/pages/search/utils.js +42 -0
- package/dist/pages/types.d.ts +70 -0
- package/dist/pages/types.js +2 -0
- package/dist/slice/contact/contact.action.d.ts +1 -0
- package/dist/slice/contact/contact.action.js +2 -0
- package/dist/slice/contact/contact.slice.d.ts +12 -0
- package/dist/slice/contact/contact.slice.js +60 -0
- package/dist/slice/index.d.ts +9 -0
- package/dist/slice/index.js +15 -0
- package/dist/slice/panel/panel.slice.d.ts +8 -0
- package/dist/slice/panel/panel.slice.js +19 -0
- package/dist/slice/video/video.action.d.ts +5 -0
- package/dist/slice/video/video.action.js +65 -0
- package/dist/slice/video/video.slice.d.ts +17 -0
- package/dist/slice/video/video.slice.js +40 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +9 -0
- package/dist/utils/common-action-sheet.d.ts +8 -0
- package/dist/utils/common-action-sheet.js +45 -0
- package/dist/utils/cookie.d.ts +1 -0
- package/dist/utils/cookie.js +29 -0
- package/dist/utils/emoji.d.ts +9 -0
- package/dist/utils/emoji.js +627 -0
- package/dist/utils/file-icon.d.ts +7 -0
- package/dist/utils/file-icon.js +80 -0
- package/dist/utils/file-operate.d.ts +1 -0
- package/dist/utils/file-operate.js +4 -0
- package/dist/utils/file.d.ts +23 -0
- package/dist/utils/file.js +255 -0
- package/dist/utils/golden-rectangle.d.ts +4 -0
- package/dist/utils/golden-rectangle.js +34 -0
- package/dist/utils/phone.d.ts +2 -0
- package/dist/utils/phone.js +24 -0
- package/dist/utils/request.d.ts +34 -0
- package/dist/utils/request.js +67 -0
- package/dist/utils/scroll.d.ts +1 -0
- package/dist/utils/scroll.js +12 -0
- package/dist/utils/summary.d.ts +2 -0
- package/dist/utils/summary.js +42 -0
- package/dist/utils/take-camera.d.ts +2 -0
- package/dist/utils/take-camera.js +41 -0
- package/dist/utils/text-mix.d.ts +9 -0
- package/dist/utils/text-mix.js +82 -0
- package/dist/utils/upload.d.ts +5 -0
- package/dist/utils/upload.js +80 -0
- package/package.json +79 -0
@@ -0,0 +1,360 @@
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
+
exports.buildPictureData = void 0;
|
39
|
+
const react_1 = __importStar(require("react"));
|
40
|
+
const react_native_1 = require("react-native");
|
41
|
+
const react_native_vision_camera_1 = require("react-native-vision-camera");
|
42
|
+
const MaterialCommunityIcons_1 = __importDefault(require("react-native-vector-icons/MaterialCommunityIcons"));
|
43
|
+
const im_base_1 = require("@smart-link/im-base");
|
44
|
+
const file_1 = require("../../utils/file");
|
45
|
+
const init_1 = require("../../init");
|
46
|
+
const rn_ui_1 = require("@smart-link/rn-ui");
|
47
|
+
const react_native_compressor_1 = require("react-native-compressor");
|
48
|
+
const { PICTURE, VIDEO } = im_base_1.ResourceType;
|
49
|
+
const FlashModeValue = ['on', 'off', 'auto'];
|
50
|
+
const FlashModeIcon = ['flash', 'flash-off', 'flash-auto'];
|
51
|
+
const CameraTypeValue = ['back', 'front'];
|
52
|
+
const CameraTypeIcon = ['camera-retake-outline', 'camera-retake'];
|
53
|
+
const timerHolder = { duration: 0 };
|
54
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = react_native_1.Dimensions.get('window');
|
55
|
+
const CameraCapture = (0, react_1.memo)(props => {
|
56
|
+
const { finishTakePicture, finishTakeRecord, cancelCamera } = props;
|
57
|
+
const camera = (0, react_1.useRef)(null);
|
58
|
+
const [cameraTypeIndex, setCameraTypeIndex] = (0, react_1.useState)(0);
|
59
|
+
const [isRecording, setIsRecording] = (0, react_1.useState)(false);
|
60
|
+
const [flashModeIndex, setFlashModeIndex] = (0, react_1.useState)(2);
|
61
|
+
const microphone = (0, react_native_vision_camera_1.useMicrophonePermission)();
|
62
|
+
const device = (0, react_native_vision_camera_1.useCameraDevice)(CameraTypeValue[cameraTypeIndex]);
|
63
|
+
const format = (0, react_native_vision_camera_1.useCameraFormat)(device, [
|
64
|
+
{ videoAspectRatio: SCREEN_HEIGHT / SCREEN_WIDTH, fps: 60, photoResolution: 'max' },
|
65
|
+
{
|
66
|
+
photoAspectRatio: SCREEN_HEIGHT / SCREEN_WIDTH,
|
67
|
+
photoResolution: 'max',
|
68
|
+
}
|
69
|
+
]);
|
70
|
+
const takePicture = () => __awaiter(void 0, void 0, void 0, function* () {
|
71
|
+
if (camera.current && !isRecording) {
|
72
|
+
const success = yield (0, file_1.requestSaveFilePermissionIfAndroid)((0, init_1.getImManager)());
|
73
|
+
if (!success) {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
const photo = yield camera.current.takePhoto({
|
77
|
+
flash: FlashModeValue[flashModeIndex],
|
78
|
+
});
|
79
|
+
console.log('photo: ', photo);
|
80
|
+
const pictureData = yield buildPictureData(photo);
|
81
|
+
finishTakePicture && finishTakePicture(pictureData);
|
82
|
+
}
|
83
|
+
});
|
84
|
+
const takeRecord = () => __awaiter(void 0, void 0, void 0, function* () {
|
85
|
+
if (camera.current) {
|
86
|
+
const success = yield (0, file_1.requestSaveFilePermissionIfAndroid)((0, init_1.getImManager)());
|
87
|
+
if (!success) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
camera.current.startRecording({
|
91
|
+
videoBitRate: 'normal',
|
92
|
+
videoCodec: 'h264',
|
93
|
+
onRecordingFinished: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
94
|
+
console.log('onRecordingFinished: ', data);
|
95
|
+
const videoData = yield buildVideoData(data);
|
96
|
+
finishTakeRecord === null || finishTakeRecord === void 0 ? void 0 : finishTakeRecord(videoData);
|
97
|
+
}),
|
98
|
+
onRecordingError: (error) => {
|
99
|
+
console.log('onRecordingError: ', error);
|
100
|
+
},
|
101
|
+
});
|
102
|
+
setIsRecording(true);
|
103
|
+
}
|
104
|
+
});
|
105
|
+
const stopRecord = () => {
|
106
|
+
var _a;
|
107
|
+
console.log('stopRecord: ', isRecording);
|
108
|
+
if (isRecording) {
|
109
|
+
(_a = camera.current) === null || _a === void 0 ? void 0 : _a.stopRecording();
|
110
|
+
setIsRecording(false);
|
111
|
+
}
|
112
|
+
};
|
113
|
+
const switchCameraType = (0, react_1.useCallback)(() => {
|
114
|
+
const index = (cameraTypeIndex + 1) % 2;
|
115
|
+
setCameraTypeIndex(index);
|
116
|
+
}, [cameraTypeIndex]);
|
117
|
+
const switchFlashMode = (0, react_1.useCallback)(() => {
|
118
|
+
const index = (flashModeIndex + 1) % 3;
|
119
|
+
setFlashModeIndex(index);
|
120
|
+
}, [flashModeIndex]);
|
121
|
+
const onCancel = () => {
|
122
|
+
var _a;
|
123
|
+
if (isRecording) {
|
124
|
+
(_a = camera.current) === null || _a === void 0 ? void 0 : _a.stopRecording();
|
125
|
+
setIsRecording(false);
|
126
|
+
}
|
127
|
+
cancelCamera && cancelCamera();
|
128
|
+
};
|
129
|
+
return (<react_native_1.View style={styles.camera}>
|
130
|
+
{device ? (<react_native_vision_camera_1.Camera ref={camera} device={device} format={format} isActive={true} style={styles.preview} photo={true} video={true} audio={microphone.hasPermission} outputOrientation="portrait" onInitialized={() => {
|
131
|
+
console.log('Camera initialized!');
|
132
|
+
}} onError={error => {
|
133
|
+
console.log(error);
|
134
|
+
}}/>) : (<react_native_1.View style={styles.emptyContainer}>
|
135
|
+
<react_native_1.Text style={styles.text}>Your phone does not have a Camera.</react_native_1.Text>
|
136
|
+
</react_native_1.View>)}
|
137
|
+
|
138
|
+
{isRecording && (<>
|
139
|
+
<Timer style={styles.time}/>
|
140
|
+
<Bounds style={styles.bounds}/>
|
141
|
+
</>)}
|
142
|
+
|
143
|
+
<react_native_1.TouchableOpacity style={styles.switch} onPress={switchCameraType}>
|
144
|
+
<MaterialCommunityIcons_1.default name={CameraTypeIcon[cameraTypeIndex]} size={(0, rn_ui_1.dp)(25)} color={'#fff'}/>
|
145
|
+
</react_native_1.TouchableOpacity>
|
146
|
+
|
147
|
+
<react_native_1.TouchableOpacity style={styles.flash} onPress={switchFlashMode}>
|
148
|
+
<MaterialCommunityIcons_1.default name={FlashModeIcon[flashModeIndex]} size={(0, rn_ui_1.dp)(25)} color={'#fff'}/>
|
149
|
+
</react_native_1.TouchableOpacity>
|
150
|
+
|
151
|
+
{!isRecording && (<react_native_1.TouchableOpacity style={styles.cancel} onPress={onCancel}>
|
152
|
+
<rn_ui_1.CaihIcon name="arrow-down-outlined" size={(0, rn_ui_1.dp)(30)} color={'#fff'}/>
|
153
|
+
</react_native_1.TouchableOpacity>)}
|
154
|
+
|
155
|
+
<react_native_1.TouchableOpacity style={styles.capture} onPress={takePicture} onLongPress={takeRecord} onPressOut={stopRecord}/>
|
156
|
+
</react_native_1.View>);
|
157
|
+
});
|
158
|
+
const Timer = (0, react_1.memo)(props => {
|
159
|
+
const { style } = props;
|
160
|
+
const [duration, setDuration] = (0, react_1.useState)(0);
|
161
|
+
const showPoint = duration % 2 === 0;
|
162
|
+
(0, react_1.useEffect)(() => {
|
163
|
+
const timer = setInterval(() => {
|
164
|
+
timerHolder.duration = timerHolder.duration + 1;
|
165
|
+
setDuration(timerHolder.duration);
|
166
|
+
}, 500);
|
167
|
+
return () => {
|
168
|
+
clearInterval(timer);
|
169
|
+
timerHolder.duration = 0;
|
170
|
+
};
|
171
|
+
}, []);
|
172
|
+
return (<react_native_1.View style={style}>
|
173
|
+
{showPoint && <react_native_1.View style={styles.point}/>}
|
174
|
+
<react_native_1.Text style={styles.timeText}>{(0, im_base_1.numberToTime)(duration / 2)}</react_native_1.Text>
|
175
|
+
</react_native_1.View>);
|
176
|
+
});
|
177
|
+
const Bounds = (0, react_1.memo)(props => {
|
178
|
+
const { style } = props;
|
179
|
+
const scale = new react_native_1.Animated.Value(2.2);
|
180
|
+
(0, react_1.useEffect)(() => {
|
181
|
+
const seq = react_native_1.Animated.sequence([
|
182
|
+
react_native_1.Animated.timing(scale, {
|
183
|
+
toValue: 2.5,
|
184
|
+
duration: 1000,
|
185
|
+
useNativeDriver: true,
|
186
|
+
}),
|
187
|
+
react_native_1.Animated.timing(scale, {
|
188
|
+
toValue: 2.2,
|
189
|
+
duration: 1000,
|
190
|
+
useNativeDriver: true,
|
191
|
+
}),
|
192
|
+
]);
|
193
|
+
react_native_1.Animated.loop(seq).start();
|
194
|
+
}, [scale]);
|
195
|
+
return <react_native_1.Animated.View style={[style, { transform: [{ scale: scale }] }]}/>;
|
196
|
+
});
|
197
|
+
const styles = react_native_1.StyleSheet.create({
|
198
|
+
camera: {
|
199
|
+
flex: 1,
|
200
|
+
},
|
201
|
+
preview: {
|
202
|
+
flex: 1,
|
203
|
+
justifyContent: 'flex-end',
|
204
|
+
alignItems: 'center',
|
205
|
+
},
|
206
|
+
time: {
|
207
|
+
flexDirection: 'row',
|
208
|
+
height: (0, rn_ui_1.dp)(60),
|
209
|
+
width: (0, rn_ui_1.dp)(150),
|
210
|
+
position: 'absolute',
|
211
|
+
top: (0, rn_ui_1.dp)(30),
|
212
|
+
alignSelf: 'center',
|
213
|
+
justifyContent: 'center',
|
214
|
+
alignItems: 'center',
|
215
|
+
},
|
216
|
+
timeText: {
|
217
|
+
fontSize: (0, rn_ui_1.dp)(18),
|
218
|
+
color: '#fff',
|
219
|
+
},
|
220
|
+
switch: {
|
221
|
+
height: (0, rn_ui_1.dp)(60),
|
222
|
+
width: (0, rn_ui_1.dp)(60),
|
223
|
+
position: 'absolute',
|
224
|
+
top: (0, rn_ui_1.dp)(30),
|
225
|
+
right: (0, rn_ui_1.dp)(15),
|
226
|
+
justifyContent: 'center',
|
227
|
+
alignItems: 'center',
|
228
|
+
},
|
229
|
+
flash: {
|
230
|
+
height: (0, rn_ui_1.dp)(60),
|
231
|
+
width: (0, rn_ui_1.dp)(60),
|
232
|
+
position: 'absolute',
|
233
|
+
top: (0, rn_ui_1.dp)(31),
|
234
|
+
right: (0, rn_ui_1.dp)(60),
|
235
|
+
justifyContent: 'center',
|
236
|
+
alignItems: 'center',
|
237
|
+
},
|
238
|
+
cancel: {
|
239
|
+
height: (0, rn_ui_1.dp)(75),
|
240
|
+
width: (0, rn_ui_1.dp)(75),
|
241
|
+
position: 'absolute',
|
242
|
+
bottom: (0, rn_ui_1.dp)(130),
|
243
|
+
left: (0, rn_ui_1.dp)(50),
|
244
|
+
justifyContent: 'center',
|
245
|
+
alignItems: 'center',
|
246
|
+
},
|
247
|
+
capture: {
|
248
|
+
borderWidth: (0, rn_ui_1.dp)(15),
|
249
|
+
borderColor: '#ddd',
|
250
|
+
backgroundColor: '#fff',
|
251
|
+
borderRadius: (0, rn_ui_1.dp)(40),
|
252
|
+
height: (0, rn_ui_1.dp)(75),
|
253
|
+
width: (0, rn_ui_1.dp)(75),
|
254
|
+
position: 'absolute',
|
255
|
+
bottom: (0, rn_ui_1.dp)(130),
|
256
|
+
alignSelf: 'center',
|
257
|
+
justifyContent: 'center',
|
258
|
+
alignItems: 'center',
|
259
|
+
},
|
260
|
+
point: {
|
261
|
+
marginRight: (0, rn_ui_1.dp)(5),
|
262
|
+
width: (0, rn_ui_1.dp)(11),
|
263
|
+
height: (0, rn_ui_1.dp)(11),
|
264
|
+
backgroundColor: '#f2121a',
|
265
|
+
borderRadius: (0, rn_ui_1.dp)(6),
|
266
|
+
position: 'absolute',
|
267
|
+
left: (0, rn_ui_1.dp)(30),
|
268
|
+
},
|
269
|
+
bounds: {
|
270
|
+
backgroundColor: '#fff',
|
271
|
+
borderRadius: (0, rn_ui_1.dp)(40),
|
272
|
+
height: (0, rn_ui_1.dp)(75),
|
273
|
+
width: (0, rn_ui_1.dp)(75),
|
274
|
+
position: 'absolute',
|
275
|
+
bottom: (0, rn_ui_1.dp)(130),
|
276
|
+
alignSelf: 'center',
|
277
|
+
justifyContent: 'center',
|
278
|
+
alignItems: 'center',
|
279
|
+
opacity: 0.2,
|
280
|
+
},
|
281
|
+
emptyContainer: {
|
282
|
+
flex: 1,
|
283
|
+
justifyContent: 'center',
|
284
|
+
alignItems: 'center',
|
285
|
+
backgroundColor: '#000',
|
286
|
+
},
|
287
|
+
text: {
|
288
|
+
color: 'white',
|
289
|
+
fontSize: 11,
|
290
|
+
fontWeight: 'bold',
|
291
|
+
textAlign: 'center',
|
292
|
+
},
|
293
|
+
});
|
294
|
+
function buildPictureData(data) {
|
295
|
+
return __awaiter(this, void 0, void 0, function* () {
|
296
|
+
const uid = (0, react_native_compressor_1.uuidv4)();
|
297
|
+
const path = data.path;
|
298
|
+
const ext = path.split('.').pop();
|
299
|
+
const filename = PICTURE + '_' + uid + '.' + ext;
|
300
|
+
const tmp = yield react_native_compressor_1.Image.compress(path, {
|
301
|
+
compressionMethod: 'auto'
|
302
|
+
});
|
303
|
+
const localPath = yield (0, file_1.moveFile)(tmp, filename, PICTURE);
|
304
|
+
const size = yield (0, react_native_compressor_1.getFileSize)(localPath);
|
305
|
+
let width = data.width;
|
306
|
+
let height = data.height;
|
307
|
+
if (data.orientation === 'portrait') {
|
308
|
+
if (width > height) {
|
309
|
+
[width, height] = [height, width];
|
310
|
+
}
|
311
|
+
}
|
312
|
+
return {
|
313
|
+
filename: filename,
|
314
|
+
localPath: localPath,
|
315
|
+
height: height,
|
316
|
+
width: width,
|
317
|
+
ext: ext,
|
318
|
+
type: 'image/' + ext,
|
319
|
+
size,
|
320
|
+
};
|
321
|
+
});
|
322
|
+
}
|
323
|
+
exports.buildPictureData = buildPictureData;
|
324
|
+
function buildVideoData(data) {
|
325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
326
|
+
const uid = (0, react_native_compressor_1.uuidv4)();
|
327
|
+
const path = data.path;
|
328
|
+
try {
|
329
|
+
const compressPath = yield react_native_compressor_1.Video.compress((0, file_1.toAbsolutePath)(path), {
|
330
|
+
compressionMethod: 'auto',
|
331
|
+
maxSize: 1080,
|
332
|
+
});
|
333
|
+
const ext = compressPath.split('.').pop();
|
334
|
+
const filename = VIDEO + '_' + uid + '.' + ext;
|
335
|
+
const size = yield (0, react_native_compressor_1.getFileSize)(compressPath);
|
336
|
+
let thumb = yield (0, react_native_compressor_1.createVideoThumbnail)((0, file_1.toAbsolutePath)(compressPath));
|
337
|
+
console.log('RNThumbnail', thumb);
|
338
|
+
const imageName = 'thumb_' + uid + '.jpg';
|
339
|
+
const imagePath = yield (0, file_1.moveFile)(thumb.path, imageName, VIDEO);
|
340
|
+
const localPath = yield (0, file_1.moveFile)(compressPath, filename, VIDEO);
|
341
|
+
return {
|
342
|
+
filename,
|
343
|
+
localPath: localPath,
|
344
|
+
imageName,
|
345
|
+
imagePath,
|
346
|
+
duration: data.duration,
|
347
|
+
ext: ext,
|
348
|
+
type: 'video/' + ext,
|
349
|
+
width: thumb.width,
|
350
|
+
height: thumb.height,
|
351
|
+
size,
|
352
|
+
};
|
353
|
+
}
|
354
|
+
catch (e) {
|
355
|
+
console.log('RNThumbnail', e);
|
356
|
+
return null;
|
357
|
+
}
|
358
|
+
});
|
359
|
+
}
|
360
|
+
exports.default = CameraCapture;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export interface ICameraResultProps {
|
3
|
+
horizontal?: boolean;
|
4
|
+
source: any;
|
5
|
+
isVideo?: boolean;
|
6
|
+
cancelResult: () => void;
|
7
|
+
confirmResult: () => void;
|
8
|
+
editResult: () => void;
|
9
|
+
}
|
10
|
+
declare const CameraResult: (props: ICameraResultProps) => React.JSX.Element;
|
11
|
+
export default CameraResult;
|
@@ -0,0 +1,102 @@
|
|
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 MaterialCommunityIcons_1 = __importDefault(require("react-native-vector-icons/MaterialCommunityIcons"));
|
33
|
+
const CameraResult = (props) => {
|
34
|
+
const { horizontal = false, isVideo = false, source, cancelResult, confirmResult, editResult, } = props;
|
35
|
+
const resizeMode = horizontal ? 'contain' : 'cover';
|
36
|
+
(0, react_1.useEffect)(() => {
|
37
|
+
return () => {
|
38
|
+
console.log('CameraResult unmounted');
|
39
|
+
};
|
40
|
+
}, []);
|
41
|
+
return (<react_native_1.View style={styles.confirm}>
|
42
|
+
<react_native_1.Image style={styles.pic} resizeMode={resizeMode} source={Object.assign({}, source)}/>
|
43
|
+
|
44
|
+
<react_native_1.View style={styles.bar}>
|
45
|
+
<react_native_1.TouchableOpacity style={styles.cancel} onPress={cancelResult}>
|
46
|
+
<MaterialCommunityIcons_1.default name='close' size={(0, rn_ui_1.dp)(30)} color={'#666'}/>
|
47
|
+
</react_native_1.TouchableOpacity>
|
48
|
+
|
49
|
+
{!isVideo && <react_native_1.TouchableOpacity style={styles.cancel} onPress={editResult}>
|
50
|
+
<MaterialCommunityIcons_1.default name='circle-edit-outline' size={(0, rn_ui_1.dp)(30)} color={'#666'}/>
|
51
|
+
</react_native_1.TouchableOpacity>}
|
52
|
+
|
53
|
+
<react_native_1.TouchableOpacity style={styles.ok} onPress={confirmResult}>
|
54
|
+
<MaterialCommunityIcons_1.default name='check' size={(0, rn_ui_1.dp)(30)} color={'#666'}/>
|
55
|
+
</react_native_1.TouchableOpacity>
|
56
|
+
</react_native_1.View>
|
57
|
+
</react_native_1.View>);
|
58
|
+
};
|
59
|
+
const styles = react_native_1.StyleSheet.create({
|
60
|
+
confirm: {
|
61
|
+
flex: 1,
|
62
|
+
backgroundColor: '#000',
|
63
|
+
justifyContent: "center",
|
64
|
+
},
|
65
|
+
pic: {
|
66
|
+
flex: 1,
|
67
|
+
},
|
68
|
+
bar: {
|
69
|
+
position: 'absolute',
|
70
|
+
justifyContent: 'space-between',
|
71
|
+
alignItems: 'center',
|
72
|
+
bottom: (0, rn_ui_1.dp)(130),
|
73
|
+
left: (0, rn_ui_1.dp)(20),
|
74
|
+
right: (0, rn_ui_1.dp)(20),
|
75
|
+
flexDirection: 'row',
|
76
|
+
},
|
77
|
+
cancel: {
|
78
|
+
backgroundColor: '#fff',
|
79
|
+
borderRadius: (0, rn_ui_1.dp)(40),
|
80
|
+
height: (0, rn_ui_1.dp)(80),
|
81
|
+
width: (0, rn_ui_1.dp)(80),
|
82
|
+
justifyContent: 'center',
|
83
|
+
alignItems: 'center',
|
84
|
+
},
|
85
|
+
edit: {
|
86
|
+
backgroundColor: '#fff',
|
87
|
+
borderRadius: (0, rn_ui_1.dp)(40),
|
88
|
+
height: (0, rn_ui_1.dp)(80),
|
89
|
+
width: (0, rn_ui_1.dp)(80),
|
90
|
+
justifyContent: 'center',
|
91
|
+
alignItems: 'center',
|
92
|
+
},
|
93
|
+
ok: {
|
94
|
+
backgroundColor: '#fff',
|
95
|
+
borderRadius: (0, rn_ui_1.dp)(40),
|
96
|
+
height: (0, rn_ui_1.dp)(80),
|
97
|
+
width: (0, rn_ui_1.dp)(80),
|
98
|
+
justifyContent: 'center',
|
99
|
+
alignItems: 'center',
|
100
|
+
}
|
101
|
+
});
|
102
|
+
exports.default = CameraResult;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ConversationType } from '@smart-link/im-base';
|
3
|
+
import { ChatAvatarIdProps } from "../../components/ChatAvatar/ChatAvatarId";
|
4
|
+
type ChatAvatarProps = {
|
5
|
+
id: string;
|
6
|
+
name: string;
|
7
|
+
url?: string;
|
8
|
+
type?: ConversationType;
|
9
|
+
size?: number;
|
10
|
+
disabled?: boolean;
|
11
|
+
editable?: boolean;
|
12
|
+
onUpdate?: (url: string) => void;
|
13
|
+
} & Pick<ChatAvatarIdProps, 'priority'>;
|
14
|
+
declare const _default: React.MemoExoticComponent<({ id, name, url: fileId, size, disabled, type, editable, onUpdate, priority }: ChatAvatarProps) => React.JSX.Element>;
|
15
|
+
export default _default;
|
@@ -0,0 +1,134 @@
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
+
const rn_ui_1 = require("@smart-link/rn-ui");
|
39
|
+
const react_1 = __importStar(require("react"));
|
40
|
+
const react_native_1 = require("react-native");
|
41
|
+
const react_native_image_crop_picker_1 = __importDefault(require("react-native-image-crop-picker"));
|
42
|
+
const init_1 = require("../../init");
|
43
|
+
const im_base_1 = require("@smart-link/im-base");
|
44
|
+
const default_assets_1 = require("../../default-assets");
|
45
|
+
const upload_1 = __importDefault(require("../../utils/upload"));
|
46
|
+
const user_1 = require("../../api/user");
|
47
|
+
const useImSelector_1 = require("../../hooks/useImSelector");
|
48
|
+
const file_1 = require("../../utils/file");
|
49
|
+
const ChatAvatarId_1 = __importDefault(require("../../components/ChatAvatar/ChatAvatarId"));
|
50
|
+
const ChatAvatar = ({ id, name, url: fileId, size = (0, rn_ui_1.dp)(40), disabled, type = im_base_1.ConversationType.C2C, editable, onUpdate, priority = 'cache' }) => {
|
51
|
+
const { user } = (0, useImSelector_1.useAuth)();
|
52
|
+
const navigation = (0, rn_ui_1.useNavigation)();
|
53
|
+
const [ready, setReady] = (0, react_1.useState)(false);
|
54
|
+
(0, react_1.useEffect)(() => {
|
55
|
+
let imManager = (0, init_1.getImManager)();
|
56
|
+
if (!imManager) {
|
57
|
+
const cycle = setInterval(() => {
|
58
|
+
imManager = (0, init_1.getImManager)();
|
59
|
+
if (imManager) {
|
60
|
+
clearInterval(cycle);
|
61
|
+
setReady(true);
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
}, 100);
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
setReady(true);
|
68
|
+
}
|
69
|
+
}, []);
|
70
|
+
const defaultAvatar = {
|
71
|
+
[im_base_1.ConversationType.C2C]: default_assets_1.defaultAvatars.EMPTY,
|
72
|
+
[im_base_1.ConversationType.C2G]: default_assets_1.defaultAvatars.GROUP,
|
73
|
+
[im_base_1.ConversationType.B2C]: default_assets_1.defaultAvatars.BUSI_NOTIFY,
|
74
|
+
}[type] || default_assets_1.defaultAvatars.EMPTY;
|
75
|
+
const onLongPress = () => __awaiter(void 0, void 0, void 0, function* () {
|
76
|
+
if (editable) {
|
77
|
+
const imManager = (0, init_1.getImManager)();
|
78
|
+
let image;
|
79
|
+
try {
|
80
|
+
image = yield react_native_image_crop_picker_1.default.openPicker({
|
81
|
+
cropping: true,
|
82
|
+
width: 300,
|
83
|
+
height: 300,
|
84
|
+
compressImageQuality: 0.7,
|
85
|
+
});
|
86
|
+
}
|
87
|
+
catch (e) {
|
88
|
+
console.log('pick cancel: ', e);
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
console.log('pick: ', image);
|
92
|
+
const fileId = yield (0, upload_1.default)(image.path, image.mime);
|
93
|
+
const localPath = yield (0, file_1.moveFile)(image.path, fileId + '.jpg', 'avatars');
|
94
|
+
console.log('upload: ', fileId);
|
95
|
+
if (type === im_base_1.ConversationType.C2C) {
|
96
|
+
imManager.user.avatars = fileId;
|
97
|
+
// 更新头像b
|
98
|
+
setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
99
|
+
try {
|
100
|
+
yield (0, user_1.updateUserInfo)(Object.assign(Object.assign({}, user), { avatars: fileId }));
|
101
|
+
}
|
102
|
+
catch (e) {
|
103
|
+
console.log('updateUserInfo error: ', e);
|
104
|
+
}
|
105
|
+
}), 0);
|
106
|
+
}
|
107
|
+
else {
|
108
|
+
// 更新群头像
|
109
|
+
yield (0, im_base_1.updateGroupInfo)({
|
110
|
+
chatGroupId: id,
|
111
|
+
avatars: fileId,
|
112
|
+
});
|
113
|
+
}
|
114
|
+
// 更新本地资源
|
115
|
+
imManager.updateResource({ url: fileId, localPath });
|
116
|
+
imManager.store.dispatch(im_base_1.ConversationActions.updateAvatars(imManager, id, fileId));
|
117
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(fileId);
|
118
|
+
}
|
119
|
+
});
|
120
|
+
const onPress = () => {
|
121
|
+
if (disabled || editable)
|
122
|
+
return;
|
123
|
+
if (type === im_base_1.ConversationType.C2C) {
|
124
|
+
// 跳转到个人详情页
|
125
|
+
navigation.navigate('UserDetail', {
|
126
|
+
userId: id,
|
127
|
+
});
|
128
|
+
}
|
129
|
+
};
|
130
|
+
return (<react_native_1.TouchableOpacity disabled={disabled} onPress={onPress} onLongPress={onLongPress}>
|
131
|
+
{ready ? <ChatAvatarId_1.default priority={priority} id={id} fileId={fileId} size={size} name={name} defaultAvatar={defaultAvatar}/> : <rn_ui_1.Avatar icon={<react_native_1.Image style={size ? { width: size, height: size } : {}} source={defaultAvatar}/>}/>}
|
132
|
+
</react_native_1.TouchableOpacity>);
|
133
|
+
};
|
134
|
+
exports.default = (0, react_1.memo)(ChatAvatar);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { ChatAvatarProps } from "./ChatAvatarLocal";
|
3
|
+
export interface ChatAvatarIdProps extends ChatAvatarProps {
|
4
|
+
id: string;
|
5
|
+
priority?: 'cache' | 'outside';
|
6
|
+
}
|
7
|
+
declare const ChatAvatarId: ({ id, fileId: fileIdProp, priority, ...ret }: ChatAvatarIdProps) => React.JSX.Element;
|
8
|
+
export default ChatAvatarId;
|