react-native/Examples/UIExplorer
Spencer Ahrens f25df504ed Add support for updating adjacent separators on row highlight to FlatList
Summary:
A nice bit of polish for apps is to update the separators between list items
when press actives the highlight (things get especially noticeable/ugly when
the separators are not full width and don't adjust). This can be difficult to
coordinate and update efficiently, so we bake the functionality into
`VirtualizedList`.

The approach taken here is a little different from `ListView`. We pass a new
`separators` object with `renderItem` that has easy-to-use callbacks for toggling
the 'highlighted' prop on both adjacent separators - they can be wired up
directly to the `onShow/HideUnderlay` props of `TouchableHighlight` (pit of
success and all that - we want those RN apps to be polished!), but we also
provide a more generic `separators.updateProps` method to set any custom
props. This also passes in `leadingItem` so more custom wiring can be done on
initial render (e.g. linking the highlight state with `Animated`).

This also moves the separator rendering into the `CellRenderer`. I think this might
also fix some subtle measurement bugs with the `onLayout` not capturing the
height of the separator, so that's nice too, but the main reason is to have
an easy place to store the state so we don't have to re-render the entire list
like `ListView` does. Instead we track references to the cells and call update
only on the two we care about so the feedback is instantaneous even with big,
heavy lists.

This diff also messes with a bunch of flow and updates the example to be more
like a standard list.

`SectionList` support is coming in a stacked diff.

**TestPlan**

Video demo:

https://youtu.be/uFE7qGA0mg4

Pretty sure this is backwards compatible....

Reviewed By: thechefchen

Differential Revision: D4833557

fbshipit-source-id: 685af46243ba13246bf280dae8a4223381ce8cea
2017-04-12 17:01:03 -07:00
..
UIExplorer Tease apart React and RCTBatchedBridge targets 2017-03-21 18:31:23 -07:00
UIExplorer-tvOS Apple TV support 2: Xcode projects and CI (scripts/objc-test.sh) 2016-10-05 07:28:44 -07:00
UIExplorer.xcodeproj Native Animated - Add tests on iOS 2017-03-28 09:16:58 -07:00
UIExplorerCxx.xcodeproj Fix warnings in React.xcodeproj 2017-03-23 11:36:17 -07:00
UIExplorerIntegrationTests Disable all of RCTRootViewIntegrationTests 2017-04-03 10:23:17 -07:00
UIExplorerUnitTests Native Animated - Add tests on iOS 2017-03-28 09:16:58 -07:00
android/app Use checkPropTypes instead of directly calling PropTypes 2017-03-22 16:04:12 -07:00
js Add support for updating adjacent separators on row highlight to FlatList 2017-04-12 17:01:03 -07:00
README.md Consolidate Running on Device (Android|iOS) Guides into one 2016-11-06 21:13:32 -08:00

README.md

UIExplorer

The UIExplorer is a sample app that showcases React Native views and modules.

Running this app

Before running the app, make sure you ran:

git clone https://github.com/facebook/react-native.git
cd react-native
npm install

Running on iOS

Mac OS and Xcode are required.

  • Open Examples/UIExplorer/UIExplorer.xcodeproj in Xcode
  • Hit the Run button

See Running on device if you want to use a physical device.

Running on Android

You'll need to have all the prerequisites (SDK, NDK) for Building React Native installed.

Start an Android emulator (Genymotion is recommended).

cd react-native
./gradlew :Examples:UIExplorer:android:app:installDebug
./packager/packager.sh

Note: Building for the first time can take a while.

Open the UIExplorer app in your emulator.

See Running on Device in case you want to use a physical device.

Running with Buck

Follow the same setup as running with gradle.

Install Buck from here.

Run the following commands from the react-native folder:

./gradlew :ReactAndroid:packageReactNdkLibsForBuck
buck fetch uiexplorer
buck install -r uiexplorer
./packager/packager.sh

Note: The native libs are still built using gradle. Full build with buck is coming soon(tm).

Built from source

Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.

This is different from apps created using react-native init which have a dependency on a specific version of React Native JS and native code, declared in a package.json file (and build.gradle for Android apps).