@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.
- package/assets/file-dir.jpg +0 -0
- package/dist/api/addressList.js +6 -17
- package/dist/api/backup.js +8 -20
- package/dist/api/file.js +6 -35
- package/dist/api/user.js +6 -16
- package/dist/components/CachedImage.js +14 -42
- package/dist/components/Camera/Camera.js +26 -54
- package/dist/components/Camera/CameraCapture.js +99 -128
- package/dist/components/Camera/CameraResult.js +33 -61
- package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
- package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
- package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
- package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarLocal.js +22 -25
- package/dist/components/ChatAvatar/index.js +2 -23
- package/dist/components/Favicon.js +6 -34
- package/dist/components/FormatTimeText.js +5 -10
- package/dist/components/Highlighter.js +9 -34
- package/dist/components/IndicatorText.js +14 -39
- package/dist/components/LocalImage.js +7 -32
- package/dist/components/NetworkUnconnected.js +14 -42
- package/dist/components/PopoverWrapper.js +22 -47
- package/dist/components/VideoPlayer.js +111 -138
- package/dist/components/styles.js +10 -13
- package/dist/default-assets.d.ts +2 -0
- package/dist/default-assets.js +9 -10
- package/dist/hooks/useDownloadSource.js +7 -12
- package/dist/hooks/useFormatMsgTime.js +5 -13
- package/dist/hooks/useImReady.js +7 -10
- package/dist/hooks/useImSelector.js +34 -48
- package/dist/hooks/useTranslation.js +5 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -28
- package/dist/init.js +30 -40
- package/dist/interface.d.ts +9 -0
- package/dist/interface.js +1 -2
- package/dist/locales/en/addressList.js +1 -3
- package/dist/locales/index.js +4 -27
- package/dist/locales/lao/addressList.js +1 -3
- package/dist/locales/zh/addressList.js +1 -3
- package/dist/pages/address-list/AddressList.js +33 -61
- package/dist/pages/address-list/CardInfo.js +10 -18
- package/dist/pages/address-list/ChooseContact.js +50 -78
- package/dist/pages/address-list/Icons.js +7 -14
- package/dist/pages/address-list/Organization.js +59 -89
- package/dist/pages/address-list/UserDetail.js +55 -83
- package/dist/pages/address-list/UserJobs.js +31 -33
- package/dist/pages/address-list/UserSearch.js +29 -54
- package/dist/pages/address-list/addressList.routes.js +11 -16
- package/dist/pages/collection/Collection.js +53 -81
- package/dist/pages/collection/ContentFactory.js +53 -82
- package/dist/pages/collection/collection.routes.js +3 -9
- package/dist/pages/conversation/ForwardToConversation.js +63 -91
- package/dist/pages/conversation/List.js +74 -102
- package/dist/pages/conversation/components/ConversationCard.js +46 -74
- package/dist/pages/conversation/components/ConversationOption.js +27 -55
- package/dist/pages/conversation/conversation.routes.js +17 -23
- package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
- package/dist/pages/conversation/setting/OptionAvatars.d.ts +1 -1
- package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
- package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
- package/dist/pages/conversation/setting/OptionConversation.js +20 -48
- package/dist/pages/conversation/setting/OptionGroup.d.ts +1 -1
- package/dist/pages/conversation/setting/OptionGroup.js +20 -48
- package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
- package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
- package/dist/pages/conversation/setting/Setting.js +50 -56
- package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
- package/dist/pages/index.js +7 -27
- package/dist/pages/message/ChooseMember.js +56 -84
- package/dist/pages/message/FileSelector.d.ts +6 -0
- package/dist/pages/message/FileSelector.js +235 -0
- package/dist/pages/message/MessageBackup/Bar.js +18 -43
- package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
- package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/index.js +3 -12
- package/dist/pages/message/MessageBackup/utils.js +14 -22
- package/dist/pages/message/MessageList.js +151 -141
- package/dist/pages/message/MessageRecord.js +74 -87
- package/dist/pages/message/components/BusiNotifyCard.js +60 -85
- package/dist/pages/message/components/ChatBg.js +11 -36
- package/dist/pages/message/components/MessageItem.d.ts +2 -1
- package/dist/pages/message/components/MessageItem.js +85 -112
- package/dist/pages/message/components/MessageItemQuote.js +30 -58
- package/dist/pages/message/components/MessageItemTips.js +27 -55
- package/dist/pages/message/components/MessageOption.d.ts +7 -3
- package/dist/pages/message/components/MessageOption.js +107 -134
- package/dist/pages/message/components/MessagePayload.d.ts +2 -1
- package/dist/pages/message/components/MessagePayload.js +36 -64
- package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
- package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
- package/dist/pages/message/components/MessageUndo.js +18 -48
- package/dist/pages/message/components/MultipleBar/index.js +48 -76
- package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
- package/dist/pages/message/components/Payload/PayloadFile.d.ts +1 -1
- package/dist/pages/message/components/Payload/PayloadFile.js +44 -68
- package/dist/pages/message/components/Payload/PayloadMultiple.js +46 -70
- package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
- package/dist/pages/message/components/Payload/PayloadPicture.d.ts +1 -1
- package/dist/pages/message/components/Payload/PayloadPicture.js +21 -50
- package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
- package/dist/pages/message/components/Payload/PayloadText.js +39 -67
- package/dist/pages/message/components/Payload/PayloadVideo.js +30 -57
- package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
- package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +2 -1
- package/dist/pages/message/components/Payload/PayloadWrapper.js +24 -44
- package/dist/pages/message/components/Payload/type.d.ts +2 -1
- package/dist/pages/message/components/Payload/type.js +1 -2
- package/dist/pages/message/components/ReceiptBack.js +30 -60
- package/dist/pages/message/components/TextMixMessage.js +13 -38
- package/dist/pages/message/components/TextMixQuote.js +128 -162
- package/dist/pages/message/components/TextMixQuoteMessage.js +19 -47
- package/dist/pages/message/components/UploadProgress.js +12 -37
- package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
- package/dist/pages/message/components/messageBar/Icons.js +56 -74
- package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
- package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
- package/dist/pages/message/components/messageBar/OptionPanel.js +54 -107
- package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
- package/dist/pages/message/components/messageBar/index.js +2 -23
- package/dist/pages/message/message.routes.js +21 -40
- package/dist/pages/search/Search.js +38 -66
- package/dist/pages/search/SearchChatRecords.js +64 -92
- package/dist/pages/search/SearchFile.js +68 -96
- package/dist/pages/search/SearchManager.js +60 -65
- package/dist/pages/search/SearchPicturePage.js +16 -44
- package/dist/pages/search/components/ChatRecords.js +46 -74
- package/dist/pages/search/components/MyGroupChat.js +41 -69
- package/dist/pages/search/components/PictureMulipleBar.js +35 -63
- package/dist/pages/search/components/SearchFileList.js +59 -64
- package/dist/pages/search/components/SearchPictures.js +68 -98
- package/dist/pages/search/components/SearchShareLinkList.js +50 -55
- package/dist/pages/search/components/SearchUser.js +25 -53
- package/dist/pages/search/components/useSearchMessage.js +12 -16
- package/dist/pages/search/search.routes.js +11 -17
- package/dist/pages/search/utils.js +4 -12
- package/dist/pages/types.d.ts +4 -2
- package/dist/pages/types.js +1 -2
- package/dist/slice/contact/contact.slice.js +4 -8
- package/dist/slice/index.js +7 -13
- package/dist/slice/panel/panel.slice.d.ts +2 -1
- package/dist/slice/panel/panel.slice.js +8 -7
- package/dist/slice/video/video.action.d.ts +1 -0
- package/dist/slice/video/video.action.js +64 -38
- package/dist/slice/video/video.slice.d.ts +1 -1
- package/dist/slice/video/video.slice.js +7 -8
- package/dist/utils/audio.d.ts +3 -0
- package/dist/utils/audio.js +10 -0
- package/dist/utils/color.js +2 -9
- package/dist/utils/common-action-sheet.js +9 -14
- package/dist/utils/cookie.js +6 -14
- package/dist/utils/emoji.js +9 -12
- package/dist/utils/file-icon.js +33 -60
- package/dist/utils/file-operate.js +1 -2
- package/dist/utils/file.d.ts +10 -2
- package/dist/utils/file.js +188 -88
- package/dist/utils/golden-rectangle.js +3 -7
- package/dist/utils/phone.js +13 -22
- package/dist/utils/request.js +7 -15
- package/dist/utils/scroll.js +5 -9
- package/dist/utils/summary.js +4 -11
- package/dist/utils/take-camera.js +12 -19
- package/dist/utils/text-mix.js +4 -11
- package/dist/utils/upload.js +20 -41
- package/package.json +6 -7
- package/dist/slice/contact/contact.action.d.ts +0 -1
- package/dist/slice/contact/contact.action.js +0 -2
@@ -1,27 +1,3 @@
|
|
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
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -31,38 +7,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
8
|
});
|
33
9
|
};
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const elements_1 = require("@react-navigation/elements");
|
52
|
-
const useImSelector_1 = require("../../../hooks/useImSelector");
|
53
|
-
const file_1 = require("../../../utils/file");
|
54
|
-
const ReceiptBack_1 = require("../../../pages/message/components/ReceiptBack");
|
10
|
+
import React, { memo, useRef } from 'react';
|
11
|
+
import { Animated, Text, StyleSheet, TouchableOpacity, View, TouchableWithoutFeedback, Dimensions, StatusBar, Modal, } from 'react-native';
|
12
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
13
|
+
import { getMessageActionKeys, MessageActions, MessagePanelActions, MessageStatus, PayloadType, ConversationType, } from '@smart-link/im-base';
|
14
|
+
import AntDesign from 'react-native-vector-icons/AntDesign';
|
15
|
+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
16
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
17
|
+
import FontAwesome from 'react-native-vector-icons/FontAwesome';
|
18
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
19
|
+
import { dp, Toast, useNavigation, Modal as Dialog } from '@smart-link/rn-ui';
|
20
|
+
import useTranslation from '../../../hooks/useTranslation';
|
21
|
+
import { ConfirmActionSheet } from '../../../utils/common-action-sheet';
|
22
|
+
import { getImManager } from '../../../init';
|
23
|
+
import { useHeaderHeight } from '@react-navigation/elements';
|
24
|
+
import { usePanel } from '../../../hooks/useImSelector';
|
25
|
+
import { saveToAlbum } from '../../../utils/file';
|
26
|
+
import { ReceiptBack } from "../../../pages/message/components/ReceiptBack";
|
55
27
|
const getMessageAction = (t, message, navigation, setLoading) => {
|
56
28
|
if (!message)
|
57
29
|
return [];
|
58
|
-
const actions =
|
30
|
+
const actions = getMessageActionKeys(message.payloadType);
|
59
31
|
const items = [
|
60
32
|
{
|
61
33
|
key: 'copy',
|
62
34
|
title: t('copy'),
|
63
|
-
icon: <
|
35
|
+
icon: <AntDesign name="copy1" size={dp(20)} color={'#333'}/>,
|
64
36
|
onPress: () => {
|
65
|
-
|
37
|
+
Clipboard.setString(message.payload.text);
|
66
38
|
},
|
67
39
|
},
|
68
40
|
// {
|
@@ -76,28 +48,28 @@ const getMessageAction = (t, message, navigation, setLoading) => {
|
|
76
48
|
{
|
77
49
|
key: 'forward',
|
78
50
|
title: t('forward'),
|
79
|
-
icon: <
|
51
|
+
icon: <FontAwesome5 name="reply" size={dp(19)} color={'#333'}/>,
|
80
52
|
onPress: () => {
|
81
|
-
|
53
|
+
getImManager().store.dispatch(MessageActions.setForwardMessage(message));
|
82
54
|
navigation.navigate('ForwardToConversation');
|
83
55
|
},
|
84
56
|
},
|
85
57
|
{
|
86
58
|
key: 'delete',
|
87
59
|
title: t('delete'),
|
88
|
-
icon: <
|
60
|
+
icon: <MaterialCommunityIcons name="delete-forever" size={dp(23)} color={'#333'}/>,
|
89
61
|
onPress: () => {
|
90
|
-
|
91
|
-
yield
|
62
|
+
ConfirmActionSheet(t('confirmDeleteMessage'), () => __awaiter(void 0, void 0, void 0, function* () {
|
63
|
+
yield getImManager().deleteMessage(message);
|
92
64
|
}), t);
|
93
65
|
},
|
94
66
|
},
|
95
67
|
{
|
96
68
|
key: 'reply',
|
97
69
|
title: t('reply'),
|
98
|
-
icon: <
|
70
|
+
icon: <MaterialCommunityIcons name="message-processing" size={dp(20)} color={'#333'}/>,
|
99
71
|
onPress: () => {
|
100
|
-
const imManager =
|
72
|
+
const imManager = getImManager();
|
101
73
|
imManager.replyMessage(message);
|
102
74
|
setTimeout(() => {
|
103
75
|
var _a, _b;
|
@@ -116,17 +88,17 @@ const getMessageAction = (t, message, navigation, setLoading) => {
|
|
116
88
|
{
|
117
89
|
key: 'undo',
|
118
90
|
title: t('undo'),
|
119
|
-
icon: <
|
91
|
+
icon: <FontAwesome name="undo" size={dp(20)} color={'#333'}/>,
|
120
92
|
onPress: () => __awaiter(void 0, void 0, void 0, function* () {
|
121
|
-
|
93
|
+
ConfirmActionSheet(t('confirmUndoMessage'), () => __awaiter(void 0, void 0, void 0, function* () {
|
122
94
|
try {
|
123
95
|
setLoading(true);
|
124
|
-
yield
|
96
|
+
yield getImManager().undoMessage(message);
|
125
97
|
setLoading(false);
|
126
98
|
}
|
127
99
|
catch (e) {
|
128
100
|
setLoading(false);
|
129
|
-
|
101
|
+
Toast.error(t('undoFail'));
|
130
102
|
}
|
131
103
|
}), t);
|
132
104
|
}),
|
@@ -134,10 +106,10 @@ const getMessageAction = (t, message, navigation, setLoading) => {
|
|
134
106
|
{
|
135
107
|
key: 'feedback',
|
136
108
|
title: t('feedback'),
|
137
|
-
icon: <
|
109
|
+
icon: <MaterialIcons name="feedback" size={dp(20)} color={'#333'}/>,
|
138
110
|
onPress: () => __awaiter(void 0, void 0, void 0, function* () {
|
139
|
-
|
140
|
-
content: <
|
111
|
+
Dialog.open({
|
112
|
+
content: <ReceiptBack message={message}/>,
|
141
113
|
maskClosable: true,
|
142
114
|
footer: {
|
143
115
|
cancelButton: false,
|
@@ -149,34 +121,38 @@ const getMessageAction = (t, message, navigation, setLoading) => {
|
|
149
121
|
{
|
150
122
|
key: 'collect',
|
151
123
|
title: t('collect'),
|
152
|
-
icon: <
|
124
|
+
icon: <FontAwesome name="star" size={dp(20)} color={'#333'}/>,
|
153
125
|
onPress: () => {
|
154
|
-
|
126
|
+
getImManager().collectMessage(message);
|
155
127
|
},
|
156
128
|
},
|
157
129
|
{
|
158
130
|
key: 'saveToAlbum',
|
159
131
|
title: t('savePicture'),
|
160
|
-
icon: <
|
132
|
+
icon: <AntDesign name="save" size={dp(20)} color={'#333'}/>,
|
161
133
|
onPress: () => __awaiter(void 0, void 0, void 0, function* () {
|
162
|
-
yield
|
134
|
+
yield saveToAlbum(getImManager(), localPath);
|
163
135
|
}),
|
164
136
|
},
|
165
137
|
{
|
166
138
|
key: 'download',
|
167
139
|
title: t('download'),
|
168
|
-
icon: <
|
140
|
+
icon: <AntDesign name="download" size={dp(20)} color={'#333'}/>,
|
169
141
|
onPress: () => __awaiter(void 0, void 0, void 0, function* () {
|
170
|
-
const imManager =
|
171
|
-
imManager.store.dispatch(
|
142
|
+
const imManager = getImManager();
|
143
|
+
imManager.store.dispatch(MessagePanelActions.downloadFile(imManager, message, () => {
|
144
|
+
Toast.success(t('downloaded'));
|
145
|
+
}, () => {
|
146
|
+
Toast.error(t('downloadError'));
|
147
|
+
}));
|
172
148
|
}),
|
173
149
|
},
|
174
150
|
{
|
175
151
|
key: 'multiple',
|
176
152
|
title: t('multiple'),
|
177
|
-
icon: <
|
153
|
+
icon: <MaterialCommunityIcons name="playlist-check" size={dp(22)} color={'#333'}/>,
|
178
154
|
onPress: () => {
|
179
|
-
|
155
|
+
getImManager().store.dispatch(MessagePanelActions.startMultipleSelect(message));
|
180
156
|
},
|
181
157
|
},
|
182
158
|
];
|
@@ -186,72 +162,72 @@ const getMessageAction = (t, message, navigation, setLoading) => {
|
|
186
162
|
// avatars,
|
187
163
|
// text,
|
188
164
|
localPath, }, conversationId, conversationType, } = message;
|
189
|
-
const imManager =
|
165
|
+
const imManager = getImManager();
|
190
166
|
return items.filter(item => {
|
191
167
|
const { key } = item;
|
192
168
|
//if (isMyMessage && key === 'reply') return false;
|
193
|
-
if (messageStatus ===
|
169
|
+
if (messageStatus === MessageStatus.EMITTING) {
|
194
170
|
return false;
|
195
171
|
}
|
196
172
|
if ((!isMyMessage ||
|
197
|
-
messageStatus ===
|
173
|
+
messageStatus === MessageStatus.EMIT_ERROR ||
|
198
174
|
new Date().getTime() - messageTime > imManager.undoLimitTime) &&
|
199
175
|
key === 'undo')
|
200
176
|
return false;
|
201
|
-
if (payloadType ===
|
177
|
+
if (payloadType === PayloadType.FILE && localPath && key === 'download') {
|
202
178
|
return false;
|
203
179
|
}
|
204
|
-
if ((!isMyMessage || conversationType !==
|
180
|
+
if ((!isMyMessage || conversationType !== ConversationType.C2C) && key === 'feedback') {
|
205
181
|
return false;
|
206
182
|
}
|
207
183
|
return actions.includes(item.key);
|
208
184
|
});
|
209
185
|
};
|
210
186
|
const renderOperations = (items, close) => {
|
211
|
-
return (<
|
187
|
+
return (<View style={styles.operationWrap}>
|
212
188
|
{items.map((item, index) => {
|
213
|
-
return (<
|
189
|
+
return (<TouchableOpacity key={index} onPress={() => {
|
214
190
|
item.onPress && item.onPress();
|
215
191
|
close && close();
|
216
192
|
}}>
|
217
|
-
<
|
193
|
+
<View style={styles.operationItem}>
|
218
194
|
{item.icon}
|
219
|
-
<
|
220
|
-
</
|
221
|
-
</
|
195
|
+
<Text style={styles.operationText}>{item.title}</Text>
|
196
|
+
</View>
|
197
|
+
</TouchableOpacity>);
|
222
198
|
})}
|
223
|
-
</
|
199
|
+
</View>);
|
224
200
|
};
|
225
|
-
const MessageOption = ({ visible, message,
|
201
|
+
const MessageOption = ({ visible, message, nativeEventLayout, touchPoint, onClose, setLoading }) => {
|
226
202
|
var _a;
|
227
|
-
const { t } = (
|
228
|
-
const headerHeight =
|
229
|
-
const { messageBarHeight } =
|
230
|
-
const navigation =
|
203
|
+
const { t } = useTranslation();
|
204
|
+
const headerHeight = useHeaderHeight();
|
205
|
+
const { messageBarHeight } = usePanel();
|
206
|
+
const navigation = useNavigation();
|
231
207
|
const items = getMessageAction(t, message, navigation, setLoading);
|
232
|
-
const translateX =
|
233
|
-
const translateY =
|
234
|
-
const scale =
|
235
|
-
const opacity =
|
236
|
-
const { width: screenWidth, height: screenHeight } =
|
237
|
-
const padding =
|
208
|
+
const translateX = useRef(new Animated.Value(0)).current;
|
209
|
+
const translateY = useRef(new Animated.Value(0)).current;
|
210
|
+
const scale = useRef(new Animated.Value(0)).current;
|
211
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
212
|
+
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
213
|
+
const padding = dp(12);
|
238
214
|
// 视窗范围
|
239
215
|
const displayArea = {
|
240
216
|
x: padding,
|
241
217
|
y: padding,
|
242
218
|
width: screenWidth - padding * 2,
|
243
|
-
height: screenHeight - headerHeight - messageBarHeight - ((_a =
|
219
|
+
height: screenHeight - headerHeight - messageBarHeight - ((_a = StatusBar.currentHeight) !== null && _a !== void 0 ? _a : 0) - padding * 2,
|
244
220
|
};
|
245
221
|
const showAnimation = (x, y) => {
|
246
222
|
translateX.setValue(x);
|
247
223
|
translateY.setValue(y);
|
248
|
-
|
249
|
-
|
224
|
+
Animated.parallel([
|
225
|
+
Animated.timing(scale, {
|
250
226
|
toValue: 1,
|
251
227
|
duration: 150,
|
252
228
|
useNativeDriver: true,
|
253
229
|
}),
|
254
|
-
|
230
|
+
Animated.timing(opacity, {
|
255
231
|
toValue: 1,
|
256
232
|
duration: 150,
|
257
233
|
useNativeDriver: true,
|
@@ -259,13 +235,13 @@ const MessageOption = ({ visible, message, nativeEvent, onClose, setLoading }) =
|
|
259
235
|
]).start();
|
260
236
|
};
|
261
237
|
const hideAnimation = () => {
|
262
|
-
|
263
|
-
|
238
|
+
Animated.parallel([
|
239
|
+
Animated.timing(scale, {
|
264
240
|
toValue: 0,
|
265
241
|
duration: 150,
|
266
242
|
useNativeDriver: true,
|
267
243
|
}),
|
268
|
-
|
244
|
+
Animated.timing(opacity, {
|
269
245
|
toValue: 0,
|
270
246
|
duration: 150,
|
271
247
|
useNativeDriver: true,
|
@@ -282,20 +258,17 @@ const MessageOption = ({ visible, message, nativeEvent, onClose, setLoading }) =
|
|
282
258
|
const { width: contentWidth, height: contentHeight } = e.nativeEvent.layout;
|
283
259
|
// 计算操作项的显示位置
|
284
260
|
// 判断点击位置是否存在
|
285
|
-
if (
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
}
|
297
|
-
showAnimation(displayArea.x + displayArea.width - contentWidth, targetY);
|
298
|
-
});
|
261
|
+
if (nativeEventLayout && touchPoint) {
|
262
|
+
const { height } = nativeEventLayout;
|
263
|
+
const { x, y } = touchPoint;
|
264
|
+
let safePageY = !isNaN(y) ? y : displayArea.y;
|
265
|
+
let targetY = safePageY + height + contentHeight > displayArea.height
|
266
|
+
? safePageY - contentHeight
|
267
|
+
: safePageY + height;
|
268
|
+
let targetX = x + contentWidth > displayArea.width
|
269
|
+
? displayArea.width - contentWidth
|
270
|
+
: x;
|
271
|
+
showAnimation(targetX, targetY);
|
299
272
|
}
|
300
273
|
else {
|
301
274
|
showAnimation(displayArea.x + displayArea.width - contentWidth, displayArea.y + displayArea.height / 2 - contentHeight / 2);
|
@@ -306,11 +279,11 @@ const MessageOption = ({ visible, message, nativeEvent, onClose, setLoading }) =
|
|
306
279
|
};
|
307
280
|
if (!items.length)
|
308
281
|
return null;
|
309
|
-
return (<
|
310
|
-
<
|
311
|
-
<
|
312
|
-
</
|
313
|
-
<
|
282
|
+
return (<Modal visible={visible} transparent onRequestClose={onHide}>
|
283
|
+
<TouchableWithoutFeedback onPress={onHide}>
|
284
|
+
<View style={StyleSheet.absoluteFill}/>
|
285
|
+
</TouchableWithoutFeedback>
|
286
|
+
<Animated.View style={[
|
314
287
|
styles.popWrap,
|
315
288
|
{
|
316
289
|
transform: [
|
@@ -328,19 +301,19 @@ const MessageOption = ({ visible, message, nativeEvent, onClose, setLoading }) =
|
|
328
301
|
},
|
329
302
|
]} onLayout={onLayout}>
|
330
303
|
{renderOperations(items, onClose)}
|
331
|
-
</
|
332
|
-
</
|
304
|
+
</Animated.View>
|
305
|
+
</Modal>);
|
333
306
|
};
|
334
|
-
const styles =
|
307
|
+
const styles = StyleSheet.create({
|
335
308
|
popWrap: {
|
336
|
-
maxWidth:
|
337
|
-
borderRadius:
|
338
|
-
paddingTop:
|
309
|
+
maxWidth: dp(280),
|
310
|
+
borderRadius: dp(5),
|
311
|
+
paddingTop: dp(10),
|
339
312
|
backgroundColor: '#fff',
|
340
313
|
shadowOffset: { width: 1, height: 2 },
|
341
314
|
shadowColor: 'rgba(0, 0, 0, 0.1)',
|
342
315
|
shadowOpacity: 1,
|
343
|
-
shadowRadius:
|
316
|
+
shadowRadius: dp(5),
|
344
317
|
elevation: 10,
|
345
318
|
},
|
346
319
|
operationWrap: {
|
@@ -348,16 +321,16 @@ const styles = react_native_1.StyleSheet.create({
|
|
348
321
|
flexWrap: 'wrap',
|
349
322
|
},
|
350
323
|
operationItem: {
|
351
|
-
width:
|
352
|
-
height:
|
353
|
-
paddingHorizontal:
|
324
|
+
width: dp(272 / 4),
|
325
|
+
height: dp(40),
|
326
|
+
paddingHorizontal: dp(2),
|
354
327
|
justifyContent: 'space-between',
|
355
328
|
alignItems: 'center',
|
356
|
-
marginBottom:
|
329
|
+
marginBottom: dp(10),
|
357
330
|
},
|
358
331
|
operationText: {
|
359
|
-
fontSize:
|
360
|
-
lineHeight:
|
332
|
+
fontSize: dp(12),
|
333
|
+
lineHeight: dp(15),
|
361
334
|
},
|
362
335
|
});
|
363
|
-
|
336
|
+
export default memo(MessageOption);
|
@@ -3,13 +3,14 @@ import { IMessage } from '@smart-link/im-base';
|
|
3
3
|
import { StyleProp } from 'react-native';
|
4
4
|
import { ViewStyle } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
|
5
5
|
import { GestureResponderEvent } from 'react-native/Libraries/Types/CoreEventTypes';
|
6
|
+
import { NativeEventLayout } from "../../types";
|
6
7
|
export interface MessagePayloadProps extends IMessage {
|
7
8
|
style?: StyleProp<ViewStyle>;
|
8
9
|
direction?: 'left' | 'right';
|
9
10
|
showArrow?: boolean;
|
10
11
|
isRecord?: boolean;
|
11
12
|
onPress?: (e: GestureResponderEvent) => void;
|
12
|
-
onLongPress?: (e: GestureResponderEvent) => void;
|
13
|
+
onLongPress?: (e: GestureResponderEvent, layout: NativeEventLayout) => void;
|
13
14
|
onLoad?: (localPath: string) => void;
|
14
15
|
}
|
15
16
|
declare const _default: React.NamedExoticComponent<MessagePayloadProps>;
|
@@ -1,27 +1,3 @@
|
|
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
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
26
2
|
var t = {};
|
27
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
@@ -33,64 +9,60 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
33
9
|
}
|
34
10
|
return t;
|
35
11
|
};
|
36
|
-
|
37
|
-
|
38
|
-
};
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
51
|
-
const PayloadMultiple_1 = __importDefault(require("./Payload/PayloadMultiple"));
|
52
|
-
const PayloadWrapper_1 = __importDefault(require("./Payload/PayloadWrapper"));
|
53
|
-
const PayloadShare_1 = __importDefault(require("../../../pages/message/components/Payload/PayloadShare"));
|
12
|
+
import React, { memo } from 'react';
|
13
|
+
import { PayloadType } from '@smart-link/im-base';
|
14
|
+
import { Text } from 'react-native';
|
15
|
+
import PayloadContact from './Payload/PayloadContact';
|
16
|
+
import PayloadFile from './Payload/PayloadFile';
|
17
|
+
import PayloadPicture from './Payload/PayloadPicture';
|
18
|
+
import PayloadVoice from './Payload/PayloadVoice';
|
19
|
+
import PayloadVideo from './Payload/PayloadVideo';
|
20
|
+
import PayloadText from './Payload/PayloadText';
|
21
|
+
import { plain } from '../../../components/styles';
|
22
|
+
import useTranslation from '../../../hooks/useTranslation';
|
23
|
+
import PayloadMultiple from './Payload/PayloadMultiple';
|
24
|
+
import PayloadWrapper from './Payload/PayloadWrapper';
|
25
|
+
import PayloadShare from "../../../pages/message/components/Payload/PayloadShare";
|
54
26
|
const MessagePayload = props => {
|
55
27
|
const { style: outStyle } = props, retProps = __rest(props, ["style"]);
|
56
|
-
const { t } = (
|
28
|
+
const { t } = useTranslation();
|
57
29
|
const payloadType = props.payloadType;
|
58
|
-
const noStylePayloadType = [
|
30
|
+
const noStylePayloadType = [PayloadType.PICTURE, PayloadType.VIDEO];
|
59
31
|
const style = !noStylePayloadType.includes(payloadType) ? outStyle : [];
|
60
32
|
const mergeProps = Object.assign(Object.assign({}, retProps), { style });
|
61
33
|
let content;
|
62
34
|
switch (payloadType) {
|
63
|
-
case
|
64
|
-
content = <
|
35
|
+
case PayloadType.TEXT:
|
36
|
+
content = <PayloadText {...mergeProps}/>;
|
65
37
|
break;
|
66
|
-
case
|
67
|
-
content = <
|
38
|
+
case PayloadType.PICTURE:
|
39
|
+
content = <PayloadPicture {...mergeProps}/>;
|
68
40
|
break;
|
69
|
-
case
|
70
|
-
content = <
|
41
|
+
case PayloadType.VOICE:
|
42
|
+
content = <PayloadVoice {...mergeProps}/>;
|
71
43
|
break;
|
72
|
-
case
|
73
|
-
content = <
|
44
|
+
case PayloadType.VIDEO:
|
45
|
+
content = <PayloadVideo {...mergeProps}/>;
|
74
46
|
break;
|
75
|
-
case
|
76
|
-
content = <
|
47
|
+
case PayloadType.FILE:
|
48
|
+
content = <PayloadFile {...mergeProps}/>;
|
77
49
|
break;
|
78
|
-
case
|
79
|
-
content = <
|
50
|
+
case PayloadType.CONTACT:
|
51
|
+
content = <PayloadContact {...mergeProps}/>;
|
80
52
|
break;
|
81
|
-
case
|
82
|
-
content = <
|
53
|
+
case PayloadType.MULTIPLE:
|
54
|
+
content = <PayloadMultiple {...mergeProps}/>;
|
83
55
|
break;
|
84
|
-
case
|
85
|
-
content = <
|
56
|
+
case PayloadType.SHARE:
|
57
|
+
content = <PayloadShare {...mergeProps}/>;
|
86
58
|
break;
|
87
59
|
default:
|
88
60
|
console.log('暂不支持的消息类型:', payloadType);
|
89
|
-
content = (<
|
90
|
-
<
|
91
|
-
</
|
61
|
+
content = (<PayloadWrapper style={style} direction={mergeProps.direction}>
|
62
|
+
<Text style={plain}>[{t('msgTypeNotSupported')}]</Text>
|
63
|
+
</PayloadWrapper>);
|
92
64
|
break;
|
93
65
|
}
|
94
66
|
return content;
|
95
67
|
};
|
96
|
-
|
68
|
+
export default memo(MessagePayload);
|