Compare commits

..

4 Commits

Author SHA1 Message Date
Brent Vatne
f9fbffbfa0 Release 1.1.0 2018-02-19 18:15:37 -08:00
Brent Vatne
1b8422d77d Fix TabRouter to support shorthand route config 2018-02-19 18:13:22 -08:00
Brent Vatne
e27afea7ab Release 1.1.0-rc.5 2018-02-19 14:46:39 -08:00
Brent Vatne
ca6cd89118 Fix regression in modular back button 2018-02-19 14:46:25 -08:00
8 changed files with 26 additions and 57 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation",
"version": "1.1.2",
"version": "1.1.0",
"description": "Routing and navigation for your React Native apps",
"main": "src/react-navigation.js",
"repository": {
@@ -33,7 +33,7 @@
"path-to-regexp": "^1.7.0",
"prop-types": "^15.5.10",
"react-native-drawer-layout-polyfill": "^1.3.2",
"react-native-safe-area-view": "^0.7.0",
"react-native-safe-area-view": "^0.6.0",
"react-native-tab-view": "^0.0.74"
},
"devDependencies": {

View File

@@ -1,9 +1,8 @@
import {
BackAndroid as DeprecatedBackAndroid,
BackHandler as ModernBackHandler,
MaskedViewIOS,
} from 'react-native';
const BackHandler = ModernBackHandler || DeprecatedBackAndroid;
export { BackHandler, MaskedViewIOS };
export { BackHandler };

View File

@@ -1,6 +1,3 @@
import React from 'react';
import { BackHandler, View } from 'react-native';
import { BackHandler } from 'react-native';
const MaskedViewIOS = () => <View>{this.props.children}</View>;
export { BackHandler, MaskedViewIOS };
export { BackHandler };

View File

@@ -240,7 +240,7 @@ export default (routeConfigs, config = {}) => {
},
getComponentForState(state) {
const routeName = state.routes[state.index].routeName;
const routeName = order[state.index];
invariant(
routeName,
`There is no route defined for index ${state.index}. Check that

View File

@@ -85,7 +85,7 @@ class CardStack extends React.Component {
if (props.screenProps !== this.props.screenProps) {
this._screenDetails = {};
}
props.transitionProps.scenes.forEach(newScene => {
props.scenes.forEach(newScene => {
if (
this._screenDetails[newScene.key] &&
this._screenDetails[newScene.key].state !== newScene.route
@@ -96,7 +96,7 @@ class CardStack extends React.Component {
}
_getScreenDetails = scene => {
const { screenProps, transitionProps: { navigation }, router } = this.props;
const { screenProps, navigation, router } = this.props;
let screenDetails = this._screenDetails[scene.key];
if (!screenDetails || screenDetails.state !== scene.route) {
const screenNavigation = addNavigationHelpers({
@@ -131,16 +131,10 @@ class CardStack extends React.Component {
headerRightInterpolator,
} = this._getTransitionConfig();
const {
mode,
transitionProps,
prevTransitionProps,
...passProps
} = this.props;
const { mode, ...passProps } = this.props;
return renderHeader({
...passProps,
...transitionProps,
scene,
mode: headerMode,
transitionPreset: this._getHeaderTransitionPreset(),
@@ -160,22 +154,22 @@ class CardStack extends React.Component {
// when we'd do that with the current structure we have. `stopAnimation` callback
// is also broken with native animated values that have no listeners so if we
// want to remove this we have to fix this too.
animatedSubscribeValue(props.transitionProps.layout.width);
animatedSubscribeValue(props.transitionProps.layout.height);
animatedSubscribeValue(props.transitionProps.position);
animatedSubscribeValue(props.layout.width);
animatedSubscribeValue(props.layout.height);
animatedSubscribeValue(props.position);
}
_reset(resetToIndex, duration) {
Animated.timing(this.props.transitionProps.position, {
Animated.timing(this.props.position, {
toValue: resetToIndex,
duration,
easing: EaseInOut,
useNativeDriver: this.props.transitionProps.position.__isNative,
useNativeDriver: this.props.position.__isNative,
}).start();
}
_goBack(backFromIndex, duration) {
const { navigation, position, scenes } = this.props.transitionProps;
const { navigation, position, scenes } = this.props;
const toValue = Math.max(backFromIndex - 1, 0);
// set temporary index for gesture handler to respect until the action is
@@ -205,15 +199,9 @@ class CardStack extends React.Component {
let floatingHeader = null;
const headerMode = this._getHeaderMode();
if (headerMode === 'float') {
floatingHeader = this._renderHeader(
this.props.transitionProps.scene,
headerMode
);
floatingHeader = this._renderHeader(this.props.scene, headerMode);
}
const {
transitionProps: { navigation, position, layout, scene, scenes },
mode,
} = this.props;
const { navigation, position, layout, scene, scenes, mode } = this.props;
const { index } = navigation.state;
const isVertical = mode === 'modal';
const { options } = this._getScreenDetails(scene);
@@ -423,8 +411,8 @@ class CardStack extends React.Component {
return TransitionConfigs.getTransitionConfig(
this.props.transitionConfig,
this.props.transitionProps,
this.props.prevTransitionProps,
{},
{},
isModal
);
};
@@ -432,19 +420,15 @@ class CardStack extends React.Component {
_renderCard = scene => {
const { screenInterpolator } = this._getTransitionConfig();
const style =
screenInterpolator &&
screenInterpolator({ ...this.props.transitionProps, scene });
screenInterpolator && screenInterpolator({ ...this.props, scene });
const SceneComponent = this.props.router.getComponentForRouteName(
scene.route.routeName
);
const { transitionProps, ...props } = this.props;
return (
<Card
{...props}
{...transitionProps}
{...this.props}
key={`card_${scene.key}`}
style={[style, this.props.cardStyle]}
scene={scene}

View File

@@ -53,7 +53,7 @@ class CardStackTransitioner extends React.Component {
return transitionSpec;
};
_render = (props, prevProps) => {
_render = props => {
const {
screenProps,
headerMode,
@@ -72,8 +72,7 @@ class CardStackTransitioner extends React.Component {
router={router}
cardStyle={cardStyle}
transitionConfig={transitionConfig}
transitionProps={props}
prevTransitionProps={prevProps}
{...props}
/>
);
};

View File

@@ -6,10 +6,10 @@ import {
Image,
Platform,
StyleSheet,
MaskedViewIOS,
View,
ViewPropTypes,
} from 'react-native';
import { MaskedViewIOS } from '../../PlatformHelpers';
import SafeAreaView from 'react-native-safe-area-view';
import HeaderTitle from './HeaderTitle';
@@ -384,7 +384,7 @@ class Header extends React.PureComponent {
if (
options.headerLeft ||
options.headerBackImage ||
Platform.OS !== 'ios' ||
Platform.OS === 'android' ||
transitionPreset !== 'uikit'
) {
return (

View File

@@ -179,19 +179,9 @@ class Transitioner extends React.Component {
const prevTransitionProps = this._prevTransitionProps;
this._prevTransitionProps = null;
const scenes = this.state.scenes.filter(isSceneNotStale);
const nextState = {
...this.state,
/**
* Array.prototype.filter creates a new instance of an array
* even if there were no elements removed. There are cases when
* `this.state.scenes` will have no stale scenes (typically when
* pushing a new route). As a result, components that rely on this prop
* might enter an unnecessary render cycle.
*/
scenes:
this.state.scenes.length === scenes.length ? this.state.scenes : scenes,
scenes: this.state.scenes.filter(isSceneNotStale),
};
this._transitionProps = buildTransitionProps(this.props, nextState);