@mpxjs/api-proxy 2.9.69 → 2.9.70
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/@types/index.d.ts +13 -0
- package/package.json +3 -3
- package/src/common/js/promisify.js +11 -3
- package/src/platform/api/action-sheet/rnActionSheet.jsx +67 -81
- package/src/platform/api/app/index.web.js +26 -11
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +2 -2
- package/src/platform/api/create-selector-query/rnNodesRef.js +1 -6
- package/src/platform/api/image/index.ali.js +4 -1
- package/src/platform/api/image/index.ios.js +45 -0
- package/src/platform/api/image/index.js +4 -1
- package/src/platform/api/image/index.web.js +46 -2
- package/src/platform/api/modal/rnModal.jsx +7 -8
- package/src/platform/api/request/index.web.js +2 -3
- package/src/platform/api/set-navigation-bar/index.ali.js +6 -1
- package/src/platform/api/set-navigation-bar/index.ios.js +6 -3
- package/src/platform/api/set-navigation-bar/index.js +4 -1
- package/src/platform/api/set-navigation-bar/index.web.js +5 -2
- package/src/platform/api/setting/index.js +19 -0
- package/src/platform/api/storage/index.web.js +1 -1
- package/src/platform/api/storage/rnStorage.js +1 -1
- package/src/platform/api/system/index.ios.js +84 -1
- package/src/platform/api/system/rnSystem.js +35 -73
- package/src/platform/api/toast/rnToast.jsx +23 -16
- package/src/platform/index.js +4 -1
- package/src/platform/api/system/rnWindowInfo.js +0 -42
package/@types/index.d.ts
CHANGED
|
@@ -110,6 +110,19 @@ export const createVideoContext: WechatMiniprogram.Wx['createVideoContext']
|
|
|
110
110
|
export const onWindowResize: WechatMiniprogram.Wx['onWindowResize']
|
|
111
111
|
export const offWindowResize: WechatMiniprogram.Wx['offWindowResize']
|
|
112
112
|
export const createAnimation: WechatMiniprogram.Wx['createAnimation']
|
|
113
|
+
export const hideHomeButton: WechatMiniprogram.Wx['hideHomeButton']
|
|
114
|
+
export const getSetting: WechatMiniprogram.Wx['getSetting']
|
|
115
|
+
export const openSetting: WechatMiniprogram.Wx['openSetting']
|
|
116
|
+
export const enableAlertBeforeUnload: WechatMiniprogram.Wx['enableAlertBeforeUnload']
|
|
117
|
+
export const disableAlertBeforeUnload: WechatMiniprogram.Wx['disableAlertBeforeUnload']
|
|
118
|
+
export const getMenuButtonBoundingClientRect: WechatMiniprogram.Wx['getMenuButtonBoundingClientRect']
|
|
119
|
+
export const getImageInfo: WechatMiniprogram.Wx['getImageInfo']
|
|
120
|
+
export const vibrateShort: WechatMiniprogram.Wx['vibrateShort']
|
|
121
|
+
export const vibrateLong: WechatMiniprogram.Wx['vibrateLong']
|
|
122
|
+
export const getExtConfig: WechatMiniprogram.Wx['getExtConfig']
|
|
123
|
+
export const getExtConfigSync: WechatMiniprogram.Wx['getExtConfigSync']
|
|
124
|
+
export const openLocation: WechatMiniprogram.Wx['openLocation']
|
|
125
|
+
export const chooseLocation: WechatMiniprogram.Wx['chooseLocation']
|
|
113
126
|
|
|
114
127
|
declare const install: (...args: any) => any
|
|
115
128
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.70",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mpxjs/utils": "^2.9.
|
|
40
|
+
"@mpxjs/utils": "^2.9.70",
|
|
41
41
|
"axios": "^1.7.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"optional": true
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "ad8f04de95865ffc2b50b8c0a7f87b5952fb8647"
|
|
76
76
|
}
|
|
@@ -70,14 +70,22 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
70
70
|
result[key] = function (...args) {
|
|
71
71
|
const obj = args[0] || {}
|
|
72
72
|
// 不需要转换 or 用户已定义回调,则不处理
|
|
73
|
-
if (!promisifyFilter(key)
|
|
73
|
+
if (!promisifyFilter(key)) {
|
|
74
74
|
return listObj[key].apply(ENV_OBJ, args)
|
|
75
75
|
} else { // 其他情况进行转换
|
|
76
76
|
if (!args[0]) args.unshift(obj)
|
|
77
77
|
let returned
|
|
78
78
|
const promise = new Promise((resolve, reject) => {
|
|
79
|
-
obj.success
|
|
80
|
-
obj.fail
|
|
79
|
+
const originSuccess = obj.success
|
|
80
|
+
const originFail = obj.fail
|
|
81
|
+
obj.success = function (res) {
|
|
82
|
+
originSuccess && originSuccess.call(this, res)
|
|
83
|
+
resolve(res)
|
|
84
|
+
}
|
|
85
|
+
obj.fail = function (e) {
|
|
86
|
+
originFail && originFail.call(this, e)
|
|
87
|
+
reject(e)
|
|
88
|
+
}
|
|
81
89
|
returned = listObj[key].apply(ENV_OBJ, args)
|
|
82
90
|
})
|
|
83
91
|
promise.__returned = returned
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import { View, TouchableHighlight, Text, StyleSheet,
|
|
1
|
+
import { View, TouchableHighlight, Text, StyleSheet, TouchableOpacity } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
import { Portal } from '@ant-design/react-native'
|
|
4
|
+
import { getWindowInfo } from '../system/rnSystem'
|
|
5
|
+
import Animated, {
|
|
6
|
+
useSharedValue,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
withTiming
|
|
9
|
+
} from 'react-native-reanimated'
|
|
4
10
|
function showActionSheet (options = {}) {
|
|
5
11
|
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
// Will change fadeAnim value to 1 in 5 seconds
|
|
10
|
-
Animated.timing(slideAnim, {
|
|
11
|
-
toValue: 0,
|
|
12
|
-
duration: 200,
|
|
13
|
-
useNativeDriver: true,
|
|
14
|
-
}).start()
|
|
15
|
-
}
|
|
16
|
-
const slideOut = () => {
|
|
17
|
-
// Will change fadeAnim value to 1 in 5 seconds
|
|
18
|
-
Animated.timing(slideAnim, {
|
|
19
|
-
toValue: 500,
|
|
20
|
-
duration: 200,
|
|
21
|
-
useNativeDriver: true,
|
|
22
|
-
}).start(() => {
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
if (itemList.length === 0 || itemList.length > 6) {
|
|
26
|
-
const result = {
|
|
27
|
-
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
|
|
28
|
-
}
|
|
29
|
-
if (itemList.length === 0) {
|
|
30
|
-
result.errno = 1001
|
|
31
|
-
result.errMsg = 'showActionSheet:fail parameter error: parameter.itemList should have at least 1 item;'
|
|
32
|
-
}
|
|
33
|
-
failHandle(result, fail, complete)
|
|
34
|
-
return
|
|
35
|
-
}
|
|
12
|
+
const windowInfo = getWindowInfo()
|
|
13
|
+
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
|
|
14
|
+
let actionSheetKey = null
|
|
36
15
|
const styles = StyleSheet.create({
|
|
37
16
|
actionActionMask: {
|
|
38
17
|
left: 0,
|
|
@@ -44,16 +23,14 @@ function showActionSheet (options = {}) {
|
|
|
44
23
|
zIndex: 1000
|
|
45
24
|
},
|
|
46
25
|
actionSheetContent: {
|
|
47
|
-
left: 0,
|
|
48
|
-
right: 0,
|
|
49
|
-
position: 'absolute',
|
|
50
|
-
bottom: 0,
|
|
51
26
|
backgroundColor: '#ffffff',
|
|
52
27
|
borderTopLeftRadius: 10,
|
|
53
28
|
borderTopRightRadius: 10,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
bottom: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
right: 0,
|
|
33
|
+
paddingBottom: bottom
|
|
57
34
|
},
|
|
58
35
|
itemStyle: {
|
|
59
36
|
paddingTop: 15,
|
|
@@ -73,53 +50,62 @@ function showActionSheet (options = {}) {
|
|
|
73
50
|
paddingBottom: 10
|
|
74
51
|
}
|
|
75
52
|
})
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
53
|
+
function ActionSheet () {
|
|
54
|
+
const offset = useSharedValue(1000);
|
|
55
|
+
|
|
56
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
57
|
+
transform: [{ translateY: offset.value }],
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
const slideOut = () => {
|
|
61
|
+
// Will change fadeAnim value to 1 in 5 seconds
|
|
62
|
+
offset.value = withTiming(1000)
|
|
83
63
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
|
|
65
|
+
offset.value = withTiming(0)
|
|
66
|
+
|
|
67
|
+
const selectAction = function (index) {
|
|
68
|
+
const result = {
|
|
69
|
+
errMsg: 'showActionSheet:ok',
|
|
70
|
+
tapIndex: index
|
|
71
|
+
}
|
|
72
|
+
successHandle(result, success, complete)
|
|
73
|
+
remove()
|
|
89
74
|
}
|
|
90
|
-
|
|
91
|
-
remove()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
|
|
76
|
+
const remove = function () {
|
|
77
|
+
if (actionSheetKey) {
|
|
78
|
+
slideOut()
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
Portal.remove(actionSheetKey)
|
|
81
|
+
actionSheetKey = null
|
|
82
|
+
}, 200)
|
|
83
|
+
}
|
|
96
84
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
|
|
86
|
+
const cancelAction = function () {
|
|
87
|
+
const result = {
|
|
88
|
+
errMsg: 'showActionSheet:fail cancel'
|
|
89
|
+
}
|
|
90
|
+
failHandle(result, fail, complete)
|
|
91
|
+
remove()
|
|
92
|
+
}
|
|
93
|
+
return (
|
|
94
|
+
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" activeOpacity={1} onPress={cancelAction} style={styles.actionActionMask}>
|
|
95
|
+
<Animated.View style={[styles.actionSheetContent, animatedStyles]} >
|
|
96
|
+
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
|
|
97
|
+
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
98
|
+
borderBottomWidth: 6,
|
|
99
|
+
borderBottomStyle: 'solid',
|
|
100
|
+
borderBottomColor: '#f7f7f7'
|
|
101
|
+
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></TouchableHighlight>) }
|
|
102
|
+
<View style={styles.buttonStyle}><TouchableOpacity onPress={cancelAction}><Text style={{ color: "#000000", width: "100%", textAlign: "center" }}>取消</Text></TouchableOpacity></View>
|
|
103
|
+
</Animated.View>
|
|
104
|
+
</TouchableHighlight>
|
|
105
|
+
)
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
style={[
|
|
107
|
-
styles.actionSheetContent,
|
|
108
|
-
{
|
|
109
|
-
transform: [{translateY: slideAnim}]
|
|
110
|
-
}
|
|
111
|
-
]}>
|
|
112
|
-
{ alertTextList.map((item, index) => <View key={index} style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{item}</Text></View>) }
|
|
113
|
-
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
114
|
-
borderBottomWidth: 6,
|
|
115
|
-
borderBottomStyle: 'solid',
|
|
116
|
-
borderBottomColor: '#f7f7f7'
|
|
117
|
-
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></TouchableHighlight>) }
|
|
118
|
-
<View style={styles.buttonStyle}><Button color={'#000000'} title={'取消'} onPress={cancelAction}></Button></View>
|
|
119
|
-
</Animated.View>
|
|
120
|
-
</TouchableHighlight>
|
|
121
|
-
actionSheetKey = Portal.add(ActionSheetView)
|
|
122
|
-
slideIn()
|
|
107
|
+
|
|
108
|
+
actionSheetKey = Portal.add(<ActionSheet/>)
|
|
123
109
|
}
|
|
124
110
|
|
|
125
111
|
export {
|
|
@@ -3,8 +3,27 @@ import { isBrowser, isReact } from '@mpxjs/utils'
|
|
|
3
3
|
global.__mpxAppCbs = global.__mpxAppCbs || {
|
|
4
4
|
show: [],
|
|
5
5
|
hide: [],
|
|
6
|
-
error: []
|
|
6
|
+
error: [],
|
|
7
|
+
rejection: []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function off (cbs, cb) {
|
|
11
|
+
if (cb) {
|
|
12
|
+
const idx = cbs.indexOf(cb)
|
|
13
|
+
if (idx > -1) cbs.splice(idx, 1)
|
|
14
|
+
} else {
|
|
15
|
+
cbs.length = 0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onUnhandledRejection (callback) {
|
|
20
|
+
if (isBrowser || isReact) {
|
|
21
|
+
global.__mpxAppCbs.rejection.push(callback)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
7
24
|
|
|
25
|
+
function offUnhandledRejection (callback) {
|
|
26
|
+
off(global.__mpxAppCbs.rejection, callback)
|
|
8
27
|
}
|
|
9
28
|
|
|
10
29
|
function onError (callback) {
|
|
@@ -14,9 +33,7 @@ function onError (callback) {
|
|
|
14
33
|
}
|
|
15
34
|
|
|
16
35
|
function offError (callback) {
|
|
17
|
-
|
|
18
|
-
const index = cbs.indexOf(callback)
|
|
19
|
-
if (index > -1) cbs.splice(index, 1)
|
|
36
|
+
off(global.__mpxAppCbs.error, callback)
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
function onAppShow (callback) {
|
|
@@ -26,9 +43,7 @@ function onAppShow (callback) {
|
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
function offAppShow (callback) {
|
|
29
|
-
|
|
30
|
-
const index = cbs.indexOf(callback)
|
|
31
|
-
if (index > -1) cbs.splice(index, 1)
|
|
46
|
+
off(global.__mpxAppCbs.show, callback)
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
function onAppHide (callback) {
|
|
@@ -38,9 +53,7 @@ function onAppHide (callback) {
|
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
function offAppHide (callback) {
|
|
41
|
-
|
|
42
|
-
const index = cbs.indexOf(callback)
|
|
43
|
-
if (index > -1) cbs.splice(index, 1)
|
|
56
|
+
off(global.__mpxAppCbs.hide, callback)
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
export {
|
|
@@ -49,5 +62,7 @@ export {
|
|
|
49
62
|
offAppShow,
|
|
50
63
|
offAppHide,
|
|
51
64
|
onError,
|
|
52
|
-
offError
|
|
65
|
+
offError,
|
|
66
|
+
onUnhandledRejection,
|
|
67
|
+
offUnhandledRejection
|
|
53
68
|
}
|
|
@@ -85,7 +85,7 @@ class RNIntersectionObserver {
|
|
|
85
85
|
|
|
86
86
|
_getWindowRect () {
|
|
87
87
|
if (this.windowRect) return this.windowRect
|
|
88
|
-
const navigation = getFocusedNavigation()
|
|
88
|
+
const navigation = getFocusedNavigation() || {}
|
|
89
89
|
const screen = Dimensions.get('screen')
|
|
90
90
|
const navigationLayout = navigation.layout || {
|
|
91
91
|
x: 0,
|
|
@@ -96,7 +96,7 @@ class RNIntersectionObserver {
|
|
|
96
96
|
|
|
97
97
|
const windowRect = {
|
|
98
98
|
top: navigationLayout.y + this.margins.top,
|
|
99
|
-
left:
|
|
99
|
+
left: this.margins.left,
|
|
100
100
|
right: navigationLayout.width - this.margins.right,
|
|
101
101
|
bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom
|
|
102
102
|
}
|
|
@@ -84,12 +84,7 @@ const getComputedStyle = (config = []) => {
|
|
|
84
84
|
return wrapFn((nodeInstance, resolve) => {
|
|
85
85
|
config = new Set(config)
|
|
86
86
|
const res = {}
|
|
87
|
-
const
|
|
88
|
-
const defaultStyle = nodeInstance.instance.defaultStyle || {}
|
|
89
|
-
const computedStyle = {
|
|
90
|
-
...defaultStyle,
|
|
91
|
-
...styles
|
|
92
|
-
}
|
|
87
|
+
const computedStyle = nodeInstance.instance.style || {}
|
|
93
88
|
config.forEach((key) => {
|
|
94
89
|
const humpKey = dash2hump(key)
|
|
95
90
|
// 取 style 的 key 是根据传入的 key 来设置,传什么设置什么 key,只不过取值需要做兼容
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
import { Image } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const previewImage = envError('previewImage')
|
|
5
|
+
|
|
6
|
+
const compressImage = envError('compressImage')
|
|
7
|
+
|
|
8
|
+
const getImageInfo = function (options = {}) {
|
|
9
|
+
const { src, success, fail, complete } = options
|
|
10
|
+
if (src === undefined) {
|
|
11
|
+
const result = {
|
|
12
|
+
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
|
|
13
|
+
errno: 1001
|
|
14
|
+
}
|
|
15
|
+
failHandle(result, fail, complete)
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
if (src === '') {
|
|
19
|
+
const result = {
|
|
20
|
+
errMsg: 'getImageInfo:fail image not found'
|
|
21
|
+
}
|
|
22
|
+
failHandle(result, fail, complete)
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
Image.getSize(src, (width, height) => {
|
|
26
|
+
const result = {
|
|
27
|
+
errMsg: 'getImageInfo:ok',
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
30
|
+
}
|
|
31
|
+
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
|
|
32
|
+
successHandle(result, success, complete)
|
|
33
|
+
}, (err) => {
|
|
34
|
+
const result = {
|
|
35
|
+
errMsg: 'getImageInfo:fail download image fail. reason: ' + err
|
|
36
|
+
}
|
|
37
|
+
failHandle(result, fail, complete)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
previewImage,
|
|
43
|
+
compressImage,
|
|
44
|
+
getImageInfo
|
|
45
|
+
}
|
|
@@ -4,7 +4,10 @@ const previewImage = ENV_OBJ.previewImage || envError('previewImage')
|
|
|
4
4
|
|
|
5
5
|
const compressImage = ENV_OBJ.compressImage || envError('compressImage')
|
|
6
6
|
|
|
7
|
+
const getImageInfo = ENV_OBJ.getImageInfo || envError('getImageInfo')
|
|
8
|
+
|
|
7
9
|
export {
|
|
8
10
|
previewImage,
|
|
9
|
-
compressImage
|
|
11
|
+
compressImage,
|
|
12
|
+
getImageInfo
|
|
10
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Preview from './Preview'
|
|
2
|
-
import { isBrowser, throwSSRWarning, envError } from '../../../common/js'
|
|
2
|
+
import { isBrowser, throwSSRWarning, envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
|
|
4
4
|
let preview = null
|
|
5
5
|
|
|
@@ -15,9 +15,53 @@ const previewImage = (options) => {
|
|
|
15
15
|
if (!preview) preview = new Preview()
|
|
16
16
|
preview.show(options)
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
const compressImage = envError('compressImage')
|
|
19
20
|
|
|
21
|
+
const getImageInfo = function (options = {}) {
|
|
22
|
+
const { src, success, fail, complete } = options
|
|
23
|
+
|
|
24
|
+
if (src === undefined) {
|
|
25
|
+
const result = {
|
|
26
|
+
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
|
|
27
|
+
errno: 1001
|
|
28
|
+
}
|
|
29
|
+
failHandle(result, fail, complete)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
if (src === '') {
|
|
33
|
+
const result = {
|
|
34
|
+
errMsg: 'getImageInfo:fail image not found'
|
|
35
|
+
}
|
|
36
|
+
failHandle(result, fail, complete)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const img = new Image()
|
|
41
|
+
img.src = src
|
|
42
|
+
|
|
43
|
+
img.onload = function () {
|
|
44
|
+
const width = img.width
|
|
45
|
+
const height = img.height
|
|
46
|
+
const result = {
|
|
47
|
+
errMsg: 'getImageInfo:ok',
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
}
|
|
51
|
+
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
|
|
52
|
+
successHandle(result, success, complete)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
img.onerror = function () {
|
|
56
|
+
const result = {
|
|
57
|
+
errMsg: 'getImageInfo:fail download image fail. '
|
|
58
|
+
}
|
|
59
|
+
failHandle(result, fail, complete)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
20
63
|
export {
|
|
21
64
|
previewImage,
|
|
22
|
-
compressImage
|
|
65
|
+
compressImage,
|
|
66
|
+
getImageInfo
|
|
23
67
|
}
|
|
@@ -17,7 +17,7 @@ const showModal = function (options = {}) {
|
|
|
17
17
|
fail,
|
|
18
18
|
complete
|
|
19
19
|
} = options
|
|
20
|
-
const modalWidth = width
|
|
20
|
+
const modalWidth = width * 0.8
|
|
21
21
|
const styles = StyleSheet.create({
|
|
22
22
|
modalTask: {
|
|
23
23
|
left: 0,
|
|
@@ -53,7 +53,8 @@ const showModal = function (options = {}) {
|
|
|
53
53
|
lineHeight: 26,
|
|
54
54
|
color: '#808080',
|
|
55
55
|
paddingLeft: 20,
|
|
56
|
-
paddingRight: 20
|
|
56
|
+
paddingRight: 20,
|
|
57
|
+
textAlign: 'center'
|
|
57
58
|
},
|
|
58
59
|
modalBtnBox: {
|
|
59
60
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
@@ -67,8 +68,8 @@ const showModal = function (options = {}) {
|
|
|
67
68
|
modalBtn: {
|
|
68
69
|
flex: 1,
|
|
69
70
|
textAlign: 'center',
|
|
70
|
-
paddingTop:
|
|
71
|
-
paddingBottom:
|
|
71
|
+
paddingTop: width * 0.04,
|
|
72
|
+
paddingBottom: width * 0.04,
|
|
72
73
|
},
|
|
73
74
|
modalButton: {
|
|
74
75
|
width: '100%',
|
|
@@ -88,9 +89,8 @@ const showModal = function (options = {}) {
|
|
|
88
89
|
let editableContent = []
|
|
89
90
|
let modalButton = [{
|
|
90
91
|
text: confirmText,
|
|
91
|
-
confirmColor,
|
|
92
92
|
type: 'confirm',
|
|
93
|
-
color:
|
|
93
|
+
color: confirmColor
|
|
94
94
|
}]
|
|
95
95
|
let contentText = content
|
|
96
96
|
const onChangeText = function (text) {
|
|
@@ -128,10 +128,9 @@ const showModal = function (options = {}) {
|
|
|
128
128
|
if (showCancel) {
|
|
129
129
|
modalButton.unshift({
|
|
130
130
|
text: cancelText,
|
|
131
|
-
cancelColor,
|
|
132
131
|
type: 'cancel',
|
|
133
132
|
style: styles.cancelStyle,
|
|
134
|
-
color:
|
|
133
|
+
color: cancelColor
|
|
135
134
|
})
|
|
136
135
|
}
|
|
137
136
|
ModalView = <View style={styles.modalTask}>
|
|
@@ -107,10 +107,9 @@ function request (options = { url: '' }) {
|
|
|
107
107
|
errMsg: `request:fail ${err}`,
|
|
108
108
|
statusCode: response.status,
|
|
109
109
|
header: response.headers,
|
|
110
|
-
data: response.data
|
|
111
|
-
stack: realError.stack,
|
|
112
|
-
...realError
|
|
110
|
+
data: response.data
|
|
113
111
|
}
|
|
112
|
+
Object.assign(res, realError)
|
|
114
113
|
failHandle(res, fail, complete)
|
|
115
114
|
})
|
|
116
115
|
|
|
@@ -17,7 +17,12 @@ function setNavigationBarColor (options = {}) {
|
|
|
17
17
|
return ENV_OBJ.setNavigationBar(options)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function hideHomeButton (options = {}) {
|
|
21
|
+
return ENV_OBJ.hideBackHome(options)
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
export {
|
|
21
25
|
setNavigationBarTitle,
|
|
22
|
-
setNavigationBarColor
|
|
26
|
+
setNavigationBarColor,
|
|
27
|
+
hideHomeButton
|
|
23
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
|
|
1
|
+
import { successHandle, failHandle, getFocusedNavigation, envError } from '../../../common/js'
|
|
2
2
|
import { nextTick } from '../next-tick'
|
|
3
3
|
function setNavigationBarTitle (options = {}) {
|
|
4
4
|
const { title = '', success, fail, complete } = options
|
|
@@ -7,7 +7,7 @@ function setNavigationBarTitle (options = {}) {
|
|
|
7
7
|
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
|
|
8
8
|
} else {
|
|
9
9
|
nextTick(() => {
|
|
10
|
-
navigation.setOptions({
|
|
10
|
+
navigation.setOptions({ title })
|
|
11
11
|
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
12
12
|
})
|
|
13
13
|
}
|
|
@@ -31,7 +31,10 @@ function setNavigationBarColor (options = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const hideHomeButton = envError('hideHomeButton')
|
|
35
|
+
|
|
34
36
|
export {
|
|
35
37
|
setNavigationBarTitle,
|
|
36
|
-
setNavigationBarColor
|
|
38
|
+
setNavigationBarColor,
|
|
39
|
+
hideHomeButton
|
|
37
40
|
}
|
|
@@ -4,7 +4,10 @@ const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavi
|
|
|
4
4
|
|
|
5
5
|
const setNavigationBarColor = ENV_OBJ.setNavigationBarColor || envError('setNavigationBarColor')
|
|
6
6
|
|
|
7
|
+
const hideHomeButton = ENV_OBJ.hideHomeButton || envError('hideHomeButton')
|
|
8
|
+
|
|
7
9
|
export {
|
|
8
10
|
setNavigationBarTitle,
|
|
9
|
-
setNavigationBarColor
|
|
11
|
+
setNavigationBarColor,
|
|
12
|
+
hideHomeButton
|
|
10
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
1
|
+
import { isBrowser, envError, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setNavigationBarTitle (options = {}) {
|
|
4
4
|
if (!isBrowser) {
|
|
@@ -26,7 +26,10 @@ function setNavigationBarColor (options = {}) {
|
|
|
26
26
|
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const hideHomeButton = envError('hideHomeButton')
|
|
30
|
+
|
|
29
31
|
export {
|
|
30
32
|
setNavigationBarTitle,
|
|
31
|
-
setNavigationBarColor
|
|
33
|
+
setNavigationBarColor,
|
|
34
|
+
hideHomeButton
|
|
32
35
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ENV_OBJ, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const getSetting = ENV_OBJ.getSetting || envError('getSetting')
|
|
4
|
+
|
|
5
|
+
const openSetting = ENV_OBJ.openSetting || envError('openSetting')
|
|
6
|
+
|
|
7
|
+
const enableAlertBeforeUnload = ENV_OBJ.enableAlertBeforeUnload || envError('enableAlertBeforeUnload')
|
|
8
|
+
|
|
9
|
+
const disableAlertBeforeUnload = ENV_OBJ.disableAlertBeforeUnload || envError('disableAlertBeforeUnload')
|
|
10
|
+
|
|
11
|
+
const getMenuButtonBoundingClientRect = ENV_OBJ.getMenuButtonBoundingClientRect || envError('getMenuButtonBoundingClientRect')
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
getSetting,
|
|
15
|
+
openSetting,
|
|
16
|
+
enableAlertBeforeUnload,
|
|
17
|
+
disableAlertBeforeUnload,
|
|
18
|
+
getMenuButtonBoundingClientRect
|
|
19
|
+
}
|
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
import DeviceInfo from 'react-native-device-info'
|
|
2
|
+
import { PixelRatio } from 'react-native'
|
|
3
|
+
import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
|
|
4
|
+
import { getWindowInfo, getLaunchOptionsSync, getEnterOptionsSync } from './rnSystem'
|
|
5
|
+
|
|
6
|
+
const getSystemInfoSync = function () {
|
|
7
|
+
const windowInfo = getWindowInfo()
|
|
8
|
+
const { screenWidth, screenHeight } = windowInfo
|
|
9
|
+
|
|
10
|
+
const result = {
|
|
11
|
+
brand: DeviceInfo.getBrand(),
|
|
12
|
+
model: DeviceInfo.getModel(),
|
|
13
|
+
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
14
|
+
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
15
|
+
deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape',
|
|
16
|
+
fontSizeSetting: PixelRatio.getFontScale()
|
|
17
|
+
}
|
|
18
|
+
Object.assign(result, windowInfo)
|
|
19
|
+
defineUnsupportedProps(result, [
|
|
20
|
+
'language',
|
|
21
|
+
'version',
|
|
22
|
+
'SDKVersion',
|
|
23
|
+
'benchmarkLevel',
|
|
24
|
+
'albumAuthorized',
|
|
25
|
+
'cameraAuthorized',
|
|
26
|
+
'locationAuthorized',
|
|
27
|
+
'microphoneAuthorized',
|
|
28
|
+
'notificationAuthorized',
|
|
29
|
+
'phoneCalendarAuthorized',
|
|
30
|
+
'host',
|
|
31
|
+
'enableDebug',
|
|
32
|
+
'notificationAlertAuthorized',
|
|
33
|
+
'notificationBadgeAuthorized',
|
|
34
|
+
'notificationSoundAuthorized',
|
|
35
|
+
'bluetoothEnabled',
|
|
36
|
+
'locationEnabled',
|
|
37
|
+
'wifiEnabled',
|
|
38
|
+
'locationReducedAccuracy',
|
|
39
|
+
'theme'
|
|
40
|
+
])
|
|
41
|
+
return result
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const getSystemInfo = function (options = {}) {
|
|
45
|
+
const { success, fail, complete } = options
|
|
46
|
+
try {
|
|
47
|
+
const systemInfo = getSystemInfoSync()
|
|
48
|
+
Object.assign(systemInfo, {
|
|
49
|
+
errMsg: 'setStorage:ok'
|
|
50
|
+
})
|
|
51
|
+
successHandle(systemInfo, success, complete)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const result = {
|
|
54
|
+
errMsg: `getSystemInfo:fail ${err}`
|
|
55
|
+
}
|
|
56
|
+
failHandle(result, fail, complete)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getDeviceInfo = function () {
|
|
61
|
+
const deviceInfo = {}
|
|
62
|
+
if (__mpx_mode__ === 'android') {
|
|
63
|
+
const deviceAbi = DeviceInfo.supported64BitAbisSync() || []
|
|
64
|
+
deviceInfo.deviceAbi = deviceAbi[0] || null
|
|
65
|
+
}
|
|
66
|
+
defineUnsupportedProps(deviceInfo, ['benchmarkLevel', 'abi', 'cpuType'])
|
|
67
|
+
Object.assign(deviceInfo, {
|
|
68
|
+
brand: DeviceInfo.getBrand(),
|
|
69
|
+
model: DeviceInfo.getModel(),
|
|
70
|
+
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
71
|
+
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
72
|
+
memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024)
|
|
73
|
+
})
|
|
74
|
+
return deviceInfo
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
getSystemInfo,
|
|
79
|
+
getSystemInfoSync,
|
|
80
|
+
getDeviceInfo,
|
|
81
|
+
getWindowInfo,
|
|
82
|
+
getLaunchOptionsSync,
|
|
83
|
+
getEnterOptionsSync
|
|
84
|
+
}
|
|
@@ -1,78 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getWindowInfo } from './rnWindowInfo'
|
|
1
|
+
import { PixelRatio, Dimensions } from 'react-native'
|
|
2
|
+
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
3
|
+
import { getFocusedNavigation } from '../../../common/js'
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
defineUnsupportedProps(result, [
|
|
21
|
-
'language',
|
|
22
|
-
'version',
|
|
23
|
-
'SDKVersion',
|
|
24
|
-
'benchmarkLevel',
|
|
25
|
-
'albumAuthorized',
|
|
26
|
-
'cameraAuthorized',
|
|
27
|
-
'locationAuthorized',
|
|
28
|
-
'microphoneAuthorized',
|
|
29
|
-
'notificationAuthorized',
|
|
30
|
-
'phoneCalendarAuthorized',
|
|
31
|
-
'host',
|
|
32
|
-
'enableDebug',
|
|
33
|
-
'notificationAlertAuthorized',
|
|
34
|
-
'notificationBadgeAuthorized',
|
|
35
|
-
'notificationSoundAuthorized',
|
|
36
|
-
'bluetoothEnabled',
|
|
37
|
-
'locationEnabled',
|
|
38
|
-
'wifiEnabled',
|
|
39
|
-
'locationReducedAccuracy',
|
|
40
|
-
'theme'
|
|
41
|
-
])
|
|
42
|
-
return result
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getSystemInfo = function (options = {}) {
|
|
46
|
-
const { success, fail, complete } = options
|
|
5
|
+
const getWindowInfo = function () {
|
|
6
|
+
const dimensionsScreen = Dimensions.get('screen')
|
|
7
|
+
const navigation = getFocusedNavigation() || {}
|
|
8
|
+
const initialWindowMetricsInset = initialWindowMetrics?.insets || {}
|
|
9
|
+
const navigationInsets = navigation.insets || {}
|
|
10
|
+
const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
|
|
11
|
+
let safeArea = {}
|
|
12
|
+
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
|
|
13
|
+
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
|
|
14
|
+
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
|
|
15
|
+
const layout = navigation.layout || {}
|
|
16
|
+
const layoutHeight = layout.height || 0
|
|
17
|
+
const layoutWidth = layout.width || 0
|
|
18
|
+
const windowHeight = layoutHeight || screenHeight
|
|
47
19
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
errMsg: `getSystemInfo:fail ${err}`
|
|
20
|
+
safeArea = {
|
|
21
|
+
left,
|
|
22
|
+
right: screenWidth - right,
|
|
23
|
+
top,
|
|
24
|
+
bottom: screenHeight - bottom,
|
|
25
|
+
height: screenHeight - top - bottom,
|
|
26
|
+
width: screenWidth - left - right
|
|
56
27
|
}
|
|
57
|
-
|
|
28
|
+
} catch (error) {
|
|
58
29
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
30
|
+
const result = {
|
|
31
|
+
pixelRatio: PixelRatio.get(),
|
|
32
|
+
windowWidth: layoutWidth || screenWidth,
|
|
33
|
+
windowHeight, // 取不到layout的时候有个兜底
|
|
34
|
+
screenWidth: screenWidth,
|
|
35
|
+
screenHeight: screenHeight,
|
|
36
|
+
screenTop: screenHeight - windowHeight,
|
|
37
|
+
statusBarHeight: safeArea.top,
|
|
38
|
+
safeArea
|
|
66
39
|
}
|
|
67
|
-
|
|
68
|
-
Object.assign(deviceInfo, {
|
|
69
|
-
brand: DeviceInfo.getBrand(),
|
|
70
|
-
model: DeviceInfo.getModel(),
|
|
71
|
-
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
72
|
-
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
73
|
-
memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024)
|
|
74
|
-
})
|
|
75
|
-
return deviceInfo
|
|
40
|
+
return result
|
|
76
41
|
}
|
|
77
42
|
|
|
78
43
|
const getLaunchOptionsSync = function () {
|
|
@@ -91,9 +56,6 @@ const getEnterOptionsSync = function () {
|
|
|
91
56
|
}
|
|
92
57
|
|
|
93
58
|
export {
|
|
94
|
-
getSystemInfo,
|
|
95
|
-
getSystemInfoSync,
|
|
96
|
-
getDeviceInfo,
|
|
97
59
|
getWindowInfo,
|
|
98
60
|
getLaunchOptionsSync,
|
|
99
61
|
getEnterOptionsSync
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
|
|
1
|
+
import { View, Text, Image, StyleSheet, ActivityIndicator, Dimensions } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
import { Portal } from '@ant-design/react-native'
|
|
4
4
|
|
|
5
5
|
let toastKey
|
|
6
6
|
let isLoadingShow
|
|
7
|
+
const dimensionsScreen = Dimensions.get('screen')
|
|
8
|
+
const screenHeight = dimensionsScreen.height
|
|
9
|
+
const contentTop = parseInt(screenHeight * 0.35)
|
|
7
10
|
let tId // show duration 计时id
|
|
8
11
|
const styles = StyleSheet.create({
|
|
9
12
|
toastContent: {
|
|
10
|
-
minWdth: 150,
|
|
11
13
|
maxWidth: '60%',
|
|
12
14
|
backgroundColor: 'rgba(20, 20, 20, 0.7)',
|
|
13
15
|
paddingTop: 15,
|
|
@@ -18,7 +20,8 @@ const styles = StyleSheet.create({
|
|
|
18
20
|
display: 'flex',
|
|
19
21
|
flexDirection: 'column',
|
|
20
22
|
justifyContent: 'center',
|
|
21
|
-
alignItems: 'center'
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
marginTop: contentTop // 小程序里面展示偏上一点
|
|
22
25
|
},
|
|
23
26
|
toastWrap: {
|
|
24
27
|
left: 0,
|
|
@@ -28,25 +31,29 @@ const styles = StyleSheet.create({
|
|
|
28
31
|
zIndex: 10000,
|
|
29
32
|
position: "absolute",
|
|
30
33
|
display: 'flex',
|
|
31
|
-
justifyContent: 'center',
|
|
32
34
|
alignItems: 'center'
|
|
33
35
|
},
|
|
36
|
+
toastHasIcon: {
|
|
37
|
+
height: 110,
|
|
38
|
+
width: 120
|
|
39
|
+
},
|
|
34
40
|
toastImg: {
|
|
35
41
|
width: 40,
|
|
36
42
|
height: 40,
|
|
37
43
|
marginLeft: 'auto',
|
|
38
|
-
marginRight: 'auto'
|
|
39
|
-
marginBottom: 10
|
|
44
|
+
marginRight: 'auto'
|
|
40
45
|
},
|
|
41
46
|
toastText: {
|
|
42
47
|
textAlign: 'center',
|
|
43
48
|
color: '#ffffff',
|
|
44
|
-
fontSize:
|
|
49
|
+
fontSize: 12,
|
|
45
50
|
lineHeight: 18,
|
|
46
51
|
height: 18,
|
|
47
|
-
overflow: 'hidden'
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
marginTop: 10
|
|
48
54
|
}
|
|
49
55
|
})
|
|
56
|
+
|
|
50
57
|
function showToast (options = {}) {
|
|
51
58
|
const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
|
|
52
59
|
let ToastView
|
|
@@ -64,29 +71,29 @@ function showToast (options = {}) {
|
|
|
64
71
|
tId = null
|
|
65
72
|
if (image || icon === 'success' || icon === 'error') {
|
|
66
73
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
67
|
-
<View style={styles.toastContent}>
|
|
74
|
+
<View style={[styles.toastContent, styles.toastHasIcon]}>
|
|
68
75
|
<Image style={ styles.toastImg } source={{uri: image || iconImg[icon]}}></Image>
|
|
69
|
-
<Text style={styles.toastText}>{title}</Text>
|
|
76
|
+
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
70
77
|
</View>
|
|
71
78
|
</View>
|
|
72
79
|
} else if (icon === 'loading') {
|
|
73
80
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
74
|
-
<View style={styles.toastContent}>
|
|
81
|
+
<View style={[styles.toastContent, styles.toastHasIcon]}>
|
|
75
82
|
<ActivityIndicator
|
|
76
83
|
animating
|
|
77
|
-
style={{ marginBottom: 10 }}
|
|
78
84
|
size='small'
|
|
79
85
|
color='#eee'
|
|
80
86
|
/>
|
|
81
|
-
<Text style={styles.toastText}>{title}</Text>
|
|
87
|
+
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
82
88
|
</View>
|
|
83
89
|
</View>
|
|
84
90
|
} else {
|
|
85
91
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
86
92
|
<View style={styles.toastContent}>
|
|
87
|
-
<Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
|
|
88
|
-
height:
|
|
89
|
-
|
|
93
|
+
{ title ? <Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
|
|
94
|
+
height: 'auto',
|
|
95
|
+
marginTop: 0
|
|
96
|
+
} : {}) }}>{title}</Text> : null }
|
|
90
97
|
</View>
|
|
91
98
|
</View>
|
|
92
99
|
}
|
package/src/platform/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export * from './api/file'
|
|
|
43
43
|
// getUserInfo
|
|
44
44
|
export * from './api/get-user-info'
|
|
45
45
|
|
|
46
|
-
// previewImage, compressImage
|
|
46
|
+
// previewImage, compressImage, getImageInfo
|
|
47
47
|
export * from './api/image'
|
|
48
48
|
|
|
49
49
|
// login
|
|
@@ -116,3 +116,6 @@ export * from './api/vibrate'
|
|
|
116
116
|
|
|
117
117
|
// onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard
|
|
118
118
|
export * from './api/keyboard'
|
|
119
|
+
|
|
120
|
+
// getSetting, openSetting, enableAlertBeforeUnload, disableAlertBeforeUnload, getMenuButtonBoundingClientRect
|
|
121
|
+
export * from './api/setting'
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { PixelRatio, Dimensions } from 'react-native'
|
|
2
|
-
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
3
|
-
import { getFocusedNavigation } from '../../../common/js'
|
|
4
|
-
|
|
5
|
-
const getWindowInfo = function () {
|
|
6
|
-
const dimensionsScreen = Dimensions.get('screen')
|
|
7
|
-
const navigation = getFocusedNavigation()
|
|
8
|
-
const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets)
|
|
9
|
-
let safeArea = {}
|
|
10
|
-
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
|
|
11
|
-
const screenHeight = dimensionsScreen.height
|
|
12
|
-
const screenWidth = dimensionsScreen.width
|
|
13
|
-
const layout = navigation?.layout || {}
|
|
14
|
-
const layoutHeight = layout.height || 0
|
|
15
|
-
const layoutWidth = layout.width || 0
|
|
16
|
-
const windowHeight = layoutHeight || screenHeight
|
|
17
|
-
try {
|
|
18
|
-
safeArea = {
|
|
19
|
-
left,
|
|
20
|
-
right: screenWidth - right,
|
|
21
|
-
top,
|
|
22
|
-
bottom: screenHeight - bottom,
|
|
23
|
-
height: screenHeight - top - bottom,
|
|
24
|
-
width: screenWidth - left - right
|
|
25
|
-
}
|
|
26
|
-
} catch (error) {
|
|
27
|
-
}
|
|
28
|
-
const result = {
|
|
29
|
-
pixelRatio: PixelRatio.get(),
|
|
30
|
-
windowWidth: layoutWidth || screenWidth,
|
|
31
|
-
windowHeight, // 取不到layout的时候有个兜底
|
|
32
|
-
screenWidth: screenWidth,
|
|
33
|
-
screenHeight: screenHeight,
|
|
34
|
-
screenTop: screenHeight - windowHeight,
|
|
35
|
-
safeArea
|
|
36
|
-
}
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
getWindowInfo
|
|
42
|
-
}
|