diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 01c875b378bf24..c84e8b87f72e8d 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -7484,6 +7484,8 @@ public class com/facebook/react/views/switchview/ReactSwitchManager : com/facebo public fun measure (Landroid/content/Context;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;[F)J public synthetic fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V public fun receiveCommand (Lcom/facebook/react/views/switchview/ReactSwitch;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public synthetic fun setBackgroundColor (Landroid/view/View;I)V + public fun setBackgroundColor (Lcom/facebook/react/views/switchview/ReactSwitch;I)V public synthetic fun setDisabled (Landroid/view/View;Z)V public fun setDisabled (Lcom/facebook/react/views/switchview/ReactSwitch;Z)V public synthetic fun setEnabled (Landroid/view/View;Z)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.java index 9fc2d32315eab5..f1c3b353bff981 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchManager.java @@ -11,6 +11,7 @@ import android.content.Context; import android.view.View; import android.widget.CompoundButton; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReactContext; @@ -117,6 +118,11 @@ protected ReactSwitch createViewInstance(ThemedReactContext context) { return view; } + @Override + public void setBackgroundColor(ReactSwitch view, @ColorInt int backgroundColor) { + view.setBackgroundColor(backgroundColor); + } + @Override @ReactProp(name = "disabled", defaultBoolean = false) public void setDisabled(ReactSwitch view, boolean disabled) { diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt index 344e92744df35b..8d66de877572fd 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeViewManager.kt @@ -8,6 +8,7 @@ package com.facebook.react.uiapp.component import android.graphics.Color +import androidx.annotation.ColorInt import com.facebook.react.bridge.ReadableArray import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.SimpleViewManager @@ -68,6 +69,10 @@ internal class MyNativeViewManager : view.emitOnArrayChangedEvent(values) } + override fun setBackgroundColor(view: MyNativeView, @ColorInt backgroundColor: Int) { + view.setBackgroundColor(backgroundColor) + } + override fun getExportedCustomBubblingEventTypeConstants(): Map = mapOf( "topIntArrayChanged" to