Expose in public interface

Summary:
Allows you to do:
```
var { RecyclerViewBackedScrollView } = require('react-native')
```

Rather than:
```
var RecyclerViewBackedScrollView = require('react-native/Libraries/Components/ScrollView/RecyclerViewBackedScrollView')
```

Also...

- Export `ScrollView` by default rather than `UnimplementedView` for `RecyclerViewBackedScrollView` on iOS -- this makes it easier on the user, so you don't have to always do a conditional for: `if IOS then use ScrollView else use RecyclerViewBackedScrollView`. I can't think of a case where this would lead to undesirable behaviour.
- Add `RecyclerViewBackedScrollView` to `MainReactPackage`
- Fix an issue with `MapView` that threw a red-screen when trying to access constants on Android because there is no `MapView` in open source and MapView.js doesn't have a platform extension.
Closes https://github.com/facebook/react-native/pull/4514

Reviewed By: svcscm

Differential Revision: D2753466

Pulled By: mkonicek

fb-gh-sync-id: 0b6e2133975c911d5117e7531cb9093faf314c52
This commit is contained in:
Brent Vatne 2015-12-22 09:02:12 -08:00 committed by facebook-github-bot-3
parent 15aa146255
commit 6df737d1e7
6 changed files with 24 additions and 19 deletions

View File

