Compare commits

..

6 Commits

Author SHA1 Message Date
Satyajit Sahoo
21709f7674 chore: publish
- @react-navigation/bottom-tabs@5.0.0-alpha.30
 - @react-navigation/drawer@5.0.0-alpha.32
2020-01-03 11:11:09 +01:00
Satyajit Sahoo
22742e4a7f chore: bump peer dep version for safe-area-context 2020-01-03 11:08:22 +01:00
Satyajit Sahoo
3cd1aedcf4 fix: pass backBehavior to the router in drawer. fixes #230 2020-01-03 11:00:35 +01:00
Satyajit Sahoo
797d3a798e chore: publish
- @react-navigation/stack@5.0.0-alpha.48
2020-01-01 16:28:28 +01:00
Satyajit Sahoo
59803f54d6 fix: improve gesture performance 2020-01-01 16:26:51 +01:00
Satyajit Sahoo
935659899f fix: use native driver for gestures 2020-01-01 15:48:26 +01:00
11 changed files with 92 additions and 43 deletions

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.30](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.29...@react-navigation/bottom-tabs@5.0.0-alpha.30) (2020-01-03)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [5.0.0-alpha.29](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.28...@react-navigation/bottom-tabs@5.0.0-alpha.29) (2020-01-01) # [5.0.0-alpha.29](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.28...@react-navigation/bottom-tabs@5.0.0-alpha.29) (2020-01-01)
**Note:** Version bump only for package @react-navigation/bottom-tabs **Note:** Version bump only for package @react-navigation/bottom-tabs

View File

