Skip to content
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

Updated Actions values to a more standard format #550

Closed
wants to merge 27 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3561582
direction support for rn 0.24+
joenoon Apr 11, 2016
1256e03
fix || logic and optimize duration 0
joenoon Apr 11, 2016
914ae8b
Improve README
Kerumen Apr 17, 2016
ea8aad1
Merge pull request #1 from aksonov/master
cridenour Apr 17, 2016
aa74423
Bump example project dependency.
cridenour Apr 17, 2016
a3a6087
Merge branch 'jn-direction1' of github.com:joenoon/react-native-route…
cridenour Apr 17, 2016
1f2c98c
Cleanup styles and unused imports.
cridenour Apr 17, 2016
495c794
Remove optionals.
cridenour Apr 17, 2016
546c00c
Make sure panHandler can be passed as null.
cridenour Apr 17, 2016
6aac7bd
Actually run react-native upgrade.
cridenour Apr 17, 2016
ff69aaa
Document why we removed optionals.
cridenour Apr 17, 2016
d0ff592
Merge pull request #536 from cridenour/feature/react-native-24
aksonov Apr 18, 2016
55bb2d2
Revert "[WIP] Get Example app working with React 0.24+ "
aksonov Apr 18, 2016
f44d50c
Merge pull request #538 from aksonov/revert-536-feature/react-native-24
aksonov Apr 18, 2016
915d3a3
Revert "Revert "[WIP] Get Example app working with React 0.24+ ""
aksonov Apr 18, 2016
c4ea2f8
Merge pull request #539 from aksonov/revert-538-revert-536-feature/re…
aksonov Apr 18, 2016
5d12464
update redux instructions in README
lynndylanhurley Apr 18, 2016
61967e6
fix typo in readme
lynndylanhurley Apr 18, 2016
3be4fc6
Merge pull request #542 from lynndylanhurley/master
aksonov Apr 18, 2016
71f58a1
improve redux setup README
lynndylanhurley Apr 18, 2016
a8e383a
Merge pull request #543 from lynndylanhurley/master
aksonov Apr 18, 2016
a74ef41
Merge pull request #535 from Kerumen/patch-1
aksonov Apr 18, 2016
59821c3
publish new version
Apr 18, 2016
12f18a5
add render title callback
timzaak Apr 19, 2016
e278588
fix the comment
timzaak Apr 19, 2016
7e6d0ee
Merge pull request #547 from timzaak/renderTitle
aksonov Apr 19, 2016
2a5279b
Updated Actions values to a more standard format
mmazzarolo Apr 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions src/DefaultRenderer.js
Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@ const {
RootContainer: NavigationRootContainer,
Header: NavigationHeader,
} = NavigationExperimental;

const {
CardStackPanResponder: NavigationCardStackPanResponder,
CardStackStyleInterpolator: NavigationCardStackStyleInterpolator
} = NavigationCard;

import TabBar from "./TabBar";
import NavBar from "./NavBar";

@@ -56,7 +62,6 @@ export default class DefaultRenderer extends Component {

let applyAnimation = selected.applyAnimation || navigationState.applyAnimation;
let style = selected.style || navigationState.style;
let direction = selected.direction || navigationState.direction || "horizontal";

let optionals = {};
if (applyAnimation) {
@@ -66,7 +71,11 @@ export default class DefaultRenderer extends Component {
if (duration === null || duration === undefined) duration = navigationState.duration;
if (duration !== null && duration !== undefined) {
optionals.applyAnimation = function (pos, navState) {
Animated.timing(pos, {toValue: navState.index, duration}).start();
if (duration === 0) {
pos.setValue(navState.index);
} else {
Animated.timing(pos, {toValue: navState.index, duration}).start();
}
};
}
}
@@ -76,7 +85,6 @@ export default class DefaultRenderer extends Component {
navigationState={navigationState}
style={[styles.animatedView, style]}
renderOverlay={this._renderHeader}
direction={direction}
renderScene={this._renderCard}
{...optionals}
/>
@@ -91,16 +99,31 @@ export default class DefaultRenderer extends Component {
}

_renderCard(/*NavigationSceneRendererProps*/ props) {
const { key, direction, panHandlers, getSceneStyle } = props.scene.navigationState;
const { key, direction, getSceneStyle } = props.scene.navigationState;
let { panHandlers, animationStyle } = props.scene.navigationState;

let style = {};
if (getSceneStyle) style = getSceneStyle(props);

const optionals = {};
if (getSceneStyle) optionals.style = getSceneStyle(props);
const isVertical = direction === "vertical";

if (!animationStyle) {
animationStyle = (isVertical ?
NavigationCardStackStyleInterpolator.forVertical(props) :
NavigationCardStackStyleInterpolator.forHorizontal(props));
}

if (!panHandlers) {
panHandlers = panHandlers || (isVertical ?
NavigationCardStackPanResponder.forVertical(props) :
NavigationCardStackPanResponder.forHorizontal(props));
}

return (
<NavigationCard
{...props}
key={'card_' + key}
direction={direction || 'horizontal'}
style={[animationStyle, style]}
panHandlers={panHandlers}
renderScene={this._renderScene}
{...optionals}