@mpxjs/api-proxy 2.9.61 → 2.9.64

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 (34) hide show
  1. package/@types/index.d.ts +3 -4
  2. package/LICENSE +433 -0
  3. package/package.json +9 -8
  4. package/src/common/js/utils.js +10 -1
  5. package/src/platform/api/action-sheet/rnActionSheet.jsx +1 -1
  6. package/src/platform/api/base/index.web.js +4 -1
  7. package/src/platform/api/clipboard-data/rnClipboard.js +18 -11
  8. package/src/platform/api/create-selector-query/rnNodesRef.js +15 -13
  9. package/src/platform/api/create-selector-query/rnSelectQuery.js +6 -0
  10. package/src/platform/api/device/network/rnNetwork.js +1 -1
  11. package/src/platform/api/ext/index.ali.js +23 -0
  12. package/src/platform/api/ext/index.js +10 -0
  13. package/src/platform/api/keyboard/index.android.js +1 -0
  14. package/src/platform/api/keyboard/index.ios.js +62 -0
  15. package/src/platform/api/keyboard/index.js +13 -0
  16. package/src/platform/api/location/index.ios.js +1 -1
  17. package/src/platform/api/location/index.web.js +1 -1
  18. package/src/platform/api/make-phone-call/rnMakePhone.js +1 -1
  19. package/src/platform/api/modal/rnModal.jsx +38 -16
  20. package/src/platform/api/page-scroll-to/index.web.js +1 -1
  21. package/src/platform/api/request/index.web.js +2 -2
  22. package/src/platform/api/screen-brightness/rnScreenBrightness.js +29 -44
  23. package/src/platform/api/set-navigation-bar/index.ios.js +14 -18
  24. package/src/platform/api/socket/SocketTask.js +1 -1
  25. package/src/platform/api/storage/rnStorage.js +5 -5
  26. package/src/platform/api/system/index.web.js +1 -1
  27. package/src/platform/api/system/rnSystem.js +36 -30
  28. package/src/platform/api/toast/rnToast.jsx +8 -8
  29. package/src/platform/api/vibrate/index.android.js +1 -0
  30. package/src/platform/api/vibrate/index.ios.js +39 -0
  31. package/src/platform/api/vibrate/index.js +10 -0
  32. package/src/platform/index.js +9 -0
  33. package/src/platform/api/toast/error.png +0 -0
  34. package/src/platform/api/toast/success.png +0 -0
