-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not work with react navigation stack pakage #29
Comments
same issues |
Hello all, until either I get around to it or the maintainer does, you can use this little snippet to convert your react-navigation-stack@~1 import createStackNavigator from 'react-navigation-stack'
import { fromRight } from 'react-navigation-transitions'
const transition = fromRight() // Or whichever you prefer
const config = {
animation: 'timing',
config: transition.transitionSpec
}
const cardStyleInterpolator = ({ current, next, index, closing, layouts }) => {
const { progress } = closing._value ? next : current
const { width, height } = layouts.screen
const containerStyle = transition.screenInterpolator({
layout: {
initWidth: width,
initHeight: height
},
position: progress,
scene: { index: 1 }
})
return { containerStyle }
}
// Usage
const Nav = createStackNavigator(
{
Home: HomeScreen
},
{
defaultNavigationOptions: {
transitionSpec: {
open: config,
close: config
},
cardStyleInterpolator
},
initialRouteName: 'Home'
}
) Bear in mind, I've only given it a quick try with:
so YMMV. I couldn't immediately get it working with The new docs for the Transition API are super confusing for me so may be some time before I get around to this. |
import {
NavigationStackConfig,
NavigationStackOptions,
NavigationStackProp,
TransitionPresets,
} from 'react-navigation-stack'
import { CreateNavigatorConfig, NavigationStackRouterConfig, NavigationRoute } from 'react-navigation'
const StackConfig: CreateNavigatorConfig<
NavigationStackConfig,
NavigationStackRouterConfig,
NavigationStackOptions,
NavigationStackProp<NavigationRoute, any>
> = {
// 跨页面共享通用的navigationOptions
defaultNavigationOptions: {
headerStyle: {
backgroundColor: '#ffffff',
}, // 一个应用于 header 的最外层 View 的 样式对象
headerTintColor: '#000000', // 返回按钮和标题都使用这个属性作为它们的颜色
headerTitleStyle: {
fontWeight: 'bold',
},
headerBackTitleVisible: false,
headerTitleAlign: 'center',
...TransitionPresets.SlideFromRightIOS, // add this line
cardStyle: {
backgroundColor: '#f5f5f9',
},
},
}
export default StackConfig |
Oh fantastic! I'll give that a go and also remove this package, one less dependency! EDIT: Worked great, thanks again! |
But they dont have the flipY and flipX though so its not 100% replaced |
in the last version of react navigation createStackNavigator import from react-navigation-stack and its not match with react-navigation-transitions
The text was updated successfully, but these errors were encountered: