@mpxjs/api-proxy 2.9.53 → 2.9.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/@types/index.d.ts +7 -7
  2. package/package.json +20 -4
  3. package/src/common/js/promisify.js +3 -1
  4. package/src/common/js/utils.js +13 -1
  5. package/src/common/js/web.js +0 -12
  6. package/src/platform/api/action-sheet/ActionSheet.js +3 -7
  7. package/src/platform/api/action-sheet/index.android.js +1 -0
  8. package/src/platform/api/action-sheet/index.ios.js +1 -0
  9. package/src/platform/api/action-sheet/rnActionSheet.jsx +127 -0
  10. package/src/platform/api/app/index.android.js +1 -0
  11. package/src/platform/api/app/index.ios.js +1 -0
  12. package/src/platform/api/app/index.web.js +5 -4
  13. package/src/platform/api/clipboard-data/rnClipboard.js +5 -5
  14. package/src/platform/api/create-selector-query/index.android.js +1 -0
  15. package/src/platform/api/create-selector-query/index.ios.js +9 -0
  16. package/src/platform/api/create-selector-query/rnNodesRef.js +262 -0
  17. package/src/platform/api/create-selector-query/rnSelectQuery.js +43 -0
  18. package/src/platform/api/device/network/getNetworkType.js +4 -4
  19. package/src/platform/api/device/network/rnNetwork.js +3 -3
  20. package/src/platform/api/image/Preview.js +3 -3
  21. package/src/platform/api/location/index.ali.js +31 -0
  22. package/src/platform/api/location/index.android.js +1 -0
  23. package/src/platform/api/location/index.ios.js +31 -0
  24. package/src/platform/api/location/index.js +13 -0
  25. package/src/platform/api/location/index.web.js +36 -0
  26. package/src/platform/api/make-phone-call/rnMakePhone.js +3 -3
  27. package/src/platform/api/modal/Modal.js +12 -15
  28. package/src/platform/api/modal/index.android.js +1 -0
  29. package/src/platform/api/modal/index.ios.js +1 -0
  30. package/src/platform/api/modal/rnModal.jsx +149 -0
  31. package/src/platform/api/next-tick/index.android.js +1 -0
  32. package/src/platform/api/next-tick/index.ios.js +1 -0
  33. package/src/platform/api/page-scroll-to/index.web.js +3 -3
  34. package/src/platform/api/pull-down/index.web.js +5 -5
  35. package/src/platform/api/request/index.web.js +3 -6
  36. package/src/platform/api/route/index.ios.js +9 -9
  37. package/src/platform/api/route/index.web.js +15 -18
  38. package/src/platform/api/screen-brightness/index.android.js +1 -0
  39. package/src/platform/api/screen-brightness/index.ios.js +1 -0
  40. package/src/platform/api/screen-brightness/rnScreenBrightness.js +53 -0
  41. package/src/platform/api/set-navigation-bar/index.android.js +1 -0
  42. package/src/platform/api/set-navigation-bar/index.ios.js +41 -0
  43. package/src/platform/api/set-navigation-bar/index.web.js +3 -3
  44. package/src/platform/api/socket/SocketTask.js +7 -17
  45. package/src/platform/api/socket/index.web.js +3 -3
  46. package/src/platform/api/storage/index.web.js +11 -12
  47. package/src/platform/api/storage/rnStorage.js +12 -12
  48. package/src/platform/api/system/index.web.js +2 -2
  49. package/src/platform/api/system/rnSystem.js +3 -3
  50. package/src/platform/api/tab-bar/index.web.js +9 -9
  51. package/src/platform/api/toast/Toast.js +3 -3
  52. package/src/platform/api/toast/error.png +0 -0
  53. package/src/platform/api/toast/index.android.js +1 -0
  54. package/src/platform/api/toast/index.ios.js +1 -0
  55. package/src/platform/api/toast/rnToast.jsx +189 -0
  56. package/src/platform/api/toast/success.png +0 -0
  57. package/src/platform/index.js +3 -0
