react-native/React/Modules
Nick Lockwood d64368b9e2 Implement CSS z-index for iOS
Summary:
This diff implement the CSS z-index for React Native iOS views. We've had numerous pull request for this feature, but they've all attempted to use the `layer.zPosition` property, which is problematic for two reasons:

1. zPosition only affects rendering order, not event processing order. Views with a higher zPosition will appear in front of others in the hierarchy, but won't be the first to receive touch events, and may be blocked by views that are visually behind them.
2. when using a perspective transform matrix, views with a nonzero zPosition will be rendered in a different position due to parallax, which probably isn't desirable.

See https://github.com/facebook/react-native/pull/7825 for further discussion of this problem.

So instead of using `layer.zPosition`, I've implemented this by actually adjusting the order of the subviews within their parent based on the zIndex. This can't be done on the JS side because it would affect layout, which is order-dependent, so I'm doing it inside the view itself.

It works as follows:

1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager.
2. `didUpdateReactSubviews` is called, which in turn calls `sortedSubviews` (which lazily generates a sorted array of  `reactSubviews` by zIndex) and inserts the result into the view.
3.  If a subview is added or removed, or the zIndex of any subview is changed, the previous `sortedSubviews` array is cleared and  `didUpdateReactSubviews` is called again.

To demonstrate it working, I've modified the UIExplorer example from https://github.com/facebook/react-native/pull/7825

Reviewed By: javache

Differential Revision: D3365717

fbshipit-source-id: b34aa8bfad577bce023f8af5414f9b974aafd8aa
2016-06-07 07:43:49 -07:00
..
RCTAccessibilityManager.h Replaced RCTSparseArray with NSDictionary 2015-11-14 10:28:28 -08:00
RCTAccessibilityManager.m Update RCTNetworking, RCTNetInfo and RCTLocationManager to use new events system 2016-05-25 04:28:36 -07:00
RCTAlertManager.h Remove an existing UIAlertViews when invalidating the RCTAlertManager 2015-09-18 08:45:27 -07:00
RCTAlertManager.m ActionSheetIOS - support share sheet on modals 2016-05-20 17:13:21 -07:00
RCTAppState.h Updated AppState module to use new emitter system 2016-05-23 09:13:37 -07:00
RCTAppState.m Replaced isMainThread checks with a proper test for main queue 2016-06-06 07:58:36 -07:00
RCTAsyncLocalStorage.h Added lightweight generic annotations 2015-11-03 14:49:30 -08:00
RCTAsyncLocalStorage.m Increase RN devtools retry timeout 2016-04-01 07:02:25 -07:00
RCTClipboard.h add Clipboard component for ios and android 2015-12-09 10:04:21 -08:00
RCTClipboard.m Minor fixes to clipboard and Linking to remove TODOs 2016-02-10 12:25:51 -08:00
RCTDevLoadingView.h [RCTDevLoadingView] Add ability to disable during development. 2015-09-04 03:46:06 -08:00
RCTDevLoadingView.m Added explicit init to observer modules 2016-05-04 07:07:24 -07:00
RCTDevMenu.h Refactor hot loading implementation on iOS 2016-01-04 10:40:32 -08:00
RCTDevMenu.m Tweak dev menu label: Stop Remote JS Debugging 2016-06-01 04:13:35 -07:00
RCTEventEmitter.h Added native event emitter 2016-05-11 06:27:29 -07:00
RCTEventEmitter.m Update RCTNetworking, RCTNetInfo and RCTLocationManager to use new events system 2016-05-25 04:28:36 -07:00
RCTExceptionsManager.h Refactored module access to allow for lazy loading 2015-11-25 04:49:45 -08:00
RCTExceptionsManager.m Replaced RegExp method parser with recursive descent 2015-12-10 10:12:29 -08:00
RCTKeyboardObserver.h Added native event emitter 2016-05-11 06:27:29 -07:00
RCTKeyboardObserver.m Added native event emitter 2016-05-11 06:27:29 -07:00
RCTRedBox.h Added lightweight generic annotations 2015-11-03 14:49:30 -08:00
RCTRedBox.m Redbox: skip column number if it is 0 2016-05-27 11:43:34 -07:00
RCTSourceCode.h Use JSStringCreateWithUTF8CString and skip NSString decoding when loading the bundle 2015-10-16 08:11:25 -07:00
RCTSourceCode.m Improve error handling in require-unbundle 2016-04-22 06:18:26 -07:00
RCTStatusBarManager.h Added native event emitter 2016-05-11 06:27:29 -07:00
RCTStatusBarManager.m Added native event emitter 2016-05-11 06:27:29 -07:00
RCTTiming.h [ReactNative] Use a single DisplayLink held by the bridge 2015-04-15 07:07:48 -08:00
RCTTiming.m Make RCTTiming module lazy 2016-05-25 10:43:27 -07:00
RCTUIManager.h Expose UIManager queue via a static function to prevent race conditions 2016-05-16 08:13:21 -07:00
RCTUIManager.m Implement CSS z-index for iOS 2016-06-07 07:43:49 -07:00