diff --git a/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js similarity index 61% rename from Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js rename to Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index 1a20adadb2b..5274896fb75 100644 --- a/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -10,13 +10,18 @@ 'use strict'; +import type { + BubblingEvent, + WithDefault, + CodegenNativeComponent, +} from '../../Types/CodegenTypes'; + const requireNativeComponent = require('../../ReactNative/requireNativeComponent'); import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {ViewProps} from '../View/ViewPropTypes'; -import type {NativeComponent} from '../../Renderer/shims/ReactNative'; -export type NativeProps = $ReadOnly<{| +type NativeProps = $ReadOnly<{| ...ViewProps, /** @@ -30,21 +35,26 @@ export type NativeProps = $ReadOnly<{| /** * The title displayed under the refresh indicator. */ - title?: ?string, + title?: ?WithDefault, /** * Called when the view starts refreshing. */ - onRefresh?: ?() => mixed, + onRefresh?: ?(event: BubblingEvent) => mixed, /** * Whether the view should be indicating an active refresh. */ - refreshing: boolean, + refreshing: WithDefault, |}>; -type PullToRefreshView = Class>; +type PullToRefreshViewType = CodegenNativeComponent< + 'PullToRefreshView', + NativeProps, +>; +// TODO: Switch this over to require('./PullToRefreshNativeViewConfig') +// once the native components are renamed in paper and fabric module.exports = ((requireNativeComponent( 'RCTRefreshControl', -): any): PullToRefreshView); +): any): PullToRefreshViewType); diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeViewConfig.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeViewConfig.js new file mode 100644 index 00000000000..27a1071076e --- /dev/null +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeViewConfig.js @@ -0,0 +1,53 @@ + +/** + * 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. + * + * @flow + */ + +'use strict'; + +const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry'); +const ReactNativeViewViewConfig = require('ReactNativeViewViewConfig'); +const verifyComponentAttributeEquivalence = require('verifyComponentAttributeEquivalence'); + +const PullToRefreshViewViewConfig = { + uiViewClassName: 'PullToRefreshView', + Commands: {}, + + bubblingEventTypes: { + ...ReactNativeViewViewConfig.bubblingEventTypes, + + topRefresh: { + phasedRegistrationNames: { + captured: 'onRefreshCapture', + bubbled: 'onRefresh', + }, + }, + }, + + directEventTypes: { + ...ReactNativeViewViewConfig.directEventTypes, + }, + + validAttributes: { + ...ReactNativeViewViewConfig.validAttributes, + tintColor: { process: require('processColor') }, + titleColor: { process: require('processColor') }, + title: true, + refreshing: true, + onRefresh: true, + }, +}; + +verifyComponentAttributeEquivalence('PullToRefreshView', PullToRefreshViewViewConfig); + +ReactNativeViewConfigRegistry.register( + 'PullToRefreshView', + () => PullToRefreshViewViewConfig, +); + +module.exports = 'PullToRefreshView'; diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index cb432db07b6..f6ed8d9e71c 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -12,10 +12,9 @@ const Platform = require('../../Utilities/Platform'); const React = require('react'); -const {NativeComponent} = require('../../Renderer/shims/ReactNative'); const AndroidSwipeRefreshLayoutNativeComponent = require('./AndroidSwipeRefreshLayoutNativeComponent'); -const RCTRefreshControlNativeComponent = require('./RCTRefreshControlNativeComponent'); +const PullToRefreshViewNativeComponent = require('./PullToRefreshViewNativeComponent'); const nullthrows = require('nullthrows'); import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; @@ -175,7 +174,7 @@ class RefreshControl extends React.Component { ...props } = this.props; return ( -