From b7fac14b6457ae49412cf7d0923250ce0f4f59ce Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Tue, 5 Nov 2019 19:07:06 -0800 Subject: [PATCH] Add view config for AndroidHorizontalScrollView Summary: Adding a handwritten view config for AndroidHorizontalScrollView, the native component that's used with `` on Android. Native props are the same as `RCTScrollView`, so I'm reusing the type for that. Changelog: [Internal] Reviewed By: rickhanlonii Differential Revision: D18284517 fbshipit-source-id: 7c81f72440b93d611f9574ad2c01a96530d07bf7 --- ...roidHorizontalScrollViewNativeComponent.js | 56 +++++++++++++++++++ Libraries/Components/ScrollView/ScrollView.js | 5 +- 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js new file mode 100644 index 00000000000..22da77e56f1 --- /dev/null +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -0,0 +1,56 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig'); +const requireNativeComponent = require('../../ReactNative/requireNativeComponent'); + +import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type {ScrollViewNativeProps} from './ScrollViewNativeComponentType'; + +const AndroidHorizontalScrollViewViewConfig = { + uiViewClassName: 'AndroidHorizontalScrollView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: { + decelerationRate: true, + disableIntervalMomentum: true, + endFillColor: {process: require('../../StyleSheet/processColor')}, + fadingEdgeLength: true, + nestedScrollEnabled: true, + overScrollMode: true, + pagingEnabled: true, + persistentScrollbar: true, + scrollEnabled: true, + scrollPerfTag: true, + sendMomentumEvents: true, + showsHorizontalScrollIndicator: true, + snapToEnd: true, + snapToInterval: true, + snapToStart: true, + snapToOffsets: true, + }, +}; + +let AndroidHorizontalScrollViewNativeComponent; +if (global.RN$Bridgeless) { + registerGeneratedViewConfig( + 'AndroidHorizontalScrollView', + AndroidHorizontalScrollViewViewConfig, + ); + AndroidHorizontalScrollViewNativeComponent = 'AndroidHorizontalScrollView'; +} else { + AndroidHorizontalScrollViewNativeComponent = requireNativeComponent( + 'AndroidHorizontalScrollView', + ); +} + +export default ((AndroidHorizontalScrollViewNativeComponent: any): HostComponent); diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 906a2583a07..55859b9efec 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -44,6 +44,7 @@ import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeade import ScrollViewNativeComponent from './ScrollViewNativeComponent'; import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent'; +import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrollViewNativeComponent'; let AndroidScrollView; let AndroidHorizontalScrollContentView; @@ -53,9 +54,7 @@ let RCTScrollContentView; if (Platform.OS === 'android') { AndroidScrollView = ScrollViewNativeComponent; - AndroidHorizontalScrollView = requireNativeComponent( - 'AndroidHorizontalScrollView', - ); + AndroidHorizontalScrollView = AndroidHorizontalScrollViewNativeComponent; AndroidHorizontalScrollContentView = requireNativeComponent( 'AndroidHorizontalScrollContentView', );