From 0db54093a1dfc190abfb2d34ae3dd0f52559ebee Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 16 Oct 2023 08:52:05 -0700 Subject: [PATCH] Fix broken Fabric Interop example (#40942) Summary: The Fabric Interop example for Android is broken. This is due to the Kotlin conversion which moved the `Color.colorToHSV(color, hsv)` statement *after* the HSV array is read so the array is always [0,0,0]. I'm fixing it here. Changelog: [Internal] [Changed] - Fix broken Fabric Interop example Reviewed By: cipolleschi Differential Revision: D50264766 --- .../java/com/facebook/react/uiapp/component/MyNativeView.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.kt index 9f8a89a3e15238..a773f9af1cb3a0 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.kt @@ -22,7 +22,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter class MyNativeView(context: ThemedReactContext) : View(context) { private var currentColor = 0 private var background: GradientDrawable = GradientDrawable() - private var reactContext: ReactContext = context.getReactApplicationContext() + private var reactContext: ReactContext = context.reactApplicationContext override fun setBackgroundColor(color: Int) { if (color != currentColor) { @@ -34,13 +34,14 @@ class MyNativeView(context: ThemedReactContext) : View(context) { } fun setCornerRadius(cornerRadius: Float) { - background.setCornerRadius(cornerRadius) + background.cornerRadius = cornerRadius setBackground(background) } private fun emitNativeEvent(color: Int) { val event = Arguments.createMap() val hsv = FloatArray(3) + Color.colorToHSV(color, hsv) val backgroundColor = Arguments.createMap().apply { putDouble("hue", hsv[0].toDouble()) @@ -49,7 +50,6 @@ class MyNativeView(context: ThemedReactContext) : View(context) { putDouble("alpha", Color.alpha(color).toDouble()) } - Color.colorToHSV(color, hsv) event.putMap("backgroundColor", backgroundColor) reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, "onColorChanged", event)