Commit Graph

94 Commits

Author SHA1 Message Date
Eric Vicenti 7963add0d5 [ReactNative] Revamp Navigator scene cache strategy
Summary:
Updating range is too complicated. We can keep cached versions of the previously rendered scenes in a map.

@public

Test Plan: Verify that the active scene is the only thing that get re-rendered, and that rendering doesn't happen during transitions or gestures. Test navigation thouroughly in AdsManager
2015-06-25 10:36:49 -08:00
Alex Kotliarskyi 01d2df8c86 [ReactNative] NavigationContext-test mock fix for OSS 2015-06-24 13:37:46 -08:00
Eric Vicenti 0c38229e8e [Navigator] Fix overswipe to -1, move guard 2015-06-22 17:00:52 -08:00
Eric Vicenti d105ae7e51 [AdsManager] Fix Navigation focus events for logging 2015-06-22 16:44:32 -08:00
Spencer Ahrens 5b476d0e41 [ReactNative] Fix manual ListView loading
Summary:
@public

If something changes in the list view that should trigger more loads, it
wouldn't.  Example case is tap to load more - only the first new row would load,
but it wouldn't trigger a re-measure and subsequent layout of additional new
rows.

Test Plan: View More in Events works.
2015-06-22 13:37:30 -08:00
Hedger Wang 7f54506f96 <Navigator />: Fix the getter for `navigationContext`.
Summary:
@public
The current getter for `navigationContext` always return a static
context, and it should return an instance-based one, instead.

Test Plan:
Use console.log() in inspect that two different navigators do
have their own `navigationContext` created.
2015-06-22 12:02:55 -08:00
Hedger Wang 93e98da908 [Navigator]: Add a getter to get the current route that is focused from the navigation context. 2015-06-19 16:12:51 -08:00
Hedger Wang e78b8c40fe [oss][react-native] unbreak NavigationEventEmitter-test 2015-06-17 14:13:05 -08:00
Hedger Wang 0a875790f5 [Navigator]: Allow developer to observe the focus change events from the owner or the children
of the navigator component.

Summary:
Per offline discussion with @evv, we'd like to deprecate the `onDidFocus` and `onWillFocus`
API that makes it really hard for the descendent children of a navigator to observe its focus
change events.
@public

Since for now the descendent children do have access to the navigator via `this.props.navigator`,
this diff makes it easy to observe the focus change event by doing:

```
this.props.navigator.addListener('willfocus', this._onFocus);
```

The goal is to make the event system in navigator more useful and maintainable.

Test Plan:
Test Video: https://www.facebook.com/pxlcld/mrzS
1. jest:  ./Libraries/FBReactKit/js/runTests.js NavigationEventEmitter
2. Load UI Explorer: <Navigator />, see console logs that shows the focus change events fires.
2015-06-16 09:09:08 -08:00
James Ide 3393b86534 [ListView] Update curRenderedRowsCount when data source changes
Summary:
When a new data source is provided, update `curRenderedRowsCount` in addition to `prevRenderedRowsCount`. What was happening is that I had an empty data source, so `curRenderedRowsCount` and `prevRenderedRowsCount` both settled at zero after the first few frames and `curRenderedRowsCount` wasn't getting increased when the data source was updated.

I also changed the `setState` calls to use the transactional API since several of the new state values are computed from the old ones.

Maybe fixes #1547
Closes https://github.com/facebook/react-native/pull/1612
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-15 13:30:17 -08:00
Eric Vicenti f8482411f9 [AdsManager] Improve animation configurations 2015-06-10 23:35:52 -08:00
Eric Vicenti 4690983c10 [AdsManager|ReactNative] Remove contextual navigation from Navigator 2015-06-10 01:13:43 -08:00
Andy Street 0a3fca9520 [react_native] JS files from D2130816: [react_native] Don't render crumb container to texture 2015-06-09 03:09:17 -08:00
Eric Vicenti f6528171d0 [ReactNative] Fix navigator touch-blocking logic
Summary:
The logic for this is incorrect when the `state.transitionToIndex === 0`, and will return false and not capture the touch.

@public

