Skip to content

Commit

Permalink
feat(rn): revert redirect animate
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen committed Mar 13, 2024
1 parent 2946064 commit 6c76218
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
4 changes: 1 addition & 3 deletions packages/taro-router-rn/src/rootNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NavigationContainerRef, StackActions } from '@react-navigation/native'
import { camelCase } from 'lodash'
import * as React from 'react'

import { getTabBarPages, handleUrl, setTabInitRoute, updateCurrentJumpUrl, updateJumpAnimate } from './utils/index'
import { getTabBarPages, handleUrl, setTabInitRoute, updateCurrentJumpUrl } from './utils/index'
import { BaseOption, CallbackResult } from './utils/types'


Expand Down Expand Up @@ -56,12 +56,10 @@ export function navigate (option: NavigateOption | NavigateBackOption, method: N
routeParam = handleUrl(path)
updateCurrentJumpUrl(path)
}
updateJumpAnimate(true)
try {
if (method === 'navigateTo') {
navigationRef.current?.dispatch(StackActions.push(routeParam.pageName, routeParam.params))
} else if (method === 'redirectTo') {
updateJumpAnimate(false)
navigationRef.current?.dispatch(StackActions.replace(routeParam.pageName, routeParam.params))
} else if (method === 'switchTab' || (method === 'reLaunch' && isTabPage(path))) {
const states = navigationRef.current?.getRootState()
Expand Down
14 changes: 3 additions & 11 deletions packages/taro-router-rn/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react'
import { StyleProp, ViewStyle } from 'react-native'

import { navigationRef } from './rootNavigation'
import { getCurrentJumpUrl, getTabInitRoute, getTabItemConfig, getTabVisible, handleUrl, hasJumpAnimate, setTabConfig } from './utils/index'
import { getCurrentJumpUrl, getTabInitRoute, getTabItemConfig, getTabVisible, handleUrl, setTabConfig } from './utils/index'
import BackButton from './view/BackButton'
import HeadTitle from './view/HeadTitle'
import CustomTabBar from './view/TabBar'
Expand Down Expand Up @@ -407,11 +407,7 @@ function createTabNavigate (config: RouterConfig, options: RouterOption) {
detachInactiveScreens={false}
{...stackProps}
// @ts-ignore
screenOptions={() => ({
...screenOptions,
animation: hasJumpAnimate() ? 'default' : 'none',
animationEnabled: !!hasJumpAnimate()
})}
screenOptions={screenOptions}
initialRouteName={getInitRouteName(config)}
>
<Stack.Screen
Expand Down Expand Up @@ -451,11 +447,7 @@ function createStackNavigate (config: RouterConfig, options:RouterOption) {
detachInactiveScreens={false}
{...stackProps}
// @ts-ignore
screenOptions={() => ({
...screenOptions,
animation: hasJumpAnimate() ? 'default' : 'none',
animationEnabled: !!hasJumpAnimate()
})}
screenOptions={screenOptions}
initialRouteName={getInitRouteName(config)}
>{pageList.map(item => {
const initParams = getInitParams(config, item.name)
Expand Down
11 changes: 0 additions & 11 deletions packages/taro-router-rn/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,6 @@ export function handleUrl (url: string): Record<string, any> {
}
}

export function hasJumpAnimate () :boolean{
if (globalAny.__taroJumpAnimate === false){
return false
}
return true
}

export function updateJumpAnimate (needAnimate: boolean){
globalAny.__taroJumpAnimate = needAnimate
}

export function updateCurrentJumpUrl (path: string){
globalAny.__taroJumpUrl = path
}
Expand Down

0 comments on commit 6c76218

Please sign in to comment.