Traviskn / react-navigation-slide-from-right-transition

A slide-from-right transition config for use with react navigation's stack navigator on android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

targeted only android

b-asaf opened this issue · comments

Hi,
how did you used the default transition in iOS while using the custom transition in Android?

You can use the Platform module from react native to execute code conditionally based on whether the operating system is Android or iOS. There's many possible ways to do it, this is one example to only pass the custom transition config on Android, and just use the default on iOS:

import { Platform } from 'react-native';
import { StackNavigator } from 'react-navigation';
import getSlideFromRightTransition from 'react-navigation-slide-from-right-transition';

/* ... your react component code here ... */
const screens = {
  Home: {
    screen: MyHomeScreen
  },
  Profile: {
    path: 'people/:name',
    screen: MyProfileScreen,
  },
};
const SimpleStack = Platform.OS === 'android'
  ? StackNavigator(screens, { transitionConfig: getSlideFromRightTransition });
  : StackNavigator(screens);

I guess I was not clear in my question.
I have multiple stacks so I don't want write in all of my stacks the following code:

const SimpleStack = Platform.OS === 'android'
  ? StackNavigator(screens, { transitionConfig: getSlideFromRightTransition });
  : StackNavigator(screens);

How, can this be done inside 'react-navigation-slide-from-right-transition'?

I actually just copy-pasted the iOS default transition from react-navigation and used it here in this library. So really, if you pass in the transition config from this library to your stack navigator on iOS it should look exactly the same as the default iOS transition, you shouldn't have to do anything special.