Add setNativeRefreshing command to SwipeRefreshLayoutManager

Summary:
As a part of the migration from `setNativeProps` in Fabric and Paper, we are replacing it by view commands in the RefreshControl component on Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18475428

fbshipit-source-id: f2e978d88e34c74771f8582247ecc82b2b942557
This commit is contained in:
Oleksandr Melnykov
2019-11-13 10:21:04 -08:00
committed by Facebook Github Bot
parent cd1e34d4a2
commit c5c3264a94
4 changed files with 44 additions and 1 deletions
@@ -45,4 +45,12 @@ public class AndroidSwipeRefreshLayoutManagerDelegate<T extends View, U extends
super.setProperty(view, propName, value);
}
}
public void receiveCommand(AndroidSwipeRefreshLayoutManagerInterface<T> viewManager, T view, String commandName, ReadableArray args) {
switch (commandName) {
case "setNativeRefreshing":
viewManager.setNativeRefreshing(view, args.getBoolean(0));
break;
}
}
}
@@ -20,4 +20,5 @@ public interface AndroidSwipeRefreshLayoutManagerInterface<T extends View> {
void setSize(T view, int value);
void setProgressViewOffset(T view, float value);
void setRefreshing(T view, boolean value);
void setNativeRefreshing(T view, boolean value);
}
@@ -10,6 +10,7 @@ package com.facebook.react.views.swiperefresh;
import static com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager.REACT_CLASS;
import android.graphics.Color;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
@@ -122,6 +123,11 @@ public class SwipeRefreshLayoutManager extends ViewGroupManager<ReactSwipeRefres
view.setProgressViewOffset(offset);
}
@Override
public void setNativeRefreshing(ReactSwipeRefreshLayout view, boolean value) {
// TODO(T52835863): Implement when view commands start using delegates generated by JS.
}
@Override
protected void addEventEmitters(
final ThemedReactContext reactContext, final ReactSwipeRefreshLayout view) {
@@ -137,6 +143,18 @@ public class SwipeRefreshLayoutManager extends ViewGroupManager<ReactSwipeRefres
});
}
@Override
public void receiveCommand(
@NonNull ReactSwipeRefreshLayout root, String commandId, @Nullable ReadableArray args) {
switch (commandId) {
case "setNativeRefreshing":
if (args != null) {
setRefreshing(root, args.getBoolean(0));
}
break;
}
}
@Nullable
@Override
public Map<String, Object> getExportedViewConstants() {