Summary:
Navigator overrides the `ref` prop of scene components so that it can call `onItemRef` and do internal bookkeeping. With callback refs, we can additionally call the original value of the `ref` prop as long as it's a function (that is, string refs are not supported). Note that the `ref` prop is moved to `reactElement.ref` out of `reactElement.props.ref`, which is why this diff accesses `child.ref`.
This diff adds support for callback refs and warns helpfully if a string ref was provided. It should be completely backwards compatible since scenes couldn't have been relying on the `ref` prop before.
cc @ericvicenti
Closes https://github.com/facebook/react-native/pull/1361
Github Author: James Ide <ide@jameside.com>
@public
Test Plan:
Write a renderScene implementation that puts a callback ref on the root component:
```js
renderScene() {
return <View ref={component => console.log('yes! this is called')} />;
}
```
Summary:
Fixes https://github.com/facebook/react-native/issues/1332
When the absolute left position is not set to zero on a provided sceneStyle, scene enabling is broken and no scene will be visible when it is pushed. This was broken recently when the scene disabling was modified to push the scenes offscreen.
Closes https://github.com/facebook/react-native/pull/1347
Github Author: Eric Vicenti <evv@fb.com>
@public
Test Plan: Tested when pushing a scene Navigator in the UIExplorer example while sceneStyle is set on the Navigator
Summary:
Fixes https://github.com/facebook/react-native/issues/1252
Scenes dismissed/popped via a gesture were not being removed. This is probably a regression from an earlier refactor.
Test plan: log statements after scene focusing now reports that `navigator.getCurrentRoutes().length` lowers after gesture. Tested on UIExplorer Navigator example
Closes https://github.com/facebook/react-native/pull/1346
Github Author: Eric Vicenti <evv@fb.com>
@public
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary:
SetState can be somewhat racy. By the time the route state finishes, another resetTo has already happened, so the origional route is no longer in the stack. Hence the redbox invariant "Calling pop to route for a route that doesn't exist!"
This could also be fixed in product code by not calling resetTo rapidly, but the navigator should be resilient to such shenanigans
@public
Test Plan: Cannot get AdsManager crash t7031976
Summary:
The index alone isn't so useful; pass the route as well. (I am using this to implement componentWill/DidFocus in a library instead of onWill/DidFocus; #1153).
Closes https://github.com/facebook/react-native/pull/1154
Github Author: James Ide <ide@jameside.com>
@public
Test Plan: Set up a navigator with a couple of scenes, and see that when onItemRef is called for each one, the route is passed in as the third argument.
Summary:
When gesturing rapidly between scenes, the navigator can get into an unresponsive state. A few minor fixes can avoid that case
@public
Test Plan: Rapid gestures on iOS device and simulator can no longer get into bad state
Summary:
In some situations, when quickly swiping back to a scene we are transitioning from, the scene is blank/missing. This is fixed by adding a check for the active gesture when we hide the scenes.
@public
Test Plan: Can no longer reproduce on simulator when quickly swiping back to the scene we are transitioning from
Summary:
Sometimes, when quicly backing out of a gesture, the scene isn't fully reset to the middle position and remains offset by a few pixels. This makes sure that never happens.
@public
Test Plan: Tested on iOS and I can no longer see the scenes stop when backing out of a gesture
Summary:
Previously it was possible for a gesture to be granted initiated if the start direction is not respected before the gesture detection distance gets reached, if the gesture direction is met eventually. This change ensures the gesture gets started in the right direction, otherwise the gesture action will set the responder.
@public
Test Plan: Fixes left-right swiping issue in AdsManager when a vertical swipe is intended.
Summary:
The default initialRoute was the first route, but it makes more sense for the default initialRoute to be the last route in the initialRouteStack.
Updated the docs to reflect that.
@public
Test Plan: Updated call sites and checked that they work. Not many places use initialRouteStack yet.
Summary:
jumpN will call enableScene for the dest scene, which makes sure the scene can be made visible, but we need to avoid resetting the opacity for it when it is already the presented scene. There is already a check to make sure we don't reset opacity for the transitioningFrom scene.
@public
Test Plan: Fixes the issue on Android device when jumping to a scene that is already presented
Summary:
Should resolve#1081
cc @ericvicenti
Closes https://github.com/facebook/react-native/pull/1082
Github Author: jmstout <git@jmstout.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Revert Plan: This seems legit, but I'm not qualified to review.
Summary:
A hack was implemented in Navigator to do this manually, but there is a proper function to get these styles for setting native props
@public
Test Plan: Testing Navigator behavior on iOS and Android
Summary:
Scenes with 0 opacity are being rendered on top of other scenes with full absolute positioning. On iOS this is fine, because the platform will not send touch events to a view with no opacity. On Android is poses a problem because the view on top, even with no opacity, is catching the touch events for the presented scene below.
This change enhances the scene enabling and hiding logic, has better naming, and improves the documentation of it.
@public
Test Plan: Tested transitions and gestures in slow motion on iOS and Android
Summary:
Now you can pass a route to the pop function in the navigator context, and the Navigator will pop that scene off the stack and every scene that follows.
This changes the request API that bubbles up to the top-level navigator. The `pop` request had previously taken a route for `popToRoute`, but that is a more obscure use case. This makes the request API more closely match the context method naming.
@public
Test Plan: Verified this works by popping several routes in AdsManager. Experimented with UIExplorer Navigator example to make sure popToRoute still works as expected
Summary:
When tapping a link quickly, it will cause two scenes to be pushed on. This prevents against that case by swallowing touches for all non-active scenes.
@public
Test Plan: Can no longer double-push scenes
Summary:
It is very rare, but sometimes there is no active gesture when the responder gets released. This will avoid a redbox in that case
@public
Test Plan: Saw the redbox. No longer see the redbox. Hardcoded missing activeGesture while responder and verified no redbox
Summary:
... for setting the transition background color between scenes. For issue #563
Closes https://github.com/facebook/react-native/pull/654
Github Author: Josh Levine <josh.levine1@gmail.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.