From f02feb8d3872b7964fd725346c4ea2560fa2acae Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 19 May 2019 17:40:45 -0700 Subject: [PATCH] Fabric: Codegen for PullToRefresh component Summary: Straightforward. Rick, I rename some stuff, I hope you are cool with that. Reviewed By: mdvacca Differential Revision: D15403306 fbshipit-source-id: 1dbd34060052a9bd39ed4211010f14b76fffcde6 --- ...peSchema.js => PullToRefreshViewSchema.js} | 9 +++--- .../RCTRefreshControlNativeComponent.js | 4 +-- .../RNPullToRefreshViewComponentView.mm | 9 +++--- .../PullToRefreshViewComponentDescriptor.h | 20 ------------ .../PullToRefreshViewEventEmitter.cpp | 18 ----------- .../PullToRefreshViewEventEmitter.h | 25 --------------- .../scrollview/PullToRefreshViewProps.cpp | 28 ----------------- .../scrollview/PullToRefreshViewProps.h | 31 ------------------- .../PullToRefreshViewShadowNode.cpp | 16 ---------- .../scrollview/PullToRefreshViewShadowNode.h | 31 ------------------- 10 files changed, 10 insertions(+), 181 deletions(-) rename Libraries/Components/RefreshControl/{RCTRefreshControlNativeTypeSchema.js => PullToRefreshViewSchema.js} (91%) delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewComponentDescriptor.h delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.cpp delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.h delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.cpp delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.h delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.cpp delete mode 100644 ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.h diff --git a/Libraries/Components/RefreshControl/RCTRefreshControlNativeTypeSchema.js b/Libraries/Components/RefreshControl/PullToRefreshViewSchema.js similarity index 91% rename from Libraries/Components/RefreshControl/RCTRefreshControlNativeTypeSchema.js rename to Libraries/Components/RefreshControl/PullToRefreshViewSchema.js index 7938004ac2c..b6b08102ee8 100644 --- a/Libraries/Components/RefreshControl/RCTRefreshControlNativeTypeSchema.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewSchema.js @@ -12,11 +12,11 @@ import type {SchemaType} from '../../../packages/react-native-codegen/src/CodegenSchema.js'; -const RCTRefreshControlNativeTypeSchema: SchemaType = { +const PullToRefreshViewSchema: SchemaType = { modules: { - RCTRefreshControlNativeType: { + PullToRefreshView: { components: { - RCTRefreshControlNativeType: { + PullToRefreshView: { extendsProps: [ { type: 'ReactNativeBuiltInType', @@ -27,7 +27,6 @@ const RCTRefreshControlNativeTypeSchema: SchemaType = { { name: 'onRefresh', optional: true, - bubblingType: 'bubble', typeAnnotation: { type: 'EventTypeAnnotation', @@ -78,4 +77,4 @@ const RCTRefreshControlNativeTypeSchema: SchemaType = { }, }; -module.exports = RCTRefreshControlNativeTypeSchema; +module.exports = PullToRefreshViewSchema; diff --git a/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js b/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js index 8c6495a8868..1a20adadb2b 100644 --- a/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js +++ b/Libraries/Components/RefreshControl/RCTRefreshControlNativeComponent.js @@ -43,8 +43,8 @@ export type NativeProps = $ReadOnly<{| refreshing: boolean, |}>; -type RCTRefreshControlNativeType = Class>; +type PullToRefreshView = Class>; module.exports = ((requireNativeComponent( 'RCTRefreshControl', -): any): RCTRefreshControlNativeType); +): any): PullToRefreshView); diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RNPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RNPullToRefreshViewComponentView.mm index 2ab27b56f79..c43b2f150f4 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RNPullToRefreshViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RNPullToRefreshViewComponentView.mm @@ -7,14 +7,13 @@ #import "RNPullToRefreshViewComponentView.h" -#import -#import -#import +#import +#import +#import #import #import - using namespace facebook::react; @implementation RNPullToRefreshViewComponentView { @@ -81,7 +80,7 @@ using namespace facebook::react; - (void)handleUIControlEventValueChanged { - std::static_pointer_cast(_eventEmitter)->onRefresh(); + std::static_pointer_cast(_eventEmitter)->onRefresh({}); } - (void)_updateTitle diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewComponentDescriptor.h b/ReactCommon/fabric/components/scrollview/PullToRefreshViewComponentDescriptor.h deleted file mode 100644 index 4e9bcd039d7..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewComponentDescriptor.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using PullToRefreshViewComponentDescriptor = - ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.cpp b/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.cpp deleted file mode 100644 index 43784bde601..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/** - * 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. - */ - -#include "PullToRefreshViewEventEmitter.h" - -namespace facebook { -namespace react { - -void PullToRefreshViewEventEmitter::onRefresh() const { - dispatchEvent("refresh"); -} - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.h b/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.h deleted file mode 100644 index 77fde7aff7f..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewEventEmitter.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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. - */ -#pragma once - -#include - -#include -#include - -namespace facebook { -namespace react { - -class PullToRefreshViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - void onRefresh() const; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.cpp b/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.cpp deleted file mode 100644 index 38a74f8aa80..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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. - */ - -#include "PullToRefreshViewProps.h" - -#include -#include - -namespace facebook { -namespace react { - -PullToRefreshViewProps::PullToRefreshViewProps( - PullToRefreshViewProps const &sourceProps, - RawProps const &rawProps) - : ViewProps(sourceProps, rawProps), - refreshing( - convertRawProp(rawProps, "refreshing", sourceProps.refreshing)), - tintColor(convertRawProp(rawProps, "tintColor", sourceProps.tintColor)), - title(convertRawProp(rawProps, "title", sourceProps.title)), - titleColor( - convertRawProp(rawProps, "titleColor", sourceProps.titleColor)) {} - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.h b/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.h deleted file mode 100644 index b173ad036a8..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewProps.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - */ - -#pragma once - -#include - -namespace facebook { -namespace react { - -class PullToRefreshViewProps final : public ViewProps { - public: - PullToRefreshViewProps() = default; - PullToRefreshViewProps( - PullToRefreshViewProps const &sourceProps, - RawProps const &rawProps); - -#pragma mark - Props - - bool const refreshing{}; - SharedColor const tintColor{}; - std::string const title{}; - SharedColor const titleColor{}; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.cpp b/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.cpp deleted file mode 100644 index e041395c48d..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/** - * 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. - */ - -#include "PullToRefreshViewShadowNode.h" - -namespace facebook { -namespace react { - -const char PullToRefreshViewComponentName[] = "RefreshControl"; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.h b/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.h deleted file mode 100644 index 38a3725841a..00000000000 --- a/ReactCommon/fabric/components/scrollview/PullToRefreshViewShadowNode.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - */ - -#pragma once - -#include -#include -#include - -namespace facebook { -namespace react { - -extern const char PullToRefreshViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -class PullToRefreshViewShadowNode final : public ConcreteViewShadowNode< - PullToRefreshViewComponentName, - PullToRefreshViewProps, - PullToRefreshViewEventEmitter> { - public: - using ConcreteViewShadowNode::ConcreteViewShadowNode; -}; - -} // namespace react -} // namespace facebook