Compare commits

..

5 Commits

Author SHA1 Message Date
satyajit.happy
b38ee1c162 chore: publish
- @react-navigation/core@5.0.0-alpha.5
 - @react-navigation/drawer@5.0.0-alpha.7
 - @react-navigation/stack@5.0.0-alpha.9
2019-08-30 15:34:34 +02:00
satyajit.happy
fdc24d2523 fix: rename contentContainerStyle to sceneContainerStyle for drawer 2019-08-30 15:30:18 +02:00
satyajit.happy
6a8242c31a fix: properly set animated node on gestureEnabled change 2019-08-29 19:55:42 +02:00
satyajit.happy
3ad2e6ebcf fix: change interpolated style when idle to avoid messing up reanimated 2019-08-29 16:12:22 +02:00
satyajit.happy
5c8d183d68 chore: rename BaseActions -> CommonActions 2019-08-29 13:10:36 +02:00
12 changed files with 95 additions and 26 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.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.4...@react-navigation/core@5.0.0-alpha.5) (2019-08-30)
**Note:** Version bump only for package @react-navigation/core
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.3...@react-navigation/core@5.0.0-alpha.4) (2019-08-29) # [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.3...@react-navigation/core@5.0.0-alpha.4) (2019-08-29)

View File

@@ -6,7 +6,7 @@
"react-native", "react-native",
"react-navigation" "react-navigation"
], ],
"version": "5.0.0-alpha.4", "version": "5.0.0-alpha.5",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

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.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.6...@react-navigation/drawer@5.0.0-alpha.7) (2019-08-30)
### Bug Fixes
* rename contentContainerStyle to sceneContainerStyle for drawer ([fdc24d2](https://github.com/react-navigation/navigation-ex/commit/fdc24d2))
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.5...@react-navigation/drawer@5.0.0-alpha.6) (2019-08-29) # [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.5...@react-navigation/drawer@5.0.0-alpha.6) (2019-08-29)
**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.6", "version": "5.0.0-alpha.7",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -75,7 +75,7 @@ export type DrawerNavigationConfig = {
lazy: boolean; lazy: boolean;
/** /**
* Whether a screen should be unmounted when navigating away from it. * Whether a screen should be unmounted when navigating away from it.
* Defaults to `false`.. * Defaults to `false`.
*/ */
unmountInactiveRoutes?: boolean; unmountInactiveRoutes?: boolean;
/** /**
@@ -87,7 +87,10 @@ export type DrawerNavigationConfig = {
* Options for the content component which will be passed as props. * Options for the content component which will be passed as props.
*/ */
contentOptions?: object; contentOptions?: object;
contentContainerStyle?: StyleProp<ViewStyle>; /**
* Style object for the component wrapping the screen content.
*/
sceneContainerStyle?: StyleProp<ViewStyle>;
style?: StyleProp<ViewStyle>; style?: StyleProp<ViewStyle>;
}; };

View File

@@ -88,7 +88,7 @@ type Props = {
statusBarAnimation: 'slide' | 'none' | 'fade'; statusBarAnimation: 'slide' | 'none' | 'fade';
overlayStyle?: StyleProp<ViewStyle>; overlayStyle?: StyleProp<ViewStyle>;
drawerStyle?: StyleProp<ViewStyle>; drawerStyle?: StyleProp<ViewStyle>;
contentContainerStyle?: StyleProp<ViewStyle>; sceneContainerStyle?: StyleProp<ViewStyle>;
renderDrawerContent: Renderer; renderDrawerContent: Renderer;
renderSceneContent: Renderer; renderSceneContent: Renderer;
gestureHandlerProps?: React.ComponentProps<typeof PanGestureHandler>; gestureHandlerProps?: React.ComponentProps<typeof PanGestureHandler>;
@@ -484,7 +484,7 @@ export default class DrawerView extends React.PureComponent<Props> {
drawerPosition, drawerPosition,
drawerType, drawerType,
swipeEdgeWidth, swipeEdgeWidth,
contentContainerStyle, sceneContainerStyle,
drawerStyle, drawerStyle,
overlayStyle, overlayStyle,
onGestureRef, onGestureRef,
@@ -534,7 +534,7 @@ export default class DrawerView extends React.PureComponent<Props> {
{ {
transform: [{ translateX: contentTranslateX }], transform: [{ translateX: contentTranslateX }],
}, },
contentContainerStyle as any, sceneContainerStyle as any,
]} ]}
> >
{renderSceneContent({ progress: this.progress })} {renderSceneContent({ progress: this.progress })}