@@ -0,0 +1,23 @@
1
+ import { changeOpts, ENV_OBJ, envError } from '../../../common/js'
2
+
3
+ const getExtConfig = function (options = {}) {
4
+ const cacheSuc = options.success
5
+ options.success = function (res) {
6
+ const sucRes = changeOpts(res, {
7
+ data: 'extConfig'
8
+ })
9
+ cacheSuc.call(this, sucRes)
10
+ }
11
+ if (ENV_OBJ.getExtConfig) {
12
+ ENV_OBJ.getExtConfig(options)
13
+ } else {
14
+ envError('getExtConfig')
15
+ }
16
+ }
17
+
18
+ const getExtConfigSync = ENV_OBJ.getExtConfigSync || envError('getExtConfigSync')
19
+
20
+ export {
21
+ getExtConfig,
22
+ getExtConfigSync
23
+ }
@@ -0,0 +1,10 @@
1
+ import { ENV_OBJ, envError } from '../../../common/js'
2
+
3
+ const getExtConfig = ENV_OBJ.getExtConfig || envError('getExtConfig')
4
+
5
+ const getExtConfigSync = ENV_OBJ.getExtConfigSync || envError('getExtConfigSync')
6
+
7
+ export {
8
+ getExtConfig,
9
+ getExtConfigSync
10
+ }
@@ -0,0 +1 @@
1
+ export * from './index'
@@ -0,0 +1,62 @@
1
+ import { Keyboard } from 'react-native'
2
+ import { successHandle, failHandle } from '../../../common/js'
3
+ let hasListener = false
4
+ const callbacks = []
5
+
6
+ function keyboardShowListener (e) {
7
+ const endCoordinates = e.endCoordinates || {}
8
+ // eslint-disable-next-line node/no-callback-literal
9
+ callbacks.forEach(cb => cb({
10
+ height: endCoordinates.height
11
+ }))
12
+ }
13
+ function keyboardHideListener (e) {
14
+ const endCoordinates = e.endCoordinates || {}
15
+ let height
16
+ if (__mpx_mode__ === 'ios') {
17
+ height = 0
18
+ } else {
19
+ height = endCoordinates.height
20
+ }
21
+ // eslint-disable-next-line node/no-callback-literal
22
+ callbacks.forEach(cb => cb({
23
+ height
24
+ }))
25
+ }
26
+ const onKeyboardHeightChange = function (callback) {
27
+ if (!hasListener) {
28
+ Keyboard.addListener('keyboardDidShow', keyboardShowListener)
29
+ Keyboard.addListener('keyboardDidHide', keyboardHideListener)
30
+ hasListener = true
31
+ }
32
+ callbacks.push(callback)
33
+ }
34
+ const offKeyboardHeightChange = function (callback) {
35
+ const index = callbacks.indexOf(callback)
36
+ if (index > -1) {
37
+ callbacks.splice(index, 1)
38
+ }
39
+ if (callbacks.length === 0) {
40
+ Keyboard.removeAllListeners('keyboardDidShow')
41
+ Keyboard.removeAllListeners('keyboardDidHide')
42
+ hasListener = false
43
+ }
44
+ }
45
+
46
+ const hideKeyboard = function (options = {}) {
47
+ const { success, fail, complete } = options
48
+ try {
49
+ Keyboard.dismiss()
50
+ const result = { errMsg: 'hideKeyboard:ok' }
51
+ successHandle(result, success, complete)
52
+ } catch (err) {
53
+ const result = { errMsg: err.message }
54
+ failHandle(result, fail, complete)
55
+ }
56
+ }
57
+
58
+ export {
59
+ onKeyboardHeightChange,
60
+ offKeyboardHeightChange,
61
+ hideKeyboard
62
+ }
@@ -0,0 +1,13 @@
1
+ import { ENV_OBJ, envError } from '../../../common/js'
2
+
3
+ const onKeyboardHeightChange = ENV_OBJ.onKeyboardHeightChange || envError('onKeyboardHeightChange')
4
+
5
+ const offKeyboardHeightChange = ENV_OBJ.offKeyboardHeightChange || envError('offKeyboardHeightChange')
6
+
7
+ const hideKeyboard = ENV_OBJ.hideKeyboard || envError('hideKeyboard')
8
+
9
+ export {
10
+ onKeyboardHeightChange,
11
+ offKeyboardHeightChange,
12
+ hideKeyboard
13
+ }
@@ -1,7 +1,7 @@
1
1
  import GetLocation from 'react-native-get-location'
2
2
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
 
