@mpxjs/api-proxy 2.10.1-beta.1 → 2.10.1-beta.10
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/package.json +1 -1
- package/src/common/js/promisify.js +1 -2
- package/src/platform/api/action-sheet/rnActionSheet.jsx +18 -10
- package/src/platform/api/route/index.ios.js +2 -45
- package/src/platform/api/route/index.js +1 -7
- package/src/platform/api/route/index.web.js +2 -8
- package/src/platform/api/set-navigation-bar/index.ios.js +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
2
|
import { View, Text, StyleSheet } from 'react-native'
|
|
3
3
|
import { successHandle, failHandle, getCurrentPageId } from '../../../common/js'
|
|
4
4
|
import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/index'
|
|
@@ -7,8 +7,7 @@ import Animated, {
|
|
|
7
7
|
useSharedValue,
|
|
8
8
|
useAnimatedStyle,
|
|
9
9
|
withTiming,
|
|
10
|
-
Easing
|
|
11
|
-
runOnJS
|
|
10
|
+
Easing
|
|
12
11
|
} from 'react-native-reanimated'
|
|
13
12
|
const actionSheetMap = new Map()
|
|
14
13
|
|
|
@@ -53,8 +52,7 @@ const styles = StyleSheet.create({
|
|
|
53
52
|
position: 'absolute',
|
|
54
53
|
bottom: 0,
|
|
55
54
|
left: 0,
|
|
56
|
-
right: 0
|
|
57
|
-
paddingBottom: bottom
|
|
55
|
+
right: 0
|
|
58
56
|
},
|
|
59
57
|
itemStyle: {
|
|
60
58
|
paddingTop: 15,
|
|
@@ -72,15 +70,16 @@ const styles = StyleSheet.create({
|
|
|
72
70
|
},
|
|
73
71
|
buttonStyle: {
|
|
74
72
|
paddingTop: 10,
|
|
75
|
-
paddingBottom: 10,
|
|
76
73
|
justifyContent: 'center',
|
|
77
|
-
alignItems: 'center'
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
paddingBottom: bottom + 10
|
|
78
76
|
}
|
|
79
77
|
})
|
|
80
78
|
|
|
81
79
|
function ActionSheet ({itemColor, height, success, fail, complete, alertText, itemList}) {
|
|
82
80
|
const slide = useSharedValue(height)
|
|
83
81
|
const fade = useSharedValue(0)
|
|
82
|
+
const [selectedIndex, setSelectedIndex] = useState(null)
|
|
84
83
|
|
|
85
84
|
const actionAnimatedStyles = useAnimatedStyle(() => {
|
|
86
85
|
return {
|
|
@@ -116,6 +115,7 @@ function ActionSheet ({itemColor, height, success, fail, complete, alertText, it
|
|
|
116
115
|
tapIndex: index
|
|
117
116
|
}
|
|
118
117
|
successHandle(result, success, complete)
|
|
118
|
+
setSelectedIndex(null)
|
|
119
119
|
}
|
|
120
120
|
const cancelAction = function () {
|
|
121
121
|
removeActionSheet()
|
|
@@ -123,6 +123,10 @@ function ActionSheet ({itemColor, height, success, fail, complete, alertText, it
|
|
|
123
123
|
errMsg: 'showActionSheet:fail cancel'
|
|
124
124
|
}
|
|
125
125
|
failHandle(result, fail, complete)
|
|
126
|
+
setSelectedIndex(null)
|
|
127
|
+
}
|
|
128
|
+
const startHandle = function (index) {
|
|
129
|
+
setSelectedIndex(index)
|
|
126
130
|
}
|
|
127
131
|
return (
|
|
128
132
|
<View style={styles.actionAction}>
|
|
@@ -131,12 +135,16 @@ function ActionSheet ({itemColor, height, success, fail, complete, alertText, it
|
|
|
131
135
|
</Animated.View>
|
|
132
136
|
<Animated.View style={[styles.actionSheetContent, actionAnimatedStyles]}>
|
|
133
137
|
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
|
|
134
|
-
{ itemList.map((item, index) => <View onTouchEnd={() => selectAction(index)} key={index} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
138
|
+
{ itemList.map((item, index) => <View onTouchStart={() => startHandle(index)} onTouchEnd={() => selectAction(index)} key={index} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
135
139
|
borderBottomWidth: 6,
|
|
136
140
|
borderBottomStyle: 'solid',
|
|
137
141
|
borderBottomColor: '#f7f7f7'
|
|
142
|
+
} : {}, selectedIndex === index ? {
|
|
143
|
+
backgroundColor: '#ececec'
|
|
138
144
|
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></View>) }
|
|
139
|
-
<View style={styles.buttonStyle
|
|
145
|
+
<View style={[styles.buttonStyle, selectedIndex === -1 ? {
|
|
146
|
+
backgroundColor: '#ececec'
|
|
147
|
+
} : {}]} onTouchStart={() => startHandle(-1)} onTouchEnd={cancelAction}><Text style={{ color: "#000000", fontSize: 18, lineHeight: 22, height: 22, width: "100%", textAlign: "center" }}>取消</Text></View>
|
|
140
148
|
</Animated.View>
|
|
141
149
|
</View>
|
|
142
150
|
)
|
|
@@ -168,4 +176,4 @@ function showActionSheet (options = {}) {
|
|
|
168
176
|
|
|
169
177
|
export {
|
|
170
178
|
showActionSheet
|
|
171
|
-
}
|
|
179
|
+
}
|
|
@@ -34,7 +34,7 @@ function resolvePath (relative, base) {
|
|
|
34
34
|
return stack.join('/')
|
|
35
35
|
}
|
|
36
36
|
let timerId = null
|
|
37
|
-
function isLock (navigationHelper
|
|
37
|
+
function isLock (navigationHelper, type, options) {
|
|
38
38
|
if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
|
|
39
39
|
const res = { errMsg: `${type}:fail the previous routing event didn't complete` }
|
|
40
40
|
failHandle(res, options.fail, options.complete)
|
|
@@ -156,53 +156,10 @@ function switchTab () {
|
|
|
156
156
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
function reset (options = {}) {
|
|
160
|
-
const routes = options.routes || []
|
|
161
|
-
if (!routes.length) {
|
|
162
|
-
const res = { errMsg: 'reset:fail routes cannot be an empty array' }
|
|
163
|
-
failHandle(res, options.fail, options.complete)
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
const resetOption = Object.getOwnPropertyNames(options).reduce((resOpt, key) => {
|
|
167
|
-
if (key !== 'fail' && key !== 'complete' && key !== 'success') {
|
|
168
|
-
resOpt[key] = options[key]
|
|
169
|
-
}
|
|
170
|
-
return resOpt
|
|
171
|
-
}, {})
|
|
172
|
-
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
173
|
-
const navigationHelper = global.__navigationHelper
|
|
174
|
-
if (isLock(navigationHelper, 'reset', options)) {
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
if (navigation && navigationHelper) {
|
|
178
|
-
navigation.reset(Object.assign(resetOption, {
|
|
179
|
-
index: routes.length - 1
|
|
180
|
-
}))
|
|
181
|
-
navigationHelper.lastSuccessCallback = () => {
|
|
182
|
-
const res = { errMsg: 'reset:ok' }
|
|
183
|
-
successHandle(res, options.success, options.complete)
|
|
184
|
-
}
|
|
185
|
-
navigationHelper.lastFailCallback = (msg) => {
|
|
186
|
-
const res = { errMsg: `reset:fail ${msg}` }
|
|
187
|
-
failHandle(res, options.fail, options.complete)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function getState () {
|
|
193
|
-
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
194
|
-
if (navigation) {
|
|
195
|
-
return navigation.getState()
|
|
196
|
-
}
|
|
197
|
-
return {}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
159
|
export {
|
|
201
160
|
redirectTo,
|
|
202
161
|
navigateTo,
|
|
203
162
|
navigateBack,
|
|
204
163
|
reLaunch,
|
|
205
|
-
switchTab
|
|
206
|
-
reset,
|
|
207
|
-
getState
|
|
164
|
+
switchTab
|
|
208
165
|
}
|
|
@@ -10,16 +10,10 @@ const reLaunch = ENV_OBJ.reLaunch || envError('reLaunch')
|
|
|
10
10
|
|
|
11
11
|
const switchTab = ENV_OBJ.switchTab || envError('switchTab')
|
|
12
12
|
|
|
13
|
-
const reset = envError('reset')
|
|
14
|
-
|
|
15
|
-
const getState = envError('getState')
|
|
16
|
-
|
|
17
13
|
export {
|
|
18
14
|
redirectTo,
|
|
19
15
|
navigateTo,
|
|
20
16
|
navigateBack,
|
|
21
17
|
reLaunch,
|
|
22
|
-
switchTab
|
|
23
|
-
reset,
|
|
24
|
-
getState
|
|
18
|
+
switchTab
|
|
25
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { successHandle, failHandle, isTabBarPage, throwSSRWarning, isBrowser
|
|
1
|
+
import { successHandle, failHandle, isTabBarPage, throwSSRWarning, isBrowser } from '../../../common/js'
|
|
2
2
|
import { EventChannel } from '../event-channel'
|
|
3
3
|
|
|
4
4
|
let routeCount = 0
|
|
@@ -183,16 +183,10 @@ function switchTab (options = {}) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
const reset = envError('reset')
|
|
187
|
-
|
|
188
|
-
const getState = envError('getState')
|
|
189
|
-
|
|
190
186
|
export {
|
|
191
187
|
redirectTo,
|
|
192
188
|
navigateTo,
|
|
193
189
|
navigateBack,
|
|
194
190
|
reLaunch,
|
|
195
|
-
switchTab
|
|
196
|
-
reset,
|
|
197
|
-
getState
|
|
191
|
+
switchTab
|
|
198
192
|
}
|
|
@@ -7,7 +7,7 @@ function setNavigationBarTitle (options = {}) {
|
|
|
7
7
|
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
|
|
8
8
|
} else {
|
|
9
9
|
nextTick(() => {
|
|
10
|
-
navigation.setOptions({ title })
|
|
10
|
+
navigation.setOptions({ title: title.trim() })
|
|
11
11
|
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
12
12
|
})
|
|
13
13
|
}
|