Skip to content

Commit

Permalink
合并fix actionsheet和webview改动逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcuijuan committed Jan 9, 2025
2 parents 6a3b10c + 411f00d commit 2feeb9b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import Animated, {

function showActionSheet (options = {}) {
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
if (itemList.length > 6) {
const result = {
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
}
failHandle(result, fail, complete)
return
}
const windowInfo = getWindowInfo()
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
let actionSheetKey = null
Expand Down
2 changes: 1 addition & 1 deletion packages/api-proxy/src/platform/api/toast/rnToast.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let toastKey
let isLoadingShow
const dimensionsScreen = Dimensions.get('screen')
const screenHeight = dimensionsScreen.height
const contentTop = parseInt(screenHeight * 0.35)
const contentTop = parseInt(screenHeight * 0.4)
let tId // show duration 计时id
const styles = StyleSheet.create({
toastContent: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ const PortalHost = ({ children } :PortalHostProps): JSX.Element => {
}

const _unmount = (key: number, curPageId?: number) => {
const navigation = getFocusedNavigation()
const pageId = navigation?.pageId
if (pageId && pageId !== (curPageId ?? currentPageId)) { // 过滤掉获取不到pageid的情况,这样避免删不掉的情况
return
}
if (manager.current) {
manager.current.unmount(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
bottom: 0 as number
}
const canGoBack = useRef<boolean>(false)
const isNavigateBack = useRef<boolean>(false)

const onAndroidBackPress = useCallback(() => {
if (canGoBack.current) {
Expand All @@ -117,10 +118,11 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
}, [canGoBack])

const beforeRemoveHandle = useCallback((e: Event) => {
if (canGoBack.current) {
if (canGoBack.current && !isNavigateBack.current) {
webViewRef.current?.goBack()
e.preventDefault()
}
isNavigateBack.current = false
}, [canGoBack])

const navigation = useNavigation()
Expand Down Expand Up @@ -157,7 +159,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
src: res.nativeEvent?.url
}
}
bindload(result)
bindload && bindload(result)
}
const _error = function (res: WebViewErrorEvent) {
setPageLoadErr(true)
Expand Down Expand Up @@ -200,6 +202,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
}
true;
`

const sendMessage = function (params: string) {
return `
window.mpxWebviewMessageCallback(${params})
Expand Down Expand Up @@ -255,6 +258,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
asyncCallback = navObj.navigateTo(...params)
break
case 'navigateBack':
isNavigateBack.current = true
asyncCallback = navObj.navigateBack(...params)
break
case 'redirectTo':
Expand Down

0 comments on commit 2feeb9b

Please sign in to comment.