@@ -0,0 +1,189 @@
1
+ import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
2
+ import { successHandle, failHandle } from '../../../common/js'
3
+ import { Portal } from '@ant-design/react-native'
4
+ import successPng from './success.png'
5
+ import errorPng from './error.png'
6
+
7
+ let toastKey
8
+ let isLoadingShow
9
+ let tId // show duration 计时id
10
+ const styles = StyleSheet.create({
11
+ toastContent: {
12
+ minWdth: 150,
13
+ maxWidth: '60%',
14
+ backgroundColor: 'rgba(20, 20, 20, 0.7)',
15
+ paddingTop: 15,
16
+ paddingBottom: 15,
17
+ paddingLeft: 20,
18
+ paddingRight: 20,
19
+ borderRadius: 5,
20
+ display: 'flex',
21
+ flexDirection: 'column',
22
+ justifyContent: 'center',
23
+ alignItems: 'center'
24
+ },
25
+ toastWrap: {
26
+ left: 0,
27
+ right: 0,
28
+ top: 0,
29
+ bottom: 0,
30
+ zIndex: 10000,
31
+ position: "absolute",
32
+ display: 'flex',
33
+ justifyContent: 'center',
34
+ alignItems: 'center'
35
+ },
36
+ toastImg: {
37
+ width: 40,
38
+ height: 40,
39
+ marginLeft: 'auto',
40
+ marginRight: 'auto',
41
+ marginBottom: 10
42
+ },
43
+ toastText: {
44
+ textAlign: 'center',
45
+ color: '#ffffff',
46
+ fontSize: 14,
47
+ lineHeight: 18,
48
+ height: 18,
49
+ overflow: 'hidden'
50
+ }
51
+ })
52
+ function showToast (options) {
53
+ const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
54
+ let ToastView
55
+ const iconImg = {
56
+ success: successPng,
57
+ fail: errorPng
58
+ }
59
+ const pointerEvents = mask ? 'auto' : 'none'
60
+ isLoadingShow = isLoading
61
+ if (tId) {
62
+ clearTimeout(tId)
63
+ }
64
+ tId = null
65
+ if (image || icon === 'success' || icon === 'error') {
66
+ ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
67
+ <View style={styles.toastContent}>
68
+ <Image source={image || iconImg[icon]} style={styles.toastImg}></Image>
69
+ <Text style={styles.toastText}>{title}</Text>
70
+ </View>
71
+ </View>
72
+ } else if (icon === 'loading') {
73
+ ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
74
+ <View style={styles.toastContent}>
75
+ <ActivityIndicator
76
+ animating
77
+ style={{ marginBottom: 10 }}
78
+ size='small'
79
+ color='#eee'
80
+ />
81
+ <Text style={styles.toastText}>{title}</Text>
82
+ </View>
83
+ </View>
84
+ } else {
85
+ ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
86
+ <View style={styles.toastContent}>
87
+ <Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
88
+ height: 36
89
+ } : {}) }}>{title}</Text>
90
+ </View>
91
+ </View>
92
+ }
93
+ try {
94
+ if (toastKey) {
95
+ Portal.remove(toastKey)
96
+ }
97
+ toastKey = Portal.add(ToastView)
98
+ if (!isLoading) {
99
+ tId = setTimeout(() => {
100
+ Portal.remove(toastKey)
101
+ toastKey = null
102
+ }, duration)
103
+ }
104
+ const result = {
105
+ errMsg: 'showToast:ok'
106
+ }
107
+ successHandle(result, success, complete)
108
+ } catch (e) {
109
+ const result = {
110
+ errMsg: `showToast:fail invalid ${e}`
111
+ }
112
+ failHandle(result, fail, complete)
113
+ }
114
+ }
115
+
116
+ function hideToast(options) {
117
+ const { noConflict = false, success, fail, complete } = options
118
+
119
+ if (isLoadingShow && noConflict) {
120
+ return
121
+ }
122
+ try {
123
+ if (toastKey) {
124
+ Portal.remove(toastKey)
125
+ toastKey = null
126
+ }
127
+ const result = {
128
+ errMsg: 'hideToast:ok'
129
+ }
130
+ successHandle(result, success, complete)
131
+ } catch (e) {
132
+ const result = {
133
+ errMsg: `hideToast:fail invalid ${e}`
134
+ }
135
+ failHandle(result, fail, complete)
136
+ }
137
+ }
138
+
139
+ function showLoading (options) {
140
+ const { title, mask, success, fail, complete } = options
141
+ showToast({
142
+ title,
143
+ mask,
144
+ icon: 'loading',
145
+ isLoading: true,
146
+ success () {
147
+ const result = {
148
+ errMsg: 'showLoading:ok'
149
+ }
150
+ successHandle(result, success, complete)
151
+ },
152
+ fail (res) {
153
+ const result = {
154
+ errMsg: res.errMsg.replace('showToast', 'showLoading')
155
+ }
156
+ failHandle(result, success, complete)
157
+ }
158
+ })
159
+ }
160
+
161
+ function hideLoading (options) {
162
+ const { noConflict = false, success, fail, complete } = options
163
+ if (!isLoadingShow && noConflict) {
164
+ return
165
+ }
166
+ isLoadingShow = false
167
+ try {
168
+ if (toastKey) {
169
+ Portal.remove(toastKey)
170
+ toastKey = null
171
+ }
172
+ const result = {
173
+ errMsg: 'hideLoading:ok'
174
+ }
175
+ successHandle(result, success, complete)
176
+ } catch (e) {
177
+ const result = {
178
+ errMsg: `hideLoading:fail invalid ${e}`
179
+ }
180
+ failHandle(result, fail, complete)
181
+ }
182
+ }
183
+
184
+ export {
185
+ showToast,
186
+ hideToast,
187
+ showLoading,
188
+ hideLoading
189
+ }
@@ -107,3 +107,6 @@ export * from './api/window'
107
107
 
108
108
  // getEnterOptionsSync
109
109
  export * from './api/lifecycle'
110
+
111
+ // getLocation, openLocation, chooseLocation
112
+ export * from './api/location'