@smart-link/rn-im 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +23 -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 +1 -0
- package/dist/default-assets.js +8 -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.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.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.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 +49 -54
- 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/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 +141 -135
- package/dist/pages/message/MessageRecord.js +49 -73
- package/dist/pages/message/components/BusiNotifyCard.js +60 -85
- package/dist/pages/message/components/ChatBg.js +11 -36
- package/dist/pages/message/components/MessageItem.js +82 -110
- package/dist/pages/message/components/MessageItemQuote.js +30 -58
- package/dist/pages/message/components/MessageItemTips.js +27 -55
- package/dist/pages/message/components/MessageOption.js +96 -120
- 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.js +41 -65
- package/dist/pages/message/components/Payload/PayloadMultiple.js +38 -66
- package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
- package/dist/pages/message/components/Payload/PayloadPicture.js +21 -49
- 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 +28 -56
- package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
- package/dist/pages/message/components/Payload/PayloadWrapper.js +18 -43
- package/dist/pages/message/components/Payload/type.js +1 -2
- package/dist/pages/message/components/ReceiptBack.js +31 -61
- package/dist/pages/message/components/TextMixMessage.js +13 -38
- package/dist/pages/message/components/TextMixQuote.js +129 -158
- package/dist/pages/message/components/TextMixQuoteMessage.js +16 -44
- 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 -82
- 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 +11 -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.js +1 -2
- package/dist/slice/contact/contact.action.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 +56 -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 +1 -1
- package/dist/utils/file.js +74 -87
- 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
@@ -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,59 +7,55 @@ 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
|
-
const ConversationCard_1 = __importDefault(require("./components/ConversationCard"));
|
48
|
-
const ConversationOption_1 = __importDefault(require("./components/ConversationOption"));
|
49
|
-
const MaterialIcons_1 = __importDefault(require("react-native-vector-icons/MaterialIcons"));
|
50
|
-
const contact_slice_1 = require("../../slice/contact/contact.slice");
|
10
|
+
import { ConnectStatus, ConversationActions } from '@smart-link/im-base';
|
11
|
+
import { CaihIcon, dp, Popover, SearchBar } from '@smart-link/rn-ui';
|
12
|
+
import React, { useEffect, useRef, useState } from 'react';
|
13
|
+
import { StyleSheet, View, FlatList, TouchableOpacity, Vibration, DevSettings, } from 'react-native';
|
14
|
+
import IndicatorText from '../../components/IndicatorText';
|
15
|
+
import NetworkUnconnected from '../../components/NetworkUnconnected';
|
16
|
+
import { useConversation } from '../../hooks/useImSelector';
|
17
|
+
import useTranslation from '../../hooks/useTranslation';
|
18
|
+
import { getImManager } from '../../init';
|
19
|
+
import ConversationCard from './components/ConversationCard';
|
20
|
+
import ConversationOption from './components/ConversationOption';
|
21
|
+
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
22
|
+
import { startCreateGroup } from '../../slice/contact/contact.slice';
|
51
23
|
const List = ({ navigation }) => {
|
52
|
-
const { t } = (
|
53
|
-
const { connectStatus, conversations, onlineMap } =
|
54
|
-
const [nativeEvent, setNativeEvent] =
|
55
|
-
const [popoverVisible, setPopoverVisible] =
|
56
|
-
const [conversation, setConversation] =
|
57
|
-
const lastPressTime =
|
58
|
-
const flatListRef =
|
59
|
-
|
24
|
+
const { t } = useTranslation();
|
25
|
+
const { connectStatus, conversations, onlineMap } = useConversation();
|
26
|
+
const [nativeEvent, setNativeEvent] = useState();
|
27
|
+
const [popoverVisible, setPopoverVisible] = useState(false);
|
28
|
+
const [conversation, setConversation] = useState();
|
29
|
+
const lastPressTime = useRef(0);
|
30
|
+
const flatListRef = useRef(null);
|
31
|
+
useEffect(() => {
|
60
32
|
let headerTitle = t('message');
|
61
33
|
switch (connectStatus) {
|
62
|
-
case
|
63
|
-
headerTitle = () => <
|
34
|
+
case ConnectStatus.CONNECTING:
|
35
|
+
headerTitle = () => <IndicatorText text={t('connecting') + '...'}/>;
|
64
36
|
break;
|
65
|
-
case
|
37
|
+
case ConnectStatus.CONNECT_PARAM_ERROR:
|
66
38
|
headerTitle = t('connectFail');
|
67
39
|
break;
|
68
|
-
case
|
40
|
+
case ConnectStatus.CONNECT_ERROR:
|
69
41
|
headerTitle = t('serverConnectionFailed');
|
70
42
|
break;
|
71
|
-
case
|
43
|
+
case ConnectStatus.CONNECT_TIMEOUT:
|
72
44
|
headerTitle = t('serverConnectionTimeout');
|
73
45
|
break;
|
74
|
-
case
|
75
|
-
headerTitle = () => <
|
46
|
+
case ConnectStatus.SYNC_SUBSCRIBE_LIST:
|
47
|
+
headerTitle = () => <IndicatorText text={t('receipting') + '...'}/>;
|
76
48
|
break;
|
77
|
-
case
|
49
|
+
case ConnectStatus.UN_CONNECT:
|
78
50
|
headerTitle = t('message') + '(' + t('unConnect') + ')';
|
79
51
|
break;
|
80
52
|
}
|
81
53
|
const options = [
|
82
54
|
{
|
83
|
-
icon: <
|
55
|
+
icon: <MaterialIcon name="person-add"/>,
|
84
56
|
content: t('createGroupChat'),
|
85
57
|
onPress: () => {
|
86
|
-
|
58
|
+
getImManager().store.dispatch(startCreateGroup());
|
87
59
|
navigation.navigate('ChooseContact', {
|
88
60
|
chooseOrg: true,
|
89
61
|
checkMode: 'multi',
|
@@ -91,7 +63,7 @@ const List = ({ navigation }) => {
|
|
91
63
|
},
|
92
64
|
},
|
93
65
|
{
|
94
|
-
icon: <
|
66
|
+
icon: <MaterialIcon name="qr-code-scanner"/>,
|
95
67
|
content: t('scan'),
|
96
68
|
onPress: () => {
|
97
69
|
navigation.navigate('ScanCode');
|
@@ -100,24 +72,24 @@ const List = ({ navigation }) => {
|
|
100
72
|
];
|
101
73
|
if (__DEV__) {
|
102
74
|
options.push({
|
103
|
-
icon: <
|
75
|
+
icon: <MaterialIcon name="settings"/>,
|
104
76
|
content: '清空数据并重启',
|
105
77
|
onPress: () => {
|
106
|
-
|
107
|
-
|
78
|
+
getImManager().db.clean();
|
79
|
+
DevSettings.reload();
|
108
80
|
},
|
109
81
|
});
|
110
82
|
}
|
111
83
|
navigation.setOptions({
|
112
84
|
headerTitle,
|
113
|
-
headerRight: () => (<
|
114
|
-
<
|
115
|
-
<
|
116
|
-
</
|
117
|
-
</
|
85
|
+
headerRight: () => (<Popover type="dark" placement="bottom" layout="vertical" duration={100} options={options} contentStyle={{ borderRadius: dp(6) }}>
|
86
|
+
<TouchableOpacity style={{ marginHorizontal: dp(10), padding: dp(9) }}>
|
87
|
+
<CaihIcon name="picker-add" size={dp(19)} color={'#f6f6f6'}/>
|
88
|
+
</TouchableOpacity>
|
89
|
+
</Popover>),
|
118
90
|
});
|
119
91
|
}, [t, navigation, connectStatus]);
|
120
|
-
|
92
|
+
useEffect(() => {
|
121
93
|
return navigation.addListener('tabPress', (e) => {
|
122
94
|
const now = Date.now();
|
123
95
|
if (now - lastPressTime.current < 300) {
|
@@ -143,8 +115,8 @@ const List = ({ navigation }) => {
|
|
143
115
|
setPopoverVisible(false);
|
144
116
|
try {
|
145
117
|
// 设置更新已读数量
|
146
|
-
const imManager =
|
147
|
-
yield imManager.store.dispatch(
|
118
|
+
const imManager = getImManager();
|
119
|
+
yield imManager.store.dispatch(ConversationActions.initConversation(imManager, conversation));
|
148
120
|
navigation.navigate('MessageList');
|
149
121
|
}
|
150
122
|
catch (e) {
|
@@ -152,27 +124,27 @@ const List = ({ navigation }) => {
|
|
152
124
|
}
|
153
125
|
});
|
154
126
|
const onLongPressCard = (conversation, nativeEvent) => {
|
155
|
-
|
127
|
+
Vibration.vibrate(10);
|
156
128
|
setPopoverVisible(true);
|
157
129
|
setNativeEvent(nativeEvent);
|
158
130
|
setConversation(conversation);
|
159
131
|
};
|
160
132
|
const listHeaderComponent = () => (<>
|
161
|
-
<
|
162
|
-
<
|
163
|
-
{connectStatus ===
|
164
|
-
<
|
165
|
-
<
|
133
|
+
<SearchBar onSearch={handleSearch} style={styles.searchBar}/>
|
134
|
+
<View style={styles.line}/>
|
135
|
+
{connectStatus === ConnectStatus.CONNECT_ERROR && (<>
|
136
|
+
<NetworkUnconnected />
|
137
|
+
<View style={styles.line}/>
|
166
138
|
</>)}
|
167
139
|
{/*{TenantConfig.config.showOrgChat && <OrgGroupBar onPressOrgGroupBar={onPressOrgGroupBar} />}*/}
|
168
|
-
<
|
140
|
+
<View style={styles.line}/>
|
169
141
|
</>);
|
170
|
-
const listFooterComponent = () => <
|
142
|
+
const listFooterComponent = () => <View style={styles.line}/>;
|
171
143
|
const keyExtractor = (item) => item.id;
|
172
144
|
const renderItem = ({ item }) => {
|
173
145
|
return (
|
174
146
|
// @ts-ignore
|
175
|
-
<
|
147
|
+
<ConversationCard selected={item.id === (conversation === null || conversation === void 0 ? void 0 : conversation.id)} conversation={item} onPressCard={onPressCard} onLongPressCard={onLongPressCard} status={onlineMap[item.id]}/>);
|
176
148
|
};
|
177
149
|
const itemSeparatorComponent = ({ leadingItem }) => {
|
178
150
|
for (let i = 0; i < conversations.length; i++) {
|
@@ -180,41 +152,41 @@ const List = ({ navigation }) => {
|
|
180
152
|
break;
|
181
153
|
}
|
182
154
|
if (leadingItem.id === conversations[i].id && conversations[i].enableTop === 'on') {
|
183
|
-
return (<
|
184
|
-
<
|
185
|
-
</
|
155
|
+
return (<View style={styles.separatorBg}>
|
156
|
+
<View style={styles.separator}/>
|
157
|
+
</View>);
|
186
158
|
}
|
187
159
|
}
|
188
|
-
return <
|
160
|
+
return <View style={styles.separator}/>;
|
189
161
|
};
|
190
162
|
const getItemLayout = (_, index) => ({
|
191
|
-
length:
|
192
|
-
offset:
|
163
|
+
length: dp(81),
|
164
|
+
offset: dp(81) * index + dp(57),
|
193
165
|
index,
|
194
166
|
});
|
195
|
-
return (<
|
196
|
-
<
|
197
|
-
<
|
167
|
+
return (<View style={{ flex: 1 }}>
|
168
|
+
<FlatList ref={flatListRef} contentContainerStyle={styles.contentContainerStyle} keyboardShouldPersistTaps={'handled'} data={conversations} ListHeaderComponent={listHeaderComponent} ListFooterComponent={listFooterComponent} ItemSeparatorComponent={itemSeparatorComponent} getItemLayout={getItemLayout} renderItem={renderItem} numColumns={1} keyExtractor={keyExtractor}/>
|
169
|
+
<ConversationOption conversation={conversation} nativeEvent={nativeEvent} visible={popoverVisible} onClose={() => {
|
198
170
|
setPopoverVisible(false);
|
199
171
|
setConversation(undefined);
|
200
172
|
}}/>
|
201
|
-
</
|
173
|
+
</View>);
|
202
174
|
};
|
203
|
-
const styles =
|
175
|
+
const styles = StyleSheet.create({
|
204
176
|
contentContainerStyle: {
|
205
177
|
backgroundColor: '#fff',
|
206
178
|
},
|
207
179
|
searchBar: {
|
208
|
-
marginHorizontal:
|
209
|
-
marginVertical:
|
180
|
+
marginHorizontal: dp(10),
|
181
|
+
marginVertical: dp(10),
|
210
182
|
},
|
211
183
|
line: {
|
212
|
-
height:
|
184
|
+
height: dp(1),
|
213
185
|
backgroundColor: '#ececec',
|
214
186
|
},
|
215
187
|
separator: {
|
216
|
-
marginLeft:
|
217
|
-
height:
|
188
|
+
marginLeft: dp(80),
|
189
|
+
height: dp(1),
|
218
190
|
backgroundColor: '#ececec',
|
219
191
|
},
|
220
192
|
separatorBg: {
|
@@ -222,15 +194,15 @@ const styles = react_native_1.StyleSheet.create({
|
|
222
194
|
},
|
223
195
|
backButton: {
|
224
196
|
backgroundColor: '#ddd',
|
225
|
-
height:
|
226
|
-
width:
|
227
|
-
borderRadius:
|
197
|
+
height: dp(50),
|
198
|
+
width: dp(50),
|
199
|
+
borderRadius: dp(25),
|
228
200
|
opacity: 0.5,
|
229
201
|
justifyContent: 'center',
|
230
202
|
alignItems: 'center',
|
231
203
|
position: 'absolute',
|
232
|
-
bottom:
|
233
|
-
right:
|
204
|
+
bottom: dp(15),
|
205
|
+
right: dp(15),
|
234
206
|
},
|
235
207
|
});
|
236
|
-
|
208
|
+
export default List;
|
@@ -1,93 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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 im_base_1 = require("@smart-link/im-base");
|
30
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
31
|
-
const react_1 = __importStar(require("react"));
|
32
|
-
const react_native_1 = require("react-native");
|
33
|
-
const FontAwesome5_1 = __importDefault(require("react-native-vector-icons/FontAwesome5"));
|
34
|
-
const MaterialIcons_1 = __importDefault(require("react-native-vector-icons/MaterialIcons"));
|
35
|
-
const ChatAvatar_1 = __importDefault(require("../../../components/ChatAvatar/ChatAvatar"));
|
36
|
-
const useFormatMsgTime_1 = __importDefault(require("../../../hooks/useFormatMsgTime"));
|
37
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
38
|
-
const ConversationCard = (0, react_1.memo)(props => {
|
1
|
+
import { getConversationContent } from '@smart-link/im-base';
|
2
|
+
import { Badge, dp } from '@smart-link/rn-ui';
|
3
|
+
import React, { memo } from 'react';
|
4
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
5
|
+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
6
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
7
|
+
import ChatAvatar from '../../../components/ChatAvatar/ChatAvatar';
|
8
|
+
import useFormatMsgTime from '../../../hooks/useFormatMsgTime';
|
9
|
+
import useTranslation from '../../../hooks/useTranslation';
|
10
|
+
const ConversationCard = memo(props => {
|
39
11
|
const { status, selected, conversation, onPressCard, onLongPressCard } = props;
|
40
|
-
const { t } = (
|
12
|
+
const { t } = useTranslation();
|
41
13
|
const { id, type, avatars, name, text, draftText, errorText, enableNoDisturb, enableTop, tipsList, time, unreadCount } = conversation;
|
42
14
|
const enableTopStyles = enableTop === 'on' ? styles.enableTop : null;
|
43
15
|
const showPoint = enableNoDisturb === 'on' && unreadCount > 0;
|
44
16
|
const countText = showPoint && unreadCount > 0 ? t('unreadCount', { unreadCount }) : '';
|
45
|
-
const content =
|
17
|
+
const content = getConversationContent(text, errorText, draftText, tipsList, countText, t);
|
46
18
|
const contentStyles = content.tips ? styles.contentRedStyles : null;
|
47
|
-
const formatTime = (
|
19
|
+
const formatTime = useFormatMsgTime(time, true);
|
48
20
|
// const imManager = getImManager();
|
49
21
|
// // 还没找到为啥会让空的头像的人变成登录人的头像,先解决表面问题
|
50
22
|
// let newAvatars = avatars;
|
51
23
|
// if (avatars === imManager.user.avatars && name !== imManager.user.userName) {
|
52
24
|
// newAvatars = "";
|
53
25
|
// }
|
54
|
-
return (<
|
26
|
+
return (<TouchableOpacity activeOpacity={0.5} style={[styles.card, enableTopStyles, selected && styles.selected]} onPress={() => {
|
55
27
|
onPressCard && onPressCard(conversation);
|
56
28
|
}} onLongPress={({ nativeEvent }) => {
|
57
29
|
onLongPressCard && onLongPressCard(conversation, nativeEvent);
|
58
30
|
}}>
|
59
|
-
<
|
60
|
-
<
|
61
|
-
<
|
62
|
-
</
|
63
|
-
{status === 'online' && <
|
64
|
-
<
|
65
|
-
</
|
66
|
-
</
|
31
|
+
<View style={{ height: dp(50), width: dp(50), marginRight: dp(16) }}>
|
32
|
+
<Badge text={unreadCount} dot={showPoint}>
|
33
|
+
<ChatAvatar disabled type={type} id={id} size={dp(48)} name={name}/>
|
34
|
+
</Badge>
|
35
|
+
{status === 'online' && <View style={styles.status}>
|
36
|
+
<MaterialIcons size={dp(14)} color={status === 'online' ? '#4caf50' : '#616161'} name={status === 'online' ? 'check-circle' : 'not-interested'}/>
|
37
|
+
</View>}
|
38
|
+
</View>
|
67
39
|
|
68
|
-
<
|
69
|
-
<
|
70
|
-
<
|
40
|
+
<View style={{ flexDirection: 'column', flex: 1 }}>
|
41
|
+
<View style={styles.swipe}>
|
42
|
+
<Text style={styles.name} numberOfLines={1}>
|
71
43
|
{name}
|
72
|
-
</
|
73
|
-
<
|
74
|
-
</
|
44
|
+
</Text>
|
45
|
+
<Text style={styles.time}>{formatTime}</Text>
|
46
|
+
</View>
|
75
47
|
|
76
|
-
<
|
77
|
-
<
|
78
|
-
<
|
48
|
+
<View style={styles.row}>
|
49
|
+
<Text style={styles.message} numberOfLines={1}>
|
50
|
+
<Text style={contentStyles}>{content.tips}</Text>
|
79
51
|
{content.text}
|
80
|
-
</
|
81
|
-
{enableNoDisturb === 'on' && (<
|
82
|
-
{enableTop === 'on' && (<
|
83
|
-
</
|
84
|
-
</
|
85
|
-
</
|
52
|
+
</Text>
|
53
|
+
{enableNoDisturb === 'on' && (<FontAwesome5 name={'bell-slash'} size={dp(12)} color={'#999'} style={styles.enableNoDisturb}/>)}
|
54
|
+
{enableTop === 'on' && (<MaterialIcons name={'push-pin'} size={dp(15)} color={'#999'} style={styles.enableNoDisturb}/>)}
|
55
|
+
</View>
|
56
|
+
</View>
|
57
|
+
</TouchableOpacity>);
|
86
58
|
});
|
87
|
-
const styles =
|
59
|
+
const styles = StyleSheet.create({
|
88
60
|
card: {
|
89
|
-
height:
|
90
|
-
padding:
|
61
|
+
height: dp(80),
|
62
|
+
padding: dp(16),
|
91
63
|
display: 'flex',
|
92
64
|
flexDirection: 'row',
|
93
65
|
},
|
@@ -103,17 +75,17 @@ const styles = react_native_1.StyleSheet.create({
|
|
103
75
|
alignItems: 'center',
|
104
76
|
},
|
105
77
|
name: {
|
106
|
-
fontSize:
|
78
|
+
fontSize: dp(15),
|
107
79
|
fontWeight: '500',
|
108
80
|
color: '#333333',
|
109
81
|
flex: 1,
|
110
82
|
},
|
111
83
|
time: {
|
112
|
-
fontSize:
|
84
|
+
fontSize: dp(12),
|
113
85
|
color: '#999999',
|
114
86
|
},
|
115
87
|
message: {
|
116
|
-
fontSize:
|
88
|
+
fontSize: dp(13),
|
117
89
|
color: '#999999',
|
118
90
|
flex: 1,
|
119
91
|
},
|
@@ -131,7 +103,7 @@ const styles = react_native_1.StyleSheet.create({
|
|
131
103
|
},
|
132
104
|
swipeDel: {
|
133
105
|
justifyContent: 'center',
|
134
|
-
width:
|
106
|
+
width: dp(75),
|
135
107
|
backgroundColor: '#ff4949',
|
136
108
|
},
|
137
109
|
swipeDelText: {
|
@@ -142,7 +114,7 @@ const styles = react_native_1.StyleSheet.create({
|
|
142
114
|
right: 2,
|
143
115
|
bottom: 2,
|
144
116
|
backgroundColor: '#fff',
|
145
|
-
borderRadius:
|
117
|
+
borderRadius: dp(10),
|
146
118
|
}
|
147
119
|
});
|
148
|
-
|
120
|
+
export default ConversationCard;
|
@@ -1,99 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
const react_1 = __importStar(require("react"));
|
30
|
-
const react_native_1 = require("react-native");
|
31
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
32
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
33
|
-
const init_1 = require("../../../init");
|
34
|
-
const PopoverWrapper_1 = __importDefault(require("../../../components/PopoverWrapper"));
|
35
|
-
const renderMenuItem = (title, onPress) => <react_native_1.TouchableOpacity activeOpacity={0.5} onPress={onPress}>
|
36
|
-
<react_native_1.Text style={styles.text}>{title}</react_native_1.Text>
|
37
|
-
</react_native_1.TouchableOpacity>;
|
1
|
+
import React, { memo } from 'react';
|
2
|
+
import { Text, StyleSheet, TouchableOpacity, } from 'react-native';
|
3
|
+
import { dp, Line } from '@smart-link/rn-ui';
|
4
|
+
import useTranslation from '../../../hooks/useTranslation';
|
5
|
+
import { getImManager } from '../../../init';
|
6
|
+
import PopoverWrapper from '../../../components/PopoverWrapper';
|
7
|
+
const renderMenuItem = (title, onPress) => <TouchableOpacity activeOpacity={0.5} onPress={onPress}>
|
8
|
+
<Text style={styles.text}>{title}</Text>
|
9
|
+
</TouchableOpacity>;
|
38
10
|
const ConversationOption = ({ conversation, nativeEvent, onClose, visible, }) => {
|
39
|
-
const { t } = (
|
11
|
+
const { t } = useTranslation();
|
40
12
|
let read, disturb, top;
|
41
13
|
if (conversation === null || conversation === void 0 ? void 0 : conversation.unreadCount) {
|
42
14
|
read = renderMenuItem(t('markRead'), () => {
|
43
|
-
|
15
|
+
getImManager().markRead(conversation);
|
44
16
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
45
17
|
});
|
46
18
|
}
|
47
19
|
else {
|
48
20
|
read = renderMenuItem(t('markUnread'), () => {
|
49
|
-
|
21
|
+
getImManager().markUnread(conversation);
|
50
22
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
51
23
|
});
|
52
24
|
}
|
53
25
|
if ((conversation === null || conversation === void 0 ? void 0 : conversation.enableNoDisturb) === 'off') {
|
54
26
|
disturb = renderMenuItem(t('chatNoDisturbOn'), () => {
|
55
|
-
|
27
|
+
getImManager().noDisturbOn(conversation);
|
56
28
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
57
29
|
});
|
58
30
|
}
|
59
31
|
else {
|
60
32
|
disturb = renderMenuItem(t('chatNoDisturbOff'), () => {
|
61
|
-
|
33
|
+
getImManager().noDisturbOff(conversation);
|
62
34
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
63
35
|
});
|
64
36
|
}
|
65
37
|
if ((conversation === null || conversation === void 0 ? void 0 : conversation.enableTop) === 'off') {
|
66
38
|
top = renderMenuItem(t('chatTopOn'), () => {
|
67
|
-
|
39
|
+
getImManager().topOn(conversation);
|
68
40
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
69
41
|
});
|
70
42
|
}
|
71
43
|
else {
|
72
44
|
top = renderMenuItem(t('chatTopOff'), () => {
|
73
|
-
|
45
|
+
getImManager().topOff(conversation);
|
74
46
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
75
47
|
});
|
76
48
|
}
|
77
49
|
const del = renderMenuItem(t('deleteChat'), () => {
|
78
|
-
|
50
|
+
getImManager().deleteConversation(conversation);
|
79
51
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
80
52
|
});
|
81
|
-
return (<
|
53
|
+
return (<PopoverWrapper showArrow={false} measureTarget={false} visible={visible} onClose={onClose} nativeEvent={nativeEvent}>
|
82
54
|
{read}
|
83
|
-
<
|
55
|
+
<Line />
|
84
56
|
{disturb}
|
85
|
-
<
|
57
|
+
<Line />
|
86
58
|
{top}
|
87
|
-
<
|
59
|
+
<Line />
|
88
60
|
{del}
|
89
|
-
</
|
61
|
+
</PopoverWrapper>);
|
90
62
|
};
|
91
|
-
|
92
|
-
const styles =
|
63
|
+
export default memo(ConversationOption);
|
64
|
+
const styles = StyleSheet.create({
|
93
65
|
text: {
|
94
66
|
color: '#555',
|
95
|
-
fontSize:
|
96
|
-
paddingHorizontal:
|
97
|
-
paddingVertical:
|
67
|
+
fontSize: dp(15),
|
68
|
+
paddingHorizontal: dp(12),
|
69
|
+
paddingVertical: dp(12),
|
98
70
|
},
|
99
71
|
});
|