4
- const getLocation = function (options) {
4
+ const getLocation = function (options = {}) {
5
5
  const { isHighAccuracy = false, success, fail, complete } = options
6
6
  GetLocation.getCurrentPosition({
7
7
  enableHighAccuracy: isHighAccuracy
@@ -1,6 +1,6 @@
1
1
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
2
2
 
3
- const getLocation = function (options) {
3
+ const getLocation = function (options = {}) {
4
4
  const { isHighAccuracy = false, success, fail, complete } = options
5
5
  if (navigator.geolocation.getCurrentPosition) {
6
6
  navigator.geolocation.getCurrentPosition((res = {}) => {
@@ -1,7 +1,7 @@
1
1
  import { successHandle, failHandle } from '../../../common/js'
2
2
  import { Linking } from 'react-native'
3
3
 
4
- const makePhoneCall = function (options) {
4
+ const makePhoneCall = function (options = {}) {
5
5
  const {
6
6
  phoneNumber = '',
7
7
  success = null,
@@ -1,8 +1,8 @@
1
- import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'
1
+ import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
3
  import { Portal } from '@ant-design/react-native'
4
4
  const { width, height } = Dimensions.get('window')
5
- const showModal = function (options) {
5
+ const showModal = function (options = {}) {
6
6
  const {
7
7
  title,
8
8
  content,
@@ -10,9 +10,9 @@ const showModal = function (options) {
10
10
  cancelText = '取消',
11
11
  cancelColor = '#000000',
12
12
  confirmText = '确定',
13
- confirmColor = '#576B95',
14
13
  editable = false,
15
- placeholderText,
14
+ placeholderText = '',
15
+ confirmColor = '#576B95',
16
16
  success,
17
17
  fail,
18
18
  complete
@@ -20,10 +20,13 @@ const showModal = function (options) {
20
20
  const modalWidth = width - 60
21
21
  const styles = StyleSheet.create({
22
22
  modalTask: {
23
- width,
24
- height,
23
+ left: 0,
24
+ right: 0,
25
+ top: 0,
26
+ bottom: 0,
25
27
  justifyContent: 'center',
26
28
  alignItems: 'center',
29
+ display: 'flex',
27
30
  backgroundColor: 'rgba(0,0,0,0.6)',
28
31
  position: 'absolute'
29
32
  },
@@ -82,12 +85,17 @@ const showModal = function (options) {
82
85
  let ModalView
83
86
  let modalTitle = []
84
87
  let modalContent = []
88
+ let editableContent = []
85
89
  let modalButton = [{
86
90
  text: confirmText,
87
91
  confirmColor,
88
92
  type: 'confirm',
89
93
  color: 'rgb(87, 107, 149)'
90
94
  }]
95
+ let contentText = content
96
+ const onChangeText = function (text) {
97
+ contentText = text
98
+ }
91
99
  const closeModal = function (buttonInfo) {
92
100
  Portal.remove(modalKey)
93
101
  modalKey = null
@@ -98,7 +106,7 @@ const showModal = function (options) {
98
106
  Object.assign(result, {
99
107
  confirm: true,
100
108
  cancel: false,
101
- content: null
109
+ content: editable ? contentText : null
102
110
  })
103
111
  } else {
104
112
  Object.assign(result, {
@@ -114,6 +122,9 @@ const showModal = function (options) {
114
122
  if (!editable && content) {
115
123
  modalContent.push(content)
116
124
  }
125
+ if (editable) {
126
+ editableContent.push(placeholderText)
127
+ }
117
128
  if (showCancel) {
118
129
  modalButton.unshift({
119
130
  text: cancelText,
@@ -123,17 +134,28 @@ const showModal = function (options) {
123
134
  color: '#000000'
124
135
  })
125
136
  }
126
- if (!editable) {
127
- ModalView = <View style={styles.modalTask}>
128
- <View style={styles.modalContent}>
129
- {modalTitle.map((item, index) => <View key={index}><Text style={styles.modalTitleText}>{item}</Text></View>)}
130
- {modalContent.map((item, index) => <ScrollView key={index} style={styles.contentBox}><Text style={styles.modalContentText}>{item}</Text></ScrollView>)}
131
- <View style={styles.modalBtnBox}>
132
- {modalButton.map((item, index) => <TouchableOpacity key={index} style={[ styles.modalBtn, item.style ]} onPress={() => closeModal(item)}><Text style={[styles.modalButton, { color: item.color }]}>{item.text}</Text></TouchableOpacity>)}
133
- </View>
137
+ ModalView = <View style={styles.modalTask}>
138
+ <View style={styles.modalContent}>
139
+ {modalTitle.map((item, index) => <View key={index}><Text style={styles.modalTitleText}>{item}</Text></View>)}
140
+ {modalContent.map((item, index) => <ScrollView key={index} style={styles.contentBox}><Text style={styles.modalContentText}>{item}</Text></ScrollView>)}
141
+ {editableContent.map((item, index) => <View key={index} style={{
142
+ width: '100%',
143
+ paddingLeft: 25,
144
+ paddingRight: 25,
145
+ marginTop: 5
146
+ }}><TextInput placeholder={item} style={{
147
+ height: 40,
148
+ backgroundColor: '#eeeeee',
149
+ width: '100%',
150
+ keyboardType: 'default',
151
+ paddingLeft: 10,
152
+ paddingRight: 10
153
+ }} onChangeText={text => onChangeText(text)} defaultValue={content}></TextInput></View>)}
154
+ <View style={styles.modalBtnBox}>
155
+ {modalButton.map((item, index) => <TouchableOpacity key={index} style={[ styles.modalBtn, item.style ]} onPress={() => closeModal(item)}><Text style={[styles.modalButton, { color: item.color }]}>{item.text}</Text></TouchableOpacity>)}
134
156
  </View>
135
157
  </View>
136
- }
158
+ </View>
137
159
  try {
138
160
  modalKey = Portal.add(ModalView)
139
161
  } catch (e) {
@@ -1,7 +1,7 @@
1
1
  import { successHandle, failHandle, isBrowser, throwSSRWarning } from '../../../common/js'
2
2
  import { nextTick } from '../next-tick'
3
3
 
4
- export function pageScrollTo (options) {
4
+ export function pageScrollTo (options = {}) {
5
5
  if (!isBrowser) {
6
6
  throwSSRWarning('pageScrollTo API is running in non browser environments')
7
7
  return
@@ -12,7 +12,7 @@ function request (options = { url: '' }) {
12
12
  method = 'GET',
13
13
  dataType = 'json',
14
14
  responseType = 'text',
15
- timeout = 60 * 1000,
15
+ timeout = global.__networkTimeout || 60 * 1000,
16
16
  header = {},
17
17
  success = null,
18
18
  fail = null,
@@ -88,7 +88,7 @@ function request (options = { url: '' }) {
88
88
  }
89
89
  }
90
90
 
91
- const result = Object.assign(res || {}, {
91
+ const result = Object.assign({}, res, {
92
92
  errMsg: 'request:ok',
93
93
  data,
94
94
  statusCode: res.status,
@@ -1,50 +1,35 @@
1
- // import * as Brightness from 'expo-brightness'
1
+ import * as Brightness from 'expo-brightness'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
- //
4
- // function getScreenBrightness (options) {
5
- // const { success, fail, complete } = options
6
- // Brightness.getBrightnessAsync().then(value => {
7
- // const result = {
8
- // errMsg: 'getScreenBrightness:ok',
9
- // value
10
- // }
11
- // successHandle(result, success, complete)
12
- // }).catch(() => {
13
- // const result = {
14
- // errMsg: 'getScreenBrightness:fail'
15
- // }
16
- // failHandle(result, fail, complete)
17
- // })
18
- // }
19
- //
20
- // function setScreenBrightness (options) {
21
- // const { value, success, fail, complete } = options
22
- // Brightness.setBrightnessAsync(value).then(() => {
23
- // const result = {
24
- // errMsg: 'setScreenBrightness:ok'
25
- // }
26
- // successHandle(result, success, complete)
27
- // }).catch(() => {
28
- // const result = {
29
- // errMsg: 'setScreenBrightness:fail'
30
- // }
31
- // failHandle(result, fail, complete)
32
- // })
33
- // }
34
3
 
35
- function getScreenBrightness (options) {
36
- const { success, complete } = options
37
- const result = {
38
- errMsg: 'getScreenBrightness:ok'
39
- }
40
- successHandle(result, success, complete)
4
+ function getScreenBrightness (options = {}) {
5
+ const { success, fail, complete } = options
6
+ Brightness.getBrightnessAsync().then(value => {
7
+ const result = {
8
+ errMsg: 'getScreenBrightness:ok',
9
+ value
10
+ }
11
+ successHandle(result, success, complete)
12
+ }).catch(() => {
13
+ const result = {
14
+ errMsg: 'getScreenBrightness:fail'
15
+ }
16
+ failHandle(result, fail, complete)
17
+ })
41
18
  }
42
- function setScreenBrightness (options) {
43
- const { fail, complete } = options
44
- const result = {
45
- errMsg: 'setScreenBrightness:fail'
46
- }
47
- failHandle(result, fail, complete)
19
+
20
+ function setScreenBrightness (options = {}) {
21
+ const { value, success, fail, complete } = options
22
+ Brightness.setBrightnessAsync(value).then(() => {
23
+ const result = {
24
+ errMsg: 'setScreenBrightness:ok'
25
+ }
26
+ successHandle(result, success, complete)
27
+ }).catch(() => {
28
+ const result = {
29
+ errMsg: 'setScreenBrightness:fail'
30
+ }
31
+ failHandle(result, fail, complete)
32
+ })
48
33
  }
49
34
 
50
35
  export {
@@ -1,21 +1,15 @@
1
- import { successHandle, failHandle } from '../../../common/js'
2
-
3
- function getFocusedNavigation () {
4
- for (const key in global.__mpxPagesMap) {
5
- const navigation = global.__mpxPagesMap[key]?.[1]
6
- if (navigation && navigation.isFocused()) {
7
- return navigation
8
- }
9
- }
10
- }
1
+ import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
2
+ import { nextTick } from '../next-tick'
11
3
  function setNavigationBarTitle (options = {}) {
12
4
  const { title = '', success, fail, complete } = options
13
5
  const navigation = getFocusedNavigation()
14
6
  if (!(navigation && navigation.setOptions)) {
15
7
  failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
16
8
  } else {
17
- navigation.setOptions({ headerTitle: title })
18
- successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
9
+ nextTick(() => {
10
+ navigation.setOptions({ headerTitle: title })
11
+ successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
12
+ })
19
13
  }
20
14
  }
21
15
 
@@ -25,13 +19,15 @@ function setNavigationBarColor (options = {}) {
25
19
  if (!(navigation && navigation.setOptions)) {
26
20
  failHandle({ errMsg: 'setNavigationBarColor:fail' }, fail, complete)
27
21
  } else {
28
- navigation.setOptions({
29
- headerStyle: {
30
- backgroundColor: backgroundColor
31
- },
32
- headerTintColor: frontColor
22
+ nextTick(() => {
23
+ navigation.setOptions({
24
+ headerStyle: {
25
+ backgroundColor: backgroundColor
26
+ },
27
+ headerTintColor: frontColor
28
+ })
29
+ successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
33
30
  })
34
- successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
35
31
  }
36
32
  }
37
33
 
@@ -40,7 +40,7 @@ class SocketTask {
40
40
  return this._socket.readyState
41
41
  }
42
42
 
43
- send (options) {
43
+ send (options = {}) {
44
44
  const { data = '', success, fail, complete } = options
45
45
  if (typeof data !== 'string' || type(data) !== 'ArrayBuffer') {
46
46
  const res = { errMsg: 'sendSocketMessage:fail Unsupported data type' }
@@ -1,7 +1,7 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage'
2
2
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
  import { hasOwn } from '@mpxjs/utils'
4
- function setStorage (options) {
4
+ function setStorage (options = {}) {
5
5
  const { key, data, success, fail, complete } = options
6
6
  let obj = {}
7
7
  if (typeof data === 'symbol') {
@@ -26,7 +26,7 @@ function setStorage (options) {
26
26
 
27
27
  const setStorageSync = envError('setStorageSync')
28
28
 
29
- function getStorage (options) {
29
+ function getStorage (options = {}) {
30
30
  const { key, success, fail, complete } = options
31
31
  if (!key) {
32
32
  const result = {
@@ -62,7 +62,7 @@ function getStorage (options) {
62
62
 
63
63
  const getStorageSync = envError('getStorageSync')
64
64
 
65
- function getStorageInfo (options) {
65
+ function getStorageInfo (options = {}) {
66
66
  const { success, fail, complete } = options
67
67
  AsyncStorage.getAllKeys((err, keys) => {
68
68
  if (err) {
@@ -83,7 +83,7 @@ function getStorageInfo (options) {
83
83
 
84
84
  const getStorageInfoSync = envError('getStorageInfoSync')
85
85
 
86
- function removeStorage (options) {
86
+ function removeStorage (options = {}) {
87
87
  const { key, success, fail, complete } = options
88
88
  AsyncStorage.removeItem(key, (err) => {
89
89
  if (err) {
@@ -104,7 +104,7 @@ function removeStorageSync (key) {
104
104
  AsyncStorage.removeItem(key)
105
105
  }
106
106
 
107
- function clearStorage (options) {
107
+ function clearStorage (options = {}) {
108
108
  const { success, fail, complete } = options
109
109
  AsyncStorage.clear((err) => {
110
110
  if (err) {
@@ -5,7 +5,7 @@ function getSystemInfoSync () {
5
5
  throwSSRWarning('getSystemInfoSync API is running in non browser environments')
6
6
  return
7
7
  }
8
- const ua = navigator.userAgent.split('(')[1].split(')')[0]
8
+ const ua = navigator.userAgent.split('(')[1]?.split(')')[0] || ''
9
9
  const phones = new Map([
10
10
  ['iPhone', /iPhone|iPad|iPod|iOS/i],
11
11
  ['Huawei', /huawei/i],
@@ -1,56 +1,62 @@
1
1
  import DeviceInfo from 'react-native-device-info'
2
2
  import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
3
3
  import { initialWindowMetrics } from 'react-native-safe-area-context'
4
- import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
4
+ import { successHandle, failHandle, defineUnsupportedProps, getFocusedNavigation } from '../../../common/js'
5
5
 
6
6
  const getWindowInfo = function () {
7
- const dimensionsWindow = Dimensions.get('window')
8
7
  const dimensionsScreen = Dimensions.get('screen')
9
- const result = {
10
- pixelRatio: PixelRatio.get(),
11
- windowWidth: dimensionsWindow.width,
12
- windowHeight: dimensionsWindow.height,
13
- screenWidth: dimensionsScreen.width,
14
- screenHeight: dimensionsScreen.height
8
+ const navigation = getFocusedNavigation() || {}
9
+ const insets = {
10
+ ...(initialWindowMetrics?.insets || {}),
11
+ ...(navigation.insets || {})
15
12
  }
16
- defineUnsupportedProps(result, ['screenTop'])
17
- return result
18
- }
19
-
20
- const getSystemInfoSync = function () {
21
- const windowInfo = getWindowInfo()
22
- const { screenWidth, screenHeight } = windowInfo
23
13
  let safeArea = {}
24
- let { top = 0, bottom = 0 } = initialWindowMetrics?.insets || {}
14
+ let { top = 0, bottom = 0, left = 0, right = 0 } = insets
25
15
  if (Platform.OS === 'android') {
26
16
  top = StatusBar.currentHeight || 0
27
17
  }
28
- const iosRes = {}
29
-
18
+ const screenHeight = dimensionsScreen.height
19
+ const screenWidth = dimensionsScreen.width
20
+ const layout = navigation.layout || {}
21
+ const layoutHeight = layout.height || 0
22
+ const layoutWidth = layout.width || 0
23
+ const windowHeight = layoutHeight || screenHeight
30
24
  try {
31
- const width = Math.min(screenWidth, screenHeight)
32
- const height = Math.max(screenWidth, screenHeight)
33
25
  safeArea = {
34
- left: 0,
35
- right: width,
26
+ left,
27
+ right: screenWidth - right,
36
28
  top,
37
- bottom: height - bottom,
38
- height: height - bottom - top,
39
- width
29
+ bottom: screenHeight - bottom,
30
+ height: screenHeight - top - bottom,
31
+ width: screenWidth - left - right
40
32
  }
41
33
  } catch (error) {
42
34
  }
35
+ const result = {
36
+ pixelRatio: PixelRatio.get(),
37
+ windowWidth: layoutWidth || screenWidth,
38
+ windowHeight, // 取不到layout的时候有个兜底
39
+ screenWidth: screenWidth,
40
+ screenHeight: screenHeight,
41
+ screenTop: screenHeight - windowHeight,
42
+ safeArea
43
+ }
44
+ return result
45
+ }
46
+
47
+ const getSystemInfoSync = function () {
48
+ const windowInfo = getWindowInfo()
49
+ const { screenWidth, screenHeight, safeArea } = windowInfo
50
+
43
51
  const result = {
44
52
  brand: DeviceInfo.getBrand(),
45
53
  model: DeviceInfo.getModel(),
46
54
  system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
47
55
  platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
48
56
  deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape',
49
- statusBarHeight: top,
57
+ statusBarHeight: safeArea.top,
50
58
  fontSizeSetting: PixelRatio.getFontScale(),
51
- safeArea,
52
- ...windowInfo,
53
- ...iosRes
59
+ ...windowInfo
54
60
  }
55
61
  defineUnsupportedProps(result, [
56
62
  'language',
@@ -77,7 +83,7 @@ const getSystemInfoSync = function () {
77
83
  return result
78
84
  }
79
85
 
80
- const getSystemInfo = function (options) {
86
+ const getSystemInfo = function (options = {}) {
81
87
  const { success, fail, complete } = options
82
88
  try {
83
89
  const systemInfo = getSystemInfoSync()
@@ -1,8 +1,6 @@
1
1
  import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
3
  import { Portal } from '@ant-design/react-native'
4
- import successPng from './success.png'
5
- import errorPng from './error.png'
6
4
 
7
5
  let toastKey
8
6
  let isLoadingShow
@@ -49,12 +47,14 @@ const styles = StyleSheet.create({
49
47
  overflow: 'hidden'
50
48
  }
51
49
  })
52
- function showToast (options) {
50
+ function showToast (options = {}) {
53
51
  const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
54
52
  let ToastView
53
+ const successPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcAgMAAACegTrLAAAADFBMVEUAAAD////R0dHj4+PcME2AAAAAAXRSTlMAQObYZgAAANNJREFUSMft1FEKwkAMBNBGyBFyH4/gR8f+ehSPLtiyQ+wM2C8Rmp+WQN90N8tOZ/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CB119h62ocDekeFSZVkHIqNp8KKjhomzYy/gxuvHbC859xCuoWLdxVR++s/6zOtdlBfJo2xkYiAWXtazNtFvb5LUDTfvouf7tY1U/wV+PzG+n2b7UKR++rn9gAbbOMP15Apn875bSR0AXX84tRl5HzDnyPIbCnBdkDtRaYg87gtbOxf9KB5m3zNyMEtNuYuBtxUCzpH9lZ4OIB3p2WbK+YBh4J17IeCml0Ns2949Dv4Oylm5F7LCwDnCF+hxP6rjLNdyqPOSaCEy2Tsp1/0m9+wWfUoLAzd+32B7ok8fIas1IngTPWOk116jBNqXMeWqnOszRizrUVXPQnmdvqZnlXqNVFaFKUf9iWQpK3uGD/HxOk4E+5BmoTFN/g/T33Q/5rVGC9NlkQKQ/30m11JdlAZuen+Nrcbm16spN+VY2oIA58jrd70xdLJ0RPkOdCnZzsd6eonWvN5O+fRlJn/3wjXKaczkWNhJZ8egM0UA3IXj99DqTgeBt5P407LCQeN3B9ttKMiJY3zO3JzlzQvA/n5mYZnXQYErEKAL9vuohWKZwMtigZbvNtoCbEEPZsEDNgFuIcLTwaLsdaS4g8c+oxvFHhz2DP/hX3KmL0cxH1iD+yimmHUL8uAZgS9F6TF6VR46gKcHRVYJvNMX4EeRHjvaNFNMo504r6stic36h/0GHxa6nCGA15eSHoGhcfRal30CtjmFL43ja3mcdS3AO/AAv5jXm5AelrAOLUEx7BJONWPUFH32PbD9/0QBrzH1KqS/XX8KafI0grx/c2UfmZZsJ5AmLZ+iIyj9SwIg9BjwtS6yDK1B96AWWoF0APRnJ3ON2Pz7I4R+iLiCBPgcaqNvkCYvF5iIxV5JpBt3q/WS4homB2EBbRci3V8o4Hov012rAq77swfi38oQZ7JEIBFIBBKBRCARSAQSgUQgEUgEEoFEICCBfwDKNlghU/F3VgAAAABJRU5ErkJggg=='
55
55
  const iconImg = {
56
56
  success: successPng,
57
- fail: errorPng
57
+ error: errorPng
58
58
  }
59
59
  const pointerEvents = mask ? 'auto' : 'none'
60
60
  isLoadingShow = isLoading
@@ -65,7 +65,7 @@ function showToast (options) {
65
65
  if (image || icon === 'success' || icon === 'error') {
66
66
  ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
67
67
  <View style={styles.toastContent}>
68
- <Image source={image || iconImg[icon]} style={styles.toastImg}></Image>
68
+ <Image style={ styles.toastImg } source={{uri: image || iconImg[icon]}}></Image>
69
69
  <Text style={styles.toastText}>{title}</Text>
70
70
  </View>
71
71
  </View>
@@ -113,7 +113,7 @@ function showToast (options) {
113
113
  }
114
114
  }
115
115
 
116
- function hideToast(options) {
116
+ function hideToast(options = {}) {
117
117
  const { noConflict = false, success, fail, complete } = options
118
118
 
119
119
  if (isLoadingShow && noConflict) {
@@ -136,7 +136,7 @@ function hideToast(options) {
136
136
  }
137
137
  }
138
138
 
139
- function showLoading (options) {
139
+ function showLoading (options = {}) {
140
140
  const { title, mask, success, fail, complete } = options
141
141
  showToast({
142
142
  title,
@@ -158,7 +158,7 @@ function showLoading (options) {
158
158
  })
159
159
  }
160
160
 
161
- function hideLoading (options) {
161
+ function hideLoading (options = {}) {
162
162
  const { noConflict = false, success, fail, complete } = options
163
163
  if (!isLoadingShow && noConflict) {
164
164
  return
@@ -0,0 +1 @@
1
+ export * from './index.ios'