2020import com .facebook .react .uimanager .ThemedReactContext ;
2121import com .facebook .react .uimanager .UIManagerModule ;
2222import com .facebook .react .uimanager .ViewGroupManager ;
23+ import com .facebook .react .uimanager .ViewManagerDelegate ;
2324import com .facebook .react .uimanager .ViewProps ;
2425import com .facebook .react .uimanager .annotations .ReactProp ;
26+ import com .facebook .react .viewmanagers .AndroidSwipeRefreshLayoutManagerDelegate ;
27+ import com .facebook .react .viewmanagers .AndroidSwipeRefreshLayoutManagerInterface ;
2528import java .util .Map ;
2629
2730/**
2831 * ViewManager for {@link ReactSwipeRefreshLayout} which allows the user to "pull to refresh" a
2932 * child view. Emits an {@code onRefresh} event when this happens.
3033 */
3134@ ReactModule (name = REACT_CLASS )
32- public class SwipeRefreshLayoutManager extends ViewGroupManager <ReactSwipeRefreshLayout > {
35+ public class SwipeRefreshLayoutManager extends ViewGroupManager <ReactSwipeRefreshLayout >
36+ implements AndroidSwipeRefreshLayoutManagerInterface <ReactSwipeRefreshLayout > {
3337
3438 public static final String REACT_CLASS = "AndroidSwipeRefreshLayout" ;
3539
40+ private final ViewManagerDelegate <ReactSwipeRefreshLayout > mDelegate ;
41+
42+ public SwipeRefreshLayoutManager () {
43+ mDelegate = new AndroidSwipeRefreshLayoutManagerDelegate <>(this );
44+ }
45+
3646 @ Override
3747 protected ReactSwipeRefreshLayout createViewInstance (ThemedReactContext reactContext ) {
3848 return new ReactSwipeRefreshLayout (reactContext );
@@ -43,11 +53,13 @@ public String getName() {
4353 return REACT_CLASS ;
4454 }
4555
56+ @ Override
4657 @ ReactProp (name = ViewProps .ENABLED , defaultBoolean = true )
4758 public void setEnabled (ReactSwipeRefreshLayout view , boolean enabled ) {
4859 view .setEnabled (enabled );
4960 }
5061
62+ @ Override
5163 @ ReactProp (name = "colors" , customType = "ColorArray" )
5264 public void setColors (ReactSwipeRefreshLayout view , @ Nullable ReadableArray colors ) {
5365 if (colors != null ) {
@@ -61,9 +73,16 @@ public void setColors(ReactSwipeRefreshLayout view, @Nullable ReadableArray colo
6173 }
6274 }
6375
64- @ ReactProp (name = "progressBackgroundColor" , defaultInt = Color .TRANSPARENT , customType = "Color" )
65- public void setProgressBackgroundColor (ReactSwipeRefreshLayout view , int color ) {
66- view .setProgressBackgroundColorSchemeColor (color );
76+ @ Override
77+ @ ReactProp (name = "progressBackgroundColor" , customType = "Color" )
78+ public void setProgressBackgroundColor (ReactSwipeRefreshLayout view , Integer color ) {
79+ view .setProgressBackgroundColorSchemeColor (color == null ? Color .TRANSPARENT : color );
80+ }
81+
82+ // TODO(T46143833): Remove this method once the 'size' prop has been migrated to String in JS.
83+ @ Override
84+ public void setSize (ReactSwipeRefreshLayout view , int value ) {
85+ view .setSize (value );
6786 }
6887
6988 // This prop temporarily takes both 0 and 1 as well as 'default' and 'large'.
@@ -90,11 +109,13 @@ public void setSize(ReactSwipeRefreshLayout view, Dynamic size) {
90109 }
91110 }
92111
112+ @ Override
93113 @ ReactProp (name = "refreshing" )
94114 public void setRefreshing (ReactSwipeRefreshLayout view , boolean refreshing ) {
95115 view .setRefreshing (refreshing );
96116 }
97117
118+ @ Override
98119 @ ReactProp (name = "progressViewOffset" , defaultFloat = 0 )
99120 public void setProgressViewOffset (final ReactSwipeRefreshLayout view , final float offset ) {
100121 view .setProgressViewOffset (offset );
@@ -129,4 +150,9 @@ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
129150 .put ("topRefresh" , MapBuilder .of ("registrationName" , "onRefresh" ))
130151 .build ();
131152 }
153+
154+ @ Override
155+ protected ViewManagerDelegate <ReactSwipeRefreshLayout > getDelegate () {
156+ return mDelegate ;
157+ }
132158}
0 commit comments