Test Plan: Try to repro bugs on device and simulator
2015-06-08 11:20:12 -08:00
Eric Vicenti 219a7c1bfd [ReactNative] Navigator block touches on scene when navigating 2015-06-01 16:35:43 -08:00
Spencer Ahrens 34cef28a10 [ReactNative] kill setInterval in ListView 2015-06-01 13:34:06 -08:00
Alex Kotliarskyi 228dc5f936 [MAdMan] Possibly fix "Cannot find breadcrumb interpolators for -1" 2015-05-29 11:23:40 -08:00
Changgeng Li 84783dbac4 Add renderSeparator support to ListView 2015-05-26 15:20:29 -08:00
Eric Vicenti 5bad316678 [ReactNative] Navigator de-contextualize popToRoute 2015-05-22 11:56:55 -08:00
Eric Vicenti 62c556c785 [ReactNative] Navigator context setHandler refer by index 2015-05-22 11:44:49 -08:00
James Ide 7f51f9c8a9 [Navigator] Support the `ref` prop on scene roots
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')} />;
}
```
2015-05-21 11:01:09 -08:00
Eric Vicenti c1609bcab8 [ReactNative] Navigator fix for sceneStyle
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
2015-05-19 18:54:15 -08:00
Eric Vicenti 97137e8bcc [ReactNative] Navigator clean scenes popped with gesture
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.
2015-05-19 18:45:42 -08:00
Spencer Ahrens 11b515b1b0 [ReactNative] clean lint in all of Libraries/ 2015-05-19 13:47:04 -08:00
Zhao Han 40da7bb835 Add more documentation in ListViewDataSource
Summary:
ListViewDataSource's default data extractor can actually expect another data form:

`{ sectionID_1: [ <rowData1>, <rowData2>, ... ], ... }`
Closes https://github.com/facebook/react-native/pull/1285
Github Author: Zhao Han <cx.chenghai+github@gmail.com>

Test Plan: Changed the ListViewExample to make sure all three formats work.
2015-05-15 13:47:43 -08:00
Yuta Okazaki 75ed1dd49e Fix typo of function name in ListView documentation
Summary:
When I read documents, I usually 'search within page' to see where they talk about specific things.
So I found this fix to be pretty useful. Hope it'll be merged!
Closes https://github.com/facebook/react-native/pull/1146
Github Author: Yuta Okazaki <s04155yo@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-14 09:52:19 -08:00
Eric Vicenti 4b5385b2f0 [ReactNative] Fix Navigator resetTo race condition
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
2015-05-13 12:17:31 -08:00
Ben Alpert a0440daf98 [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNodeHandle 2015-05-13 13:24:37 -07:00
Logan Bernard 2ed2d20dfe FloatFromLeft animation
Summary:
float from left animation for Navigator.SceneConfigs

#1100
@ericvicenti
@ide
Closes https://github.com/facebook/react-native/pull/1249
Github Author: Logan Bernard <bernard.logan4@gmail.com>

@public

Test Plan: Video: https://drive.google.com/file/d/0B9HtmABaCcR0Zi1yNkl5UDhWbzg/view
2015-05-13 13:24:37 -07:00
James Ide 6a699302c8 [Navigator] Pass route into onItemRef
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.
2015-05-13 13:24:37 -07:00
Eric Vicenti 1a68585990 [ReactNative] Navigator fix rapid gesture breakage
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
2015-05-13 13:24:36 -07:00
Eric Vicenti 02d875869a [ReactNative] Fix Navigator empty scene issue
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
2015-05-13 13:24:36 -07:00
Eric Vicenti aa19232609 [ReactNative] Fix case where scenes are not reset on gesture detaching
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
2015-05-13 13:24:35 -07:00
Eric Vicenti a852227279 [ReactNative] Improve Navigator start gesture logic
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.
2015-05-13 13:24:35 -07:00
Eric Vicenti 40e3f6ea8c [ReactNative] Navigator initialRoute default change
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.
2015-05-06 11:18:55 -08:00
Eric Vicenti 86cfcbc77e [ReactNative] Navigator fix opacity reset for presented scene
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
2015-05-05 14:30:29 -08:00
jmstout 929b2999c4 Fix a bug in the Navigator's gesture.edgeHitWidth implementation
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.
2015-05-05 06:26:51 -08:00
Eric Vicenti 50de4a67b0 [ReactNative] Navigator use flattenStyle
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
2015-05-04 14:33:25 -08:00
Eric Vicenti 548a0a6a4f [ReactNative] Fix Navigator scene hiding logic
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
2015-05-04 08:54:19 -08:00
Eric Vicenti c0d77dbe9c [ReactNative] Navigator pop specify route to pop
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
2015-05-01 18:11:13 -08:00
Eric Vicenti 28e6e993c6 [ReactNative] Navigator focus handler context fix 2015-05-01 17:01:58 -08:00
Eric Vicenti 5453be2ab2 [ReactNative] Fix touch issue caused by D2036644 after swiping back 2015-05-01 16:15:28 -08:00
Eric Vicenti 6abf37b47e [ReactNative] Navigator.Interceptor handler arg fix 2015-05-01 14:20:09 -08:00
Eric Vicenti 76dc14684d [ReactNative] Navigator block touches to non-active scenes
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
2015-04-30 15:49:37 -08:00
Eric Vicenti 08ec846176 [ReactNative] Fix logic in popToRoute 2015-04-29 20:52:32 -08:00
Andy Street c82c6a07ae [react_native] JS files from D2027859: [react_native] Fix ToTheLeft wizard transitions 2015-04-29 04:49:43 -08:00
Eric Vicenti 349f8b942a [ReactNative] Avoid Navigator invariant in edge case
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
2015-04-28 23:53:39 -08:00
Eric Vicenti 9209c444c7 [ReactNative] Androidized Navigator animations
Summary:
Added configurations for android-like animations, with gestures disabled.

@public

Test Plan: Tested on AdsManager Android
2015-04-28 13:10:49 -08:00
Eric Vicenti 8afdf30363 [ReactNative] Navigator refactor and improvements 2015-04-27 21:37:33 -08:00
Eric Vicenti ec3d70e738 [ReactNative] Quiet Navigator context warning 2015-04-27 17:31:12 -08:00