@@ -10,7 +10,7 @@
"android", "android",
"tab" "tab"
], ],
"version": "5.0.0-alpha.29", "version": "5.0.0-alpha.30",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -51,7 +51,7 @@
"@react-navigation/native": "^5.0.0-alpha.0", "@react-navigation/native": "^5.0.0-alpha.0",
"react": "*", "react": "*",
"react-native": "*", "react-native": "*",
"react-native-safe-area-context": "^0.3.6" "react-native-safe-area-context": "^0.6.0"
}, },
"@react-native-community/bob": { "@react-native-community/bob": {
"source": "src", "source": "src",

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.32](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.31...@react-navigation/drawer@5.0.0-alpha.32) (2020-01-03)
### Bug Fixes
* pass backBehavior to the router in drawer. fixes [#230](https://github.com/react-navigation/navigation-ex/issues/230) ([3cd1aed](https://github.com/react-navigation/navigation-ex/commit/3cd1aedcf490a4c7962b2d36873d714637f3b9b0))
# [5.0.0-alpha.31](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.30...@react-navigation/drawer@5.0.0-alpha.31) (2020-01-01) # [5.0.0-alpha.31](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.30...@react-navigation/drawer@5.0.0-alpha.31) (2020-01-01)
**Note:** Version bump only for package @react-navigation/drawer **Note:** Version bump only for package @react-navigation/drawer

View File

@@ -11,7 +11,7 @@
"material", "material",
"drawer" "drawer"
], ],
"version": "5.0.0-alpha.31", "version": "5.0.0-alpha.32",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -23,6 +23,7 @@ type Props = DefaultNavigatorOptions<DrawerNavigationOptions> &
function DrawerNavigator({ function DrawerNavigator({
initialRouteName, initialRouteName,
backBehavior,
children, children,
screenOptions, screenOptions,
...rest ...rest
@@ -34,6 +35,7 @@ function DrawerNavigator({
DrawerNavigationEventMap DrawerNavigationEventMap
>(DrawerRouter, { >(DrawerRouter, {
initialRouteName, initialRouteName,
backBehavior,
children, children,
screenOptions, screenOptions,
}); });

View File

@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.48](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.47...@react-navigation/stack@5.0.0-alpha.48) (2020-01-01)
### Bug Fixes
* improve gesture performance ([59803f5](https://github.com/react-navigation/navigation-ex/commit/59803f54d64f85c8e46c1ebc70613a70a812f53a))
* use native driver for gestures ([9356598](https://github.com/react-navigation/navigation-ex/commit/935659899f1d4084c601fbefea4a935f9b6ce087))
# [5.0.0-alpha.47](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.46...@react-navigation/stack@5.0.0-alpha.47) (2020-01-01) # [5.0.0-alpha.47](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.46...@react-navigation/stack@5.0.0-alpha.47) (2020-01-01)
**Note:** Version bump only for package @react-navigation/stack **Note:** Version bump only for package @react-navigation/stack

View File

@@ -10,7 +10,7 @@
"android", "android",
"stack" "stack"
], ],
"version": "5.0.0-alpha.47", "version": "5.0.0-alpha.48",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -105,6 +105,11 @@ export default class Card extends React.Component<Props> {
if ( if (
this.getAnimateToValue(this.props) !== this.getAnimateToValue(prevProps) this.getAnimateToValue(this.props) !== this.getAnimateToValue(prevProps)
) { ) {
// We need to trigger the animation when route was closed
// Thr route might have been closed by a `POP` action or by a gesture
// When route was closed due to a gesture, the animation would've happened already
// It's still important to trigger the animation so that `onClose` is called
// If `onClose` is not called, cleanup step won't be performed for gestures
this.animate({ closing }); this.animate({ closing });
} }
} }
@@ -132,7 +137,7 @@ export default class Card extends React.Component<Props> {
closing, closing,
velocity, velocity,
}: { }: {
closing: boolean | undefined; closing?: boolean;
velocity?: number; velocity?: number;
}) => { }) => {
const { const {
@@ -143,6 +148,11 @@ export default class Card extends React.Component<Props> {
onTransitionStart, onTransitionStart,
} = this.props; } = this.props;
const toValue = this.getAnimateToValue({
...this.props,
closing,
});
const spec = closing ? transitionSpec.close : transitionSpec.open; const spec = closing ? transitionSpec.close : transitionSpec.open;
const animation = const animation =
@@ -153,7 +163,7 @@ export default class Card extends React.Component<Props> {
...spec.config, ...spec.config,
velocity, velocity,
useNativeDriver: true, useNativeDriver: true,
toValue: this.getAnimateToValue(this.props), toValue,
}).start(({ finished }) => { }).start(({ finished }) => {
if (finished) { if (finished) {
if (closing) { if (closing) {
@@ -169,7 +179,11 @@ export default class Card extends React.Component<Props> {
closing, closing,
layout, layout,
gestureDirection, gestureDirection,
}: Props) => { }: {
closing?: boolean;
layout: Layout;
gestureDirection: GestureDirection;
}) => {
if (!closing) { if (!closing) {
return 0; return 0;
} }
@@ -376,15 +390,18 @@ export default class Card extends React.Component<Props> {
} = interpolatedStyle; } = interpolatedStyle;
const handleGestureEvent = gestureEnabled const handleGestureEvent = gestureEnabled
? Animated.event([ ? Animated.event(
{ [
nativeEvent: {
gestureDirection === 'vertical' || nativeEvent:
gestureDirection === 'vertical-inverted' gestureDirection === 'vertical' ||
? { translationY: gesture } gestureDirection === 'vertical-inverted'
: { translationX: gesture }, ? { translationY: gesture }
}, : { translationX: gesture },
]) },
],
{ useNativeDriver: true }
)
: undefined; : undefined;
const { backgroundColor } = StyleSheet.flatten(contentStyle || {}); const { backgroundColor } = StyleSheet.flatten(contentStyle || {});

View File

@@ -30,7 +30,6 @@ type Props = TransitionPreset & {
renderScene: (props: { route: Route<string> }) => React.ReactNode; renderScene: (props: { route: Route<string> }) => React.ReactNode;
onOpenRoute: (props: { route: Route<string> }) => void; onOpenRoute: (props: { route: Route<string> }) => void;
onCloseRoute: (props: { route: Route<string> }) => void; onCloseRoute: (props: { route: Route<string> }) => void;
onGoBack: (props: { route: Route<string> }) => void;
onTransitionStart?: ( onTransitionStart?: (
props: { route: Route<string> }, props: { route: Route<string> },
closing: boolean closing: boolean
@@ -73,7 +72,6 @@ export default function CardContainer({
index, index,
layout, layout,
onCloseRoute, onCloseRoute,
onGoBack,
onOpenRoute, onOpenRoute,
onPageChangeCancel, onPageChangeCancel,
onPageChangeConfirm, onPageChangeConfirm,
@@ -109,7 +107,6 @@ export default function CardContainer({
} }
onTransitionStart?.({ route: scene.route }, closing); onTransitionStart?.({ route: scene.route }, closing);
closing && onGoBack({ route: scene.route });
}; };
const insets = { const insets = {

View File

@@ -46,7 +46,6 @@ type Props = {
routes: Route<string>[]; routes: Route<string>[];
openingRouteKeys: string[]; openingRouteKeys: string[];
closingRouteKeys: string[]; closingRouteKeys: string[];
onGoBack: (props: { route: Route<string> }) => void;
onOpenRoute: (props: { route: Route<string> }) => void; onOpenRoute: (props: { route: Route<string> }) => void;
onCloseRoute: (props: { route: Route<string> }) => void; onCloseRoute: (props: { route: Route<string> }) => void;
getPreviousRoute: (props: { getPreviousRoute: (props: {
@@ -360,7 +359,6 @@ export default class CardStack extends React.Component<Props, State> {
closingRouteKeys, closingRouteKeys,
onOpenRoute, onOpenRoute,
onCloseRoute, onCloseRoute,
onGoBack,
getPreviousRoute, getPreviousRoute,
getGesturesEnabled, getGesturesEnabled,
renderHeader, renderHeader,
@@ -527,7 +525,6 @@ export default class CardStack extends React.Component<Props, State> {
onCloseRoute={onCloseRoute} onCloseRoute={onCloseRoute}
onTransitionStart={onTransitionStart} onTransitionStart={onTransitionStart}
onTransitionEnd={onTransitionEnd} onTransitionEnd={onTransitionEnd}
onGoBack={onGoBack}
gestureEnabled={index !== 0 && getGesturesEnabled({ route })} gestureEnabled={index !== 0 && getGesturesEnabled({ route })}
gestureVelocityImpact={gestureVelocityImpact} gestureVelocityImpact={gestureVelocityImpact}
gestureDirection={gestureDirection} gestureDirection={gestureDirection}

View File

@@ -266,18 +266,6 @@ class StackView extends React.Component<Props, State> {
return <HeaderContainer {...props} />; return <HeaderContainer {...props} />;
}; };
private handleGoBack = ({ route }: { route: Route<string> }) => {
const { state, navigation } = this.props;
// This event will trigger when a gesture ends
// We need to perform the transition before removing the route completely
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
};
private handleOpenRoute = ({ route }: { route: Route<string> }) => { private handleOpenRoute = ({ route }: { route: Route<string> }) => {
this.setState(state => ({ this.setState(state => ({
routes: state.replacingRouteKeys.length routes: state.replacingRouteKeys.length
@@ -290,15 +278,33 @@ class StackView extends React.Component<Props, State> {
}; };
private handleCloseRoute = ({ route }: { route: Route<string> }) => { private handleCloseRoute = ({ route }: { route: Route<string> }) => {
// This event will trigger when the animation for closing the route ends const { state, navigation } = this.props;
// In this case, we need to clean up any state tracking the route and pop it immediately
// @ts-ignore if (state.routes.find(r => r.key === route.key)) {
this.setState(state => ({ // If a route exists in state, trigger a pop
routes: state.routes.filter(r => r.key !== route.key), // This will happen in when the route was closed from the card component
openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key), // e.g. When the close animation triggered from a gesture ends
closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key), // For the cleanup, the card needs to call this function again from its componentDidUpdate
})); navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
} else {
// Otherwise, the animation was triggered due to a route removal
// In this case, we need to clean up any state tracking the route and pop it immediately
// @ts-ignore
this.setState(state => ({
routes: state.routes.filter(r => r.key !== route.key),
openingRouteKeys: state.openingRouteKeys.filter(
key => key !== route.key
),
closingRouteKeys: state.closingRouteKeys.filter(
key => key !== route.key
),
}));
}
}; };
private handleTransitionStart = ( private handleTransitionStart = (
@@ -355,7 +361,6 @@ class StackView extends React.Component<Props, State> {
routes={routes} routes={routes}
openingRouteKeys={openingRouteKeys} openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys} closingRouteKeys={closingRouteKeys}
onGoBack={this.handleGoBack}
onOpenRoute={this.handleOpenRoute} onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute} onCloseRoute={this.handleCloseRoute}
onTransitionStart={this.handleTransitionStart} onTransitionStart={this.handleTransitionStart}