@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
@@ -0,0 +1,235 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
// @flow
|
11
|
+
import * as React from 'react';
|
12
|
+
import { dp, NavigationPage, SearchInput } from "@smart-link/rn-ui";
|
13
|
+
import { View, StyleSheet, TouchableOpacity, ScrollView, Text, FlatList } from "react-native";
|
14
|
+
import { Fragment, useCallback, useEffect, useState } from "react";
|
15
|
+
import { getFileRootItem, getFileType, isImage, numberToFileSize, readFileDir, selectFile } from "../../utils/file";
|
16
|
+
import { getImManager } from "../../init";
|
17
|
+
import AntDesign from "react-native-vector-icons/AntDesign";
|
18
|
+
import useTranslation from "../../hooks/useTranslation";
|
19
|
+
import { findSvgIcon } from "../../utils/file-icon";
|
20
|
+
import FastImage from "react-native-fast-image";
|
21
|
+
import { dirImg } from "../../default-assets";
|
22
|
+
import { formatTime } from "../../hooks/useFormatMsgTime";
|
23
|
+
import { useConversation } from "../../hooks/useImSelector";
|
24
|
+
const getIcon = (item) => {
|
25
|
+
if (item.isDir) {
|
26
|
+
return <FastImage style={styles.fileImage} source={dirImg}/>;
|
27
|
+
}
|
28
|
+
if (isImage(item.path)) {
|
29
|
+
return <FastImage style={styles.fileImage} source={{ uri: 'file://' + item.path }}/>;
|
30
|
+
}
|
31
|
+
if (item.thumbPath) {
|
32
|
+
return <FastImage style={styles.fileImage} source={{ uri: 'file://' + item.thumbPath }}/>;
|
33
|
+
}
|
34
|
+
const Icon = findSvgIcon(getFileType(item.path));
|
35
|
+
return <Icon style={styles.fileImage}/>;
|
36
|
+
};
|
37
|
+
const FileSelector = ({ navigation }) => {
|
38
|
+
const scrollHolder = {};
|
39
|
+
const [data, setData] = useState([]);
|
40
|
+
const [keyword, setKeyword] = useState('');
|
41
|
+
const [pathItems, setPathItems] = useState([]);
|
42
|
+
const imManager = getImManager();
|
43
|
+
const { t, i18n } = useTranslation();
|
44
|
+
const { currentConversation } = useConversation();
|
45
|
+
useEffect(() => {
|
46
|
+
navigation.setOptions({
|
47
|
+
headerLeft({ tintColor }) {
|
48
|
+
return (<TouchableOpacity activeOpacity={0.5} style={{ padding: dp(10) }} onPress={() => {
|
49
|
+
navigation.goBack();
|
50
|
+
}}>
|
51
|
+
<Text style={{ color: tintColor }}>{t('cancel')}</Text>
|
52
|
+
</TouchableOpacity>);
|
53
|
+
},
|
54
|
+
title: t('file')
|
55
|
+
});
|
56
|
+
getFileRootItem(imManager).then(items => {
|
57
|
+
setData(items);
|
58
|
+
});
|
59
|
+
}, [navigation, t]);
|
60
|
+
const onPressItem = (item) => __awaiter(void 0, void 0, void 0, function* () {
|
61
|
+
if (!item.isDir) {
|
62
|
+
const localPath = yield selectFile(imManager, item.path, item.name);
|
63
|
+
const file = {
|
64
|
+
filename: item.name,
|
65
|
+
localPath: localPath,
|
66
|
+
size: item.size,
|
67
|
+
type: getFileType(item.path),
|
68
|
+
lastModified: item.time,
|
69
|
+
};
|
70
|
+
navigation.goBack();
|
71
|
+
if (isImage(file.localPath)) {
|
72
|
+
imManager.sendPictureMessage(currentConversation, file);
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
imManager.sendFileMessage(currentConversation, file);
|
76
|
+
}
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
setPathItems([...pathItems.filter(pathItem => pathItem.path !== item.path), item]);
|
80
|
+
scrollHolder.scroll.scrollToEnd();
|
81
|
+
readFileDir(imManager, item.path, keyword).then(items => {
|
82
|
+
setData(items);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
const onChangeText = useCallback((keyword) => {
|
86
|
+
setKeyword(keyword);
|
87
|
+
if (pathItems.length === 0) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
readFileDir(imManager, pathItems[pathItems.length - 1].path, keyword).then(items => {
|
91
|
+
setData(items);
|
92
|
+
});
|
93
|
+
}, [pathItems]);
|
94
|
+
const onPressPathRoot = useCallback(() => {
|
95
|
+
setPathItems([]);
|
96
|
+
getFileRootItem(imManager).then(items => {
|
97
|
+
setData(items);
|
98
|
+
});
|
99
|
+
}, []);
|
100
|
+
const onPressPathItem = useCallback((item) => {
|
101
|
+
setPathItems([
|
102
|
+
...pathItems.filter(source => source.path.indexOf(item.path) === -1),
|
103
|
+
item
|
104
|
+
]);
|
105
|
+
readFileDir(imManager, item.path, keyword).then(items => {
|
106
|
+
setData(items);
|
107
|
+
});
|
108
|
+
}, [pathItems, keyword]);
|
109
|
+
const listHeaderComponent = data.length === 0 ? null : <View style={styles.listHeaderLine}/>;
|
110
|
+
const listFooterComponent = data.length === 0 ? null : <View style={styles.listFooterLine}/>;
|
111
|
+
const itemSeparatorComponent = () => <View style={styles.separator}/>;
|
112
|
+
const keyExtractor = (item) => item.name + '_' + item.size;
|
113
|
+
const renderItem = ({ item }) => {
|
114
|
+
const icon = getIcon(item);
|
115
|
+
const extText = item.isDir ? (item.childrenCount + t('items')) : numberToFileSize(item.size);
|
116
|
+
return (<TouchableOpacity style={styles.item} onPress={() => {
|
117
|
+
onPressItem && onPressItem(item);
|
118
|
+
}}>
|
119
|
+
|
120
|
+
{icon}
|
121
|
+
<View style={styles.width15}/>
|
122
|
+
<View style={styles.left}>
|
123
|
+
<Text style={styles.name} numberOfLines={1} ellipsizeMode={'middle'}>
|
124
|
+
{item.name}
|
125
|
+
</Text>
|
126
|
+
<Text style={styles.time} numberOfLines={1} ellipsizeMode={'middle'}>
|
127
|
+
{(item.time ? (formatTime(item.time, t, i18n) + ' - ') : '') + extText}
|
128
|
+
</Text>
|
129
|
+
</View>
|
130
|
+
{item.isDir &&
|
131
|
+
<AntDesign name='right' size={dp(14)} color={'#666'} style={styles.accessory}/>}
|
132
|
+
|
133
|
+
</TouchableOpacity>);
|
134
|
+
};
|
135
|
+
return (<NavigationPage noPadding>
|
136
|
+
<View style={styles.selector}>
|
137
|
+
<View style={styles.search}>
|
138
|
+
<SearchInput style={{
|
139
|
+
height: dp(32),
|
140
|
+
backgroundColor: '#ececec',
|
141
|
+
}} value={keyword} onChange={onChangeText} onSubmitEditing={() => { }}/>
|
142
|
+
</View>
|
143
|
+
<View style={styles.scroll}>
|
144
|
+
<TouchableOpacity onPress={onPressPathRoot} style={styles.scrollVertical}>
|
145
|
+
<Text style={styles.pathText}>{t('position')}</Text>
|
146
|
+
</TouchableOpacity>
|
147
|
+
<AntDesign name='right' size={dp(16)} color={'#333'} style={styles.scrollVertical}/>
|
148
|
+
<ScrollView style={styles.scrollVertical} horizontal={true} ref={v => scrollHolder.scroll = v}>
|
149
|
+
|
150
|
+
{pathItems.map((pathItem, index) => {
|
151
|
+
const disabled = index === pathItems.length - 1;
|
152
|
+
return (<Fragment key={index}>
|
153
|
+
<TouchableOpacity disabled={disabled} onPress={() => {
|
154
|
+
onPressPathItem && onPressPathItem(pathItem);
|
155
|
+
}}>
|
156
|
+
<Text style={styles.pathText}>{pathItem.name}</Text>
|
157
|
+
</TouchableOpacity>
|
158
|
+
<AntDesign name='right' size={dp(16)} color={'#333'}/>
|
159
|
+
</Fragment>);
|
160
|
+
})}
|
161
|
+
</ScrollView>
|
162
|
+
</View>
|
163
|
+
<FlatList contentContainerStyle={styles.list} ItemSeparatorComponent={itemSeparatorComponent} ListHeaderComponent={listHeaderComponent} ListFooterComponent={listFooterComponent} initialNumToRender={20} numColumns={1} data={data} keyboardShouldPersistTaps={'handled'} keyExtractor={keyExtractor} renderItem={renderItem}/>
|
164
|
+
</View>
|
165
|
+
</NavigationPage>);
|
166
|
+
};
|
167
|
+
const styles = StyleSheet.create({
|
168
|
+
selector: {
|
169
|
+
flex: 1,
|
170
|
+
backgroundColor: '#fff',
|
171
|
+
},
|
172
|
+
scroll: {
|
173
|
+
flexDirection: 'row',
|
174
|
+
paddingHorizontal: dp(8),
|
175
|
+
},
|
176
|
+
scrollVertical: {
|
177
|
+
paddingBottom: dp(10),
|
178
|
+
},
|
179
|
+
pathText: {
|
180
|
+
paddingHorizontal: dp(5),
|
181
|
+
fontSize: dp(14),
|
182
|
+
lineHeight: dp(16),
|
183
|
+
color: '#666',
|
184
|
+
},
|
185
|
+
search: {
|
186
|
+
backgroundColor: '#fff',
|
187
|
+
padding: dp(10),
|
188
|
+
},
|
189
|
+
list: {
|
190
|
+
paddingHorizontal: dp(15),
|
191
|
+
},
|
192
|
+
listFooterLine: {},
|
193
|
+
listHeaderLine: {},
|
194
|
+
separator: {
|
195
|
+
marginLeft: dp(65),
|
196
|
+
marginVertical: dp(10),
|
197
|
+
height: dp(1),
|
198
|
+
backgroundColor: '#ececec'
|
199
|
+
},
|
200
|
+
width15: {
|
201
|
+
width: dp(15),
|
202
|
+
},
|
203
|
+
width10: {
|
204
|
+
width: dp(10),
|
205
|
+
},
|
206
|
+
item: {
|
207
|
+
flexDirection: 'row',
|
208
|
+
alignItems: 'center',
|
209
|
+
},
|
210
|
+
fileImage: {
|
211
|
+
borderRadius: dp(5),
|
212
|
+
width: dp(49),
|
213
|
+
height: dp(49)
|
214
|
+
},
|
215
|
+
left: {
|
216
|
+
justifyContent: 'space-around'
|
217
|
+
},
|
218
|
+
name: {
|
219
|
+
color: '#333',
|
220
|
+
fontSize: dp(15),
|
221
|
+
lineHeight: dp(20),
|
222
|
+
width: dp(260),
|
223
|
+
},
|
224
|
+
time: {
|
225
|
+
color: '#666',
|
226
|
+
fontSize: dp(12),
|
227
|
+
lineHeight: dp(18),
|
228
|
+
},
|
229
|
+
accessory: {
|
230
|
+
alignSelf: 'center',
|
231
|
+
position: 'absolute',
|
232
|
+
right: dp(15),
|
233
|
+
}
|
234
|
+
});
|
235
|
+
export default FileSelector;
|
@@ -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,24 +9,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
33
9
|
}
|
34
10
|
return t;
|
35
11
|
};
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
const
|
40
|
-
const { width } = react_native_1.Dimensions.get('window');
|
12
|
+
import { dp, useTheme } from '@smart-link/rn-ui';
|
13
|
+
import React, { useRef } from 'react';
|
14
|
+
import { View, Animated, Dimensions, StyleSheet } from 'react-native';
|
15
|
+
const { width } = Dimensions.get('window');
|
41
16
|
/* 进度条组件 */
|
42
|
-
const Bar =
|
17
|
+
const Bar = React.memo((_a) => {
|
43
18
|
var { width: widthProp, progress } = _a, props = __rest(_a, ["width", "progress"]);
|
44
|
-
const theme =
|
45
|
-
const _progress =
|
46
|
-
|
47
|
-
|
19
|
+
const theme = useTheme();
|
20
|
+
const _progress = useRef(new Animated.Value(0));
|
21
|
+
React.useEffect(() => {
|
22
|
+
Animated.spring(_progress.current, {
|
48
23
|
toValue: progress,
|
49
24
|
useNativeDriver: false,
|
50
25
|
}).start();
|
51
26
|
}, [progress]);
|
52
|
-
return (<
|
53
|
-
<
|
27
|
+
return (<View style={[styles.background, { width: widthProp }, props.barStyle]}>
|
28
|
+
<Animated.View style={[
|
54
29
|
styles.fillStyle,
|
55
30
|
{
|
56
31
|
backgroundColor: theme.primaryColor,
|
@@ -60,18 +35,18 @@ const Bar = react_1.default.memo((_a) => {
|
|
60
35
|
}),
|
61
36
|
},
|
62
37
|
]}/>
|
63
|
-
</
|
38
|
+
</View>);
|
64
39
|
});
|
65
|
-
const styles =
|
40
|
+
const styles = StyleSheet.create({
|
66
41
|
background: {
|
67
|
-
height:
|
42
|
+
height: dp(10),
|
68
43
|
backgroundColor: '#ccc',
|
69
44
|
flexDirection: 'row',
|
70
|
-
borderRadius:
|
45
|
+
borderRadius: dp(30),
|
71
46
|
},
|
72
47
|
fillStyle: {
|
73
|
-
height:
|
74
|
-
borderRadius:
|
48
|
+
height: dp(10),
|
49
|
+
borderRadius: dp(30),
|
75
50
|
},
|
76
51
|
});
|
77
|
-
|
52
|
+
export default Bar;
|
@@ -1,64 +1,34 @@
|
|
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
|
-
exports.getImageStyle = void 0;
|
30
|
-
const react_1 = __importStar(require("react"));
|
31
|
-
const react_native_1 = require("react-native");
|
32
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
33
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
34
|
-
const default_assets_1 = require("../../../default-assets");
|
35
|
-
const useFormatMsgTime_1 = __importDefault(require("../../../hooks/useFormatMsgTime"));
|
36
|
-
const backup_1 = require("../../../api/backup");
|
37
|
-
const { width } = react_native_1.Dimensions.get('window');
|
38
|
-
const getImageStyle = (img, scale) => {
|
39
|
-
const imgInfo = react_native_1.Image.resolveAssetSource(img);
|
1
|
+
import React, { useEffect, useState } from 'react';
|
2
|
+
import { View, Text, StyleSheet, Dimensions, Image } from 'react-native';
|
3
|
+
import { Button, dp, Line, Modal, NavigationPage, Space, Toast } from '@smart-link/rn-ui';
|
4
|
+
import useTranslation from '../../../hooks/useTranslation';
|
5
|
+
import { messageBackupImg } from '../../../default-assets';
|
6
|
+
import useFormatMsgTime from '../../../hooks/useFormatMsgTime';
|
7
|
+
import { deleteMyBackupMessage, getMyLastBackupTime } from '../../../api/backup';
|
8
|
+
const { width } = Dimensions.get('window');
|
9
|
+
export const getImageStyle = (img, scale) => {
|
10
|
+
const imgInfo = Image.resolveAssetSource(img);
|
40
11
|
return {
|
41
12
|
width: width * scale,
|
42
13
|
height: ((width * imgInfo.height) / imgInfo.width) * scale,
|
43
14
|
};
|
44
15
|
};
|
45
|
-
exports.getImageStyle = getImageStyle;
|
46
16
|
const MessageBackup = ({ navigation, route }) => {
|
47
|
-
const { t } = (
|
48
|
-
const [noRecord, setNoRecord] =
|
49
|
-
const [lastBackupTime, setLastBackupTime] =
|
50
|
-
const time = (
|
51
|
-
|
17
|
+
const { t } = useTranslation();
|
18
|
+
const [noRecord, setNoRecord] = useState(true);
|
19
|
+
const [lastBackupTime, setLastBackupTime] = useState(Date.now());
|
20
|
+
const time = useFormatMsgTime(lastBackupTime);
|
21
|
+
useEffect(() => {
|
52
22
|
navigation.setOptions({
|
53
23
|
title: t('cloudBackup_title'),
|
54
24
|
});
|
55
25
|
navigation.addListener('focus', () => {
|
56
26
|
// 获取上次备份时间
|
57
27
|
console.log('focus');
|
58
|
-
|
28
|
+
getMyLastBackupTime()
|
59
29
|
.then(res => {
|
60
30
|
if (res.data) {
|
61
|
-
|
31
|
+
Toast.loading;
|
62
32
|
setLastBackupTime(new Date(res.data).getTime());
|
63
33
|
setNoRecord(false);
|
64
34
|
}
|
@@ -68,29 +38,29 @@ const MessageBackup = ({ navigation, route }) => {
|
|
68
38
|
});
|
69
39
|
});
|
70
40
|
}, [t, navigation, route]);
|
71
|
-
return (<
|
72
|
-
<
|
73
|
-
<
|
74
|
-
{noRecord ? (<
|
75
|
-
<
|
76
|
-
<
|
77
|
-
<
|
41
|
+
return (<NavigationPage noPadding>
|
42
|
+
<View style={styles.container}>
|
43
|
+
<Image style={styles.img} source={messageBackupImg.cloud}/>
|
44
|
+
{noRecord ? (<Text style={styles.title}>{t('cloudBackup_noRecord')}</Text>) : (<Text style={styles.title}>{t('cloudBackup_record', { time: time })}</Text>)}
|
45
|
+
<Space size="m"/>
|
46
|
+
<Line style={{ marginVertical: dp(10) }}/>
|
47
|
+
<Button style={styles.button} type={'primary'} onPress={() => {
|
78
48
|
navigation.navigate('StartBackupPage');
|
79
49
|
}}>
|
80
50
|
{t('cloudBackup_startText')}
|
81
|
-
</
|
51
|
+
</Button>
|
82
52
|
{!noRecord && (<>
|
83
|
-
<
|
53
|
+
<Button style={styles.button} type={'primary'} onPress={() => {
|
84
54
|
navigation.navigate('RestoreBackupPage');
|
85
55
|
}}>
|
86
56
|
{t('cloudBackup_restoreText')}
|
87
|
-
</
|
88
|
-
<
|
89
|
-
const model =
|
57
|
+
</Button>
|
58
|
+
<Button style={styles.button} onPress={() => {
|
59
|
+
const model = Modal.confirm({
|
90
60
|
title: t('cloudBackup_clearText'),
|
91
61
|
message: t('cloudBackup_clearTipsMessage'),
|
92
62
|
onOk: () => {
|
93
|
-
|
63
|
+
deleteMyBackupMessage().then(res => {
|
94
64
|
if (res.data) {
|
95
65
|
setNoRecord(true);
|
96
66
|
}
|
@@ -104,30 +74,30 @@ const MessageBackup = ({ navigation, route }) => {
|
|
104
74
|
});
|
105
75
|
}}>
|
106
76
|
{t('cloudBackup_clearText')}
|
107
|
-
</
|
77
|
+
</Button>
|
108
78
|
</>)}
|
109
|
-
</
|
110
|
-
</
|
79
|
+
</View>
|
80
|
+
</NavigationPage>);
|
111
81
|
};
|
112
|
-
const styles =
|
82
|
+
const styles = StyleSheet.create({
|
113
83
|
container: {
|
114
84
|
flex: 1,
|
115
85
|
alignItems: 'center',
|
116
|
-
paddingTop:
|
86
|
+
paddingTop: dp(40),
|
117
87
|
width,
|
118
88
|
},
|
119
|
-
img:
|
89
|
+
img: getImageStyle(messageBackupImg.cloud, 0.8),
|
120
90
|
title: {
|
121
|
-
fontSize:
|
91
|
+
fontSize: dp(16),
|
122
92
|
textAlign: 'center',
|
123
93
|
},
|
124
94
|
button: {
|
125
|
-
marginVertical:
|
126
|
-
width:
|
95
|
+
marginVertical: dp(8),
|
96
|
+
width: dp(width - 40),
|
127
97
|
},
|
128
98
|
tips: {
|
129
|
-
fontSize:
|
130
|
-
paddingVertical:
|
99
|
+
fontSize: dp(16),
|
100
|
+
paddingVertical: dp(20),
|
131
101
|
},
|
132
102
|
});
|
133
|
-
|
103
|
+
export default MessageBackup;
|
@@ -1,52 +1,24 @@
|
|
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 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 utils_1 = require("./utils");
|
33
|
-
const MessageBackup_1 = require("./MessageBackup");
|
34
|
-
const default_assets_1 = require("../../../default-assets");
|
35
|
-
const useTranslation_1 = __importDefault(require("../../../hooks/useTranslation"));
|
36
|
-
const Bar_1 = __importDefault(require("./Bar"));
|
37
|
-
const { width } = react_native_1.Dimensions.get('window');
|
1
|
+
import { Button, dp, NavigationPage } from '@smart-link/rn-ui';
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
3
|
+
import { View, StyleSheet, Dimensions, Image, Text } from 'react-native';
|
4
|
+
import { MessageRestoreUtils } from './utils';
|
5
|
+
import { getImageStyle } from './MessageBackup';
|
6
|
+
import { messageBackupImg } from '../../../default-assets';
|
7
|
+
import useTranslation from '../../../hooks/useTranslation';
|
8
|
+
import Bar from './Bar';
|
9
|
+
const { width } = Dimensions.get('window');
|
38
10
|
const RestoreBackupPage = ({ navigation }) => {
|
39
|
-
const { t, i18n } = (
|
40
|
-
const [progress, setProgress] =
|
41
|
-
const [paused, setPaused] =
|
42
|
-
const messageRestore =
|
43
|
-
|
11
|
+
const { t, i18n } = useTranslation();
|
12
|
+
const [progress, setProgress] = useState(0);
|
13
|
+
const [paused, setPaused] = useState(false);
|
14
|
+
const messageRestore = useRef();
|
15
|
+
useEffect(() => {
|
44
16
|
navigation.setOptions({
|
45
17
|
title: t('cloudBackup_restoreText'),
|
46
18
|
});
|
47
19
|
}, [t, navigation]);
|
48
|
-
|
49
|
-
messageRestore.current = new
|
20
|
+
useEffect(() => {
|
21
|
+
messageRestore.current = new MessageRestoreUtils(p => {
|
50
22
|
setProgress(p);
|
51
23
|
});
|
52
24
|
messageRestore.current.start();
|
@@ -71,65 +43,65 @@ const RestoreBackupPage = ({ navigation }) => {
|
|
71
43
|
setPaused(false);
|
72
44
|
};
|
73
45
|
const finished = progress >= 100;
|
74
|
-
return (<
|
75
|
-
<
|
76
|
-
<
|
77
|
-
<
|
78
|
-
{!finished ? (<
|
79
|
-
<
|
80
|
-
<
|
81
|
-
</
|
82
|
-
<
|
83
|
-
</
|
84
|
-
{!finished && !paused && (<
|
46
|
+
return (<NavigationPage noPadding>
|
47
|
+
<View style={styles.container}>
|
48
|
+
<Image style={styles.img} source={messageBackupImg.cloud_begin}/>
|
49
|
+
<View style={styles.progress}>
|
50
|
+
{!finished ? (<Text style={styles.text}>{t('cloudBackup_inRestore')}</Text>) : (<Text style={styles.text}>{t('cloudBackup_completed')}</Text>)}
|
51
|
+
<View style={styles.progressBar}>
|
52
|
+
<Bar width={dp(width - 80)} progress={progress}/>
|
53
|
+
</View>
|
54
|
+
<Text style={styles.progressText}>{progress}%</Text>
|
55
|
+
</View>
|
56
|
+
{!finished && !paused && (<Button style={styles.button} type={'primary'} onPress={pause}>
|
85
57
|
{t('cloudBackup_pause')}
|
86
|
-
</
|
87
|
-
{!finished && paused && (<
|
58
|
+
</Button>)}
|
59
|
+
{!finished && paused && (<Button style={styles.button} type={'primary'} onPress={resume}>
|
88
60
|
{t('cloudBackup_resume')}
|
89
|
-
</
|
90
|
-
{!finished && (<
|
61
|
+
</Button>)}
|
62
|
+
{!finished && (<Button style={styles.button} danger onPress={cancel}>
|
91
63
|
{t('cancel')}
|
92
|
-
</
|
64
|
+
</Button>)}
|
93
65
|
|
94
|
-
{finished && (<
|
66
|
+
{finished && (<Button style={styles.button} type="default" onPress={() => {
|
95
67
|
navigation.goBack();
|
96
68
|
}}>
|
97
69
|
{i18n.t('back')}
|
98
|
-
</
|
99
|
-
</
|
100
|
-
</
|
70
|
+
</Button>)}
|
71
|
+
</View>
|
72
|
+
</NavigationPage>);
|
101
73
|
};
|
102
|
-
const styles =
|
74
|
+
const styles = StyleSheet.create({
|
103
75
|
container: {
|
104
76
|
flex: 1,
|
105
77
|
alignItems: 'center',
|
106
|
-
paddingTop:
|
78
|
+
paddingTop: dp(20),
|
107
79
|
width,
|
108
80
|
},
|
109
|
-
img:
|
81
|
+
img: getImageStyle(messageBackupImg.cloud_begin, 0.8),
|
110
82
|
text: {
|
111
83
|
textAlign: 'center',
|
112
|
-
marginVertical:
|
84
|
+
marginVertical: dp(8),
|
113
85
|
},
|
114
86
|
button: {
|
115
|
-
marginVertical:
|
116
|
-
width:
|
87
|
+
marginVertical: dp(8),
|
88
|
+
width: dp(width - 40),
|
117
89
|
},
|
118
90
|
progress: {
|
119
|
-
paddingTop:
|
120
|
-
paddingBottom:
|
91
|
+
paddingTop: dp(30),
|
92
|
+
paddingBottom: dp(20),
|
121
93
|
},
|
122
94
|
progressBar: {
|
123
95
|
flexDirection: 'row',
|
124
96
|
alignItems: 'center',
|
125
97
|
},
|
126
98
|
percent: {
|
127
|
-
marginLeft:
|
128
|
-
fontSize:
|
99
|
+
marginLeft: dp(4),
|
100
|
+
fontSize: dp(14),
|
129
101
|
},
|
130
102
|
progressText: {
|
131
|
-
fontSize:
|
103
|
+
fontSize: dp(14),
|
132
104
|
textAlign: 'center',
|
133
105
|
},
|
134
106
|
});
|
135
|
-
|
107
|
+
export default RestoreBackupPage;
|