@ -21,6 +21,7 @@ var {
ListView, ListView,
TouchableHighlight, TouchableHighlight,
StyleSheet, StyleSheet,
RecyclerViewBackedScrollView,
Text, Text,
View, View,
} = React; } = React;
@ -55,6 +56,7 @@ var ListViewSimpleExample = React.createClass({
<ListView <ListView
dataSource={this.state.dataSource} dataSource={this.state.dataSource}
renderRow={this._renderRow} renderRow={this._renderRow}
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
/> />
</UIExplorerPage> </UIExplorerPage>
); );
@ -62,9 +64,7 @@ var ListViewSimpleExample = React.createClass({
_renderRow: function(rowData: string, sectionID: number, rowID: number) { _renderRow: function(rowData: string, sectionID: number, rowID: number) {
var rowHash = Math.abs(hashCode(rowData)); var rowHash = Math.abs(hashCode(rowData));
var imgSource = { var imgSource = THUMB_URLS[rowHash % THUMB_URLS.length];
uri: THUMB_URLS[rowHash % THUMB_URLS.length],
};
return ( return (
<TouchableHighlight onPress={() => this._pressRow(rowID)}> <TouchableHighlight onPress={() => this._pressRow(rowID)}>
<View> <View>
@ -98,18 +98,18 @@ var ListViewSimpleExample = React.createClass({
}); });
var THUMB_URLS = [ var THUMB_URLS = [
'Thumbnails/like.png', require('./Thumbnails/like.png'),
'Thumbnails/dislike.png', require('./Thumbnails/dislike.png'),
'Thumbnails/call.png', require('./Thumbnails/call.png'),
'Thumbnails/fist.png', require('./Thumbnails/fist.png'),
'Thumbnails/bandaged.png', require('./Thumbnails/bandaged.png'),
'Thumbnails/flowers.png', require('./Thumbnails/flowers.png'),
'Thumbnails/heart.png', require('./Thumbnails/heart.png'),
'Thumbnails/liking.png', require('./Thumbnails/liking.png'),
'Thumbnails/party.png', require('./Thumbnails/party.png'),
'Thumbnails/poke.png', require('./Thumbnails/poke.png'),
'Thumbnails/superlike.png', require('./Thumbnails/superlike.png'),
'Thumbnails/victory.png', require('./Thumbnails/victory.png'),
]; ];
var LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.'; var LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';

View File

@ -24,6 +24,7 @@ var UIExplorerListBase = require('./UIExplorerListBase');
var COMPONENTS = [ var COMPONENTS = [
require('./ImageExample'), require('./ImageExample'),
require('./ListViewExample'),
require('./ProgressBarAndroidExample'), require('./ProgressBarAndroidExample'),
require('./ScrollViewSimpleExample'), require('./ScrollViewSimpleExample'),
require('./SwitchAndroidExample'), require('./SwitchAndroidExample'),

View File

@ -5,4 +5,4 @@
*/ */
'use strict'; 'use strict';
module.exports = require('UnimplementedView'); module.exports = require('ScrollView');

View File

@ -32,6 +32,7 @@ var ReactNative = {
get SnapshotViewIOS() { return require('SnapshotViewIOS'); }, get SnapshotViewIOS() { return require('SnapshotViewIOS'); },
get Switch() { return require('Switch'); }, get Switch() { return require('Switch'); },
get PullToRefreshViewAndroid() { return require('PullToRefreshViewAndroid'); }, get PullToRefreshViewAndroid() { return require('PullToRefreshViewAndroid'); },
get RecyclerViewBackedScrollView() { return require('RecyclerViewBackedScrollView'); },
get SwitchAndroid() { return require('SwitchAndroid'); }, get SwitchAndroid() { return require('SwitchAndroid'); },
get SwitchIOS() { return require('SwitchIOS'); }, get SwitchIOS() { return require('SwitchIOS'); },
get TabBarIOS() { return require('TabBarIOS'); }, get TabBarIOS() { return require('TabBarIOS'); },
@ -101,7 +102,7 @@ var ReactNative = {
get createFragment() { return require('ReactFragment').create; }, get createFragment() { return require('ReactFragment').create; },
get update() { return require('update'); }, get update() { return require('update'); },
}, },
// Note: this must be placed last to prevent eager // Note: this must be placed last to prevent eager
// evaluation of the getter-wrapped submodules above // evaluation of the getter-wrapped submodules above
...require('React'), ...require('React'),
@ -109,11 +110,11 @@ var ReactNative = {
if (__DEV__) { if (__DEV__) {
Object.defineProperty(ReactNative.addons, 'Perf', { Object.defineProperty(ReactNative.addons, 'Perf', {
enumerable: true, enumerable: true,
get: () => require('ReactDefaultPerf'), get: () => require('ReactDefaultPerf'),
}); });
Object.defineProperty(ReactNative.addons, 'TestUtils', { Object.defineProperty(ReactNative.addons, 'TestUtils', {
enumerable: true, enumerable: true,
get: () => require('ReactTestUtils'), get: () => require('ReactTestUtils'),
}); });
} }

View File

@ -44,6 +44,7 @@ var ReactNative = Object.assign(Object.create(require('React')), {
SnapshotViewIOS: require('SnapshotViewIOS'), SnapshotViewIOS: require('SnapshotViewIOS'),
Switch: require('Switch'), Switch: require('Switch'),
PullToRefreshViewAndroid: require('PullToRefreshViewAndroid'), PullToRefreshViewAndroid: require('PullToRefreshViewAndroid'),
RecyclerViewBackedScrollView: require('RecyclerViewBackedScrollView'),
SwitchAndroid: require('SwitchAndroid'), SwitchAndroid: require('SwitchAndroid'),
SwitchIOS: require('SwitchIOS'), SwitchIOS: require('SwitchIOS'),
TabBarIOS: require('TabBarIOS'), TabBarIOS: require('TabBarIOS'),

View File

@ -30,6 +30,7 @@ import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.drawer.ReactDrawerLayoutManager; import com.facebook.react.views.drawer.ReactDrawerLayoutManager;
import com.facebook.react.views.image.ReactImageManager; import com.facebook.react.views.image.ReactImageManager;
import com.facebook.react.views.progressbar.ReactProgressBarViewManager; import com.facebook.react.views.progressbar.ReactProgressBarViewManager;
import com.facebook.react.views.recyclerview.RecyclerViewBackedScrollViewManager;
import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager; import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager;
import com.facebook.react.views.scroll.ReactScrollViewManager; import com.facebook.react.views.scroll.ReactScrollViewManager;
import com.facebook.react.views.switchview.ReactSwitchManager; import com.facebook.react.views.switchview.ReactSwitchManager;
@ -78,6 +79,7 @@ public class MainReactPackage implements ReactPackage {
new ReactImageManager(), new ReactImageManager(),
new ReactProgressBarViewManager(), new ReactProgressBarViewManager(),
new ReactRawTextManager(), new ReactRawTextManager(),
new RecyclerViewBackedScrollViewManager(),
new ReactScrollViewManager(), new ReactScrollViewManager(),
new ReactSwitchManager(), new ReactSwitchManager(),
new ReactTextInputManager(), new ReactTextInputManager(),