diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index 553a3a46ba0..8134b8a486f 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -61,4 +61,5 @@ export const Commands: NativeCommands = codegenNativeCommands({ export default (codegenNativeComponent('PullToRefreshView', { paperComponentName: 'RCTRefreshControl', + excludedPlatform: 'android', }): HostComponent); diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index 43ebf012308..c0d600c0e87 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -16,7 +16,10 @@ const React = require('react'); import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {ViewProps} from '../View/ViewPropTypes'; import AndroidSwipeRefreshLayoutNativeComponent from './AndroidSwipeRefreshLayoutNativeComponent'; -import PullToRefreshViewNativeComponent from './PullToRefreshViewNativeComponent'; + +import PullToRefreshViewNativeComponent, { + Commands as PullToRefreshCommands, +} from './PullToRefreshViewNativeComponent'; let RefreshLayoutConsts: any; if (Platform.OS === 'android') { @@ -138,6 +141,8 @@ class RefreshControl extends React.Component { _setNativePropsOnRef: ?({refreshing: boolean, ...}) => void; _lastNativeRefreshing = false; + _nativeRef: ?React.ElementRef; + componentDidMount() { this._lastNativeRefreshing = this.props.refreshing; } @@ -152,16 +157,26 @@ class RefreshControl extends React.Component { this.props.refreshing !== this._lastNativeRefreshing && this._setNativePropsOnRef ) { - this._setNativePropsOnRef({ - refreshing: this.props.refreshing, - }); + if (Platform.OS === 'android') { + this._setNativePropsOnRef({ + refreshing: this.props.refreshing, + }); + } else if (this._nativeRef) { + PullToRefreshCommands.setNativeRefreshing( + this._nativeRef, + this.props.refreshing, + ); + } this._lastNativeRefreshing = this.props.refreshing; } } render(): React.Node { - const setRef = ref => - (this._setNativePropsOnRef = ref ? ref.setNativeProps.bind(ref) : null); + const setRef = ref => { + this._setNativePropsOnRef = ref ? ref.setNativeProps.bind(ref) : null; + this._nativeRef = ref; + }; + if (Platform.OS === 'ios') { const { enabled, diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java deleted file mode 100644 index 7425904720b..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java +++ /dev/null @@ -1,50 +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. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; - -public class PullToRefreshViewManagerDelegate & PullToRefreshViewManagerInterface> extends BaseViewManagerDelegate { - public PullToRefreshViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "tintColor": - mViewManager.setTintColor(view, value == null ? null : ((Double) value).intValue()); - break; - case "titleColor": - mViewManager.setTitleColor(view, value == null ? null : ((Double) value).intValue()); - break; - case "title": - mViewManager.setTitle(view, value == null ? null : (String) value); - break; - case "refreshing": - mViewManager.setRefreshing(view, value == null ? false : (boolean) value); - break; - default: - super.setProperty(view, propName, value); - } - } - - public void receiveCommand(PullToRefreshViewManagerInterface viewManager, T view, String commandName, ReadableArray args) { - switch (commandName) { - case "setNativeRefreshing": - viewManager.setNativeRefreshing(view, args.getBoolean(0)); - break; - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java deleted file mode 100644 index 4f40ee89cbb..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java +++ /dev/null @@ -1,21 +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. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface PullToRefreshViewManagerInterface { - void setTintColor(T view, @Nullable Integer value); - void setTitleColor(T view, @Nullable Integer value); - void setTitle(T view, @Nullable String value); - void setRefreshing(T view, boolean value); - void setNativeRefreshing(T view, boolean refreshing); -}