View File

@@ -190,7 +190,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
drawerPosition, drawerPosition,
drawerBackgroundColor, drawerBackgroundColor,
overlayColor, overlayColor,
contentContainerStyle, sceneContainerStyle,
edgeWidth, edgeWidth,
minSwipeDistance, minSwipeDistance,
hideStatusBar, hideStatusBar,
@@ -222,7 +222,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
gestureHandlerProps={gestureHandlerProps} gestureHandlerProps={gestureHandlerProps}
drawerType={drawerType} drawerType={drawerType}
drawerPosition={drawerPosition} drawerPosition={drawerPosition}
contentContainerStyle={contentContainerStyle} sceneContainerStyle={sceneContainerStyle}
drawerStyle={{ drawerStyle={{
backgroundColor: drawerBackgroundColor || 'white', backgroundColor: drawerBackgroundColor || 'white',
width: this.state.drawerWidth, width: this.state.drawerWidth,

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.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.8...@react-navigation/stack@5.0.0-alpha.9) (2019-08-30)
### Bug Fixes
* change interpolated style when idle to avoid messing up reanimated ([3ad2e6e](https://github.com/react-navigation/navigation-ex/commit/3ad2e6e))
* properly set animated node on gestureEnabled change ([6a8242c](https://github.com/react-navigation/navigation-ex/commit/6a8242c))
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.7...@react-navigation/stack@5.0.0-alpha.8) (2019-08-29) # [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.7...@react-navigation/stack@5.0.0-alpha.8) (2019-08-29)

View File

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

View File

@@ -202,7 +202,11 @@ export default class Card extends React.Component<Props> {
} }
if (closing !== prevProps.closing) { if (closing !== prevProps.closing) {
this.isClosing.setValue(closing ? TRUE : FALSE); // If the style updates during render, setting the value here doesn't work
// We need to defer it a bit so the animation starts properly
requestAnimationFrame(() =>
this.isClosing.setValue(closing ? TRUE : FALSE)
);
} }
} }
@@ -267,6 +271,17 @@ export default class Card extends React.Component<Props> {
finished: new Value(FALSE), finished: new Value(FALSE),
}; };
private handleTransitionEnd = () => {
this.isRunningAnimation = false;
this.interpolatedStyle = this.getInterpolatedStyle(
this.props.styleInterpolator,
this.props.index,
this.props.current,
this.props.next,
this.props.layout
);
};
private runTransition = (isVisible: Binary | Animated.Node<number>) => { private runTransition = (isVisible: Binary | Animated.Node<number>) => {
const { open: openingSpec, close: closingSpec } = this.props.transitionSpec; const { open: openingSpec, close: closingSpec } = this.props.transitionSpec;
@@ -331,7 +346,9 @@ export default class Card extends React.Component<Props> {
call([this.isVisible], ([value]: ReadonlyArray<Binary>) => { call([this.isVisible], ([value]: ReadonlyArray<Binary>) => {
const isOpen = Boolean(value); const isOpen = Boolean(value);
const { onOpen, onClose } = this.props; const { onOpen, onClose } = this.props;
this.isRunningAnimation = false;
this.handleTransitionEnd();
if (isOpen) { if (isOpen) {
onOpen(true); onOpen(true);
} else { } else {
@@ -357,7 +374,7 @@ export default class Card extends React.Component<Props> {
cond(neq(this.nextIsVisible, UNSET), [ cond(neq(this.nextIsVisible, UNSET), [
// Stop any running animations // Stop any running animations
cond(clockRunning(this.clock), [ cond(clockRunning(this.clock), [
call([], () => (this.isRunningAnimation = false)), call([], this.handleTransitionEnd),
stopClock(this.clock), stopClock(this.clock),
]), ]),
set(this.gesture, 0), set(this.gesture, 0),
@@ -511,6 +528,18 @@ export default class Card extends React.Component<Props> {
}) })
); );
// Keep track of the style in a property to avoid changing the animated node when deps change
// The style shouldn't change in the middle of the animation and should refer to what was there at the start of it
// Which will be the last value when just before the render which started the animation
// We need to make sure to update this when the running animation ends
private interpolatedStyle = this.getInterpolatedStyle(
this.props.styleInterpolator,
this.props.index,
this.props.current,
this.props.next,
this.props.layout
);
private gestureActivationCriteria() { private gestureActivationCriteria() {
const { layout, gestureDirection, gestureResponseDistance } = this.props; const { layout, gestureDirection, gestureResponseDistance } = this.props;
@@ -551,35 +580,39 @@ export default class Card extends React.Component<Props> {
render() { render() {
const { const {
index,
active, active,
transparent, transparent,
layout, styleInterpolator,
index,
current, current,
next, next,
layout,
overlayEnabled, overlayEnabled,
shadowEnabled, shadowEnabled,
gestureEnabled, gestureEnabled,
gestureDirection, gestureDirection,
children, children,
styleInterpolator,
containerStyle: customContainerStyle, containerStyle: customContainerStyle,
contentStyle, contentStyle,
...rest ...rest
} = this.props; } = this.props;
if (!this.isRunningAnimation) {
this.interpolatedStyle = this.getInterpolatedStyle(
styleInterpolator,
index,
current,
next,
layout
);
}
const { const {
containerStyle, containerStyle,
cardStyle, cardStyle,
overlayStyle, overlayStyle,
shadowStyle, shadowStyle,
} = this.getInterpolatedStyle( } = this.interpolatedStyle;
styleInterpolator,
index,
current,
next,
layout
);
const handleGestureEvent = gestureEnabled const handleGestureEvent = gestureEnabled
? gestureDirection === 'vertical' ? gestureDirection === 'vertical'
@@ -592,6 +625,7 @@ export default class Card extends React.Component<Props> {
<View pointerEvents="box-none" {...rest}> <View pointerEvents="box-none" {...rest}>
<Animated.Code exec={this.exec} /> <Animated.Code exec={this.exec} />
<Animated.Code <Animated.Code
key={gestureEnabled ? 'gesture-code' : 'no-gesture-code'}
exec={gestureEnabled ? this.execWithGesture : this.execNoGesture} exec={gestureEnabled ? this.execWithGesture : this.execNoGesture}
/> />
{overlayEnabled && overlayStyle ? ( {overlayEnabled && overlayStyle ? (

View File

@@ -167,11 +167,14 @@ export default class Stack extends React.Component<Props, State> {
: undefined; : undefined;
const next = nextRoute ? progress[nextRoute.key] : undefined; const next = nextRoute ? progress[nextRoute.key] : undefined;
const oldScene = state.scenes[index];
const scene = { const scene = {
route, route,
previous: previousRoute, previous: previousRoute,
descriptor: descriptor:
props.descriptors[route.key] || state.descriptors[route.key], props.descriptors[route.key] ||
state.descriptors[route.key] ||
(oldScene ? oldScene.descriptor : { options: {} }),
progress: { progress: {
current, current,
next, next,
@@ -179,8 +182,6 @@ export default class Stack extends React.Component<Props, State> {
}, },
}; };
const oldScene = state.scenes[index];
if ( if (
oldScene && oldScene &&
scene.route === oldScene.route && scene.route === oldScene.route &&