Files
react-native/ReactAndroid/src/main/java/com/facebook/react/flat
Valentin Shergin 6114f863c3 Restructured inheritance around ReactTextViewManager and co.
Summary:
Abstract class `ReactBaseTextShadowNode` was decoupled from `ReactTextShadowNode` to separate two goals/roles:
 * `ReactBaseTextShadowNode` represents spanned `<Text>` nodes, which can bear text attributes (both `RCTText` and `RCTVirtualText`);
 * `ReactTextShadowNode` represents anchor `<Text>` view in Yoga terms, which can bear layout attributes (`RCTText` and `RCTTextInput`).

`ReactVirtualTextShadowNode` now inherits `ReactBaseTextShadowNode`.
The same architectural changes was applited to view managers.

Why?
 * This is just a better architecture which represents the nature of this objects.
 * Bunch of "negative" logic which turn off excessive features for some suclasses was removed.
 * Memory efficiency.
 * Now we can improve `<TextInput>` component using right inheritance. Yay!

Reviewed By: achen1

Differential Revision: D5715830

fbshipit-source-id: ecc0764a03b5b7586fe77ad31f149cd840f4da41
2017-09-11 15:49:01 -07:00
..
2016-12-19 13:40:28 -08:00
2016-12-19 16:58:30 -08:00

Nodes

Nodes is an experimental, alternate version of UIImplementation for ReactNative on Android. It has two main advantages over the existing UIImplementation:

  1. Support for overflow:visible on Android.
  2. More efficient generation of view hierarchies.

The intention is to ultimately replace the existing UIImplementation on Android with Nodes (after all the issues are ironed out).

How to test

In a subclass of ReactNativeHost, add this:

@Override
protected UIImplementationProvider getUIImplementationProvider() {
  return new FlatUIImplementationProvider();
}

How it Works

The existing UIImplementation maps all non-layout tags to Views (resulting in an almost 1:1 mapping of tags to Views, with the exception of some optimizations for layout only tags that don't draw content). Nodes, on the other hand, maps react tags to a set of DrawCommands. In other words, an <image> tag will often be mapped to a Drawable instead of an ImageView and a <text> tag will be mapped to a Layout instead of a TextView. This helps flatten the resulting View hierarchy.

There are situations where DrawCommands are promoted to Views:

  1. Existing Android components that are wrapped by React Native (for example, ViewPager, ScrollView, etc).
  2. When using a View is more optimal (for example, opacity, to avoid unnecessary invalidations).
  3. To facilitate the implementation of certain features (accessibility, transforms, etc).

This means that existing custom ViewManagers should continue to work as they did with the existing UIImplementation.

Limitations and Known Issues

  • LayoutAnimations are not yet supported
  • zIndex is not yet supported