Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.facebook.react.module.annotations.ReactModule

@ReactModule(name = NativeSampleModuleSpec.NAME)
public class NativeSampleModule(reactContext: ReactApplicationContext?) :
ReactContextBaseJavaModule(reactContext) {
ReactContextBaseJavaModule(reactContext) {

override fun getName(): String = NAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.facebook.react.uimanager.ViewManager
public class OSSLibraryExamplePackage : ReactPackage {
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
listOf(NativeSampleModule(reactContext))
listOf(NativeSampleModule(reactContext))

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
listOf(SampleNativeComponentViewManager())
listOf(SampleNativeComponentViewManager())
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.facebook.react.viewmanagers.SampleNativeComponentManagerInterface
/** Legacy View manager (non Fabric compatible) for {@link SampleNativeView} components. */
@ReactModule(name = SampleNativeComponentViewManager.REACT_CLASS)
internal class SampleNativeComponentViewManager :
SimpleViewManager<SampleNativeView>(), SampleNativeComponentManagerInterface<SampleNativeView> {
SimpleViewManager<SampleNativeView>(), SampleNativeComponentManagerInterface<SampleNativeView> {

override fun getName(): String = REACT_CLASS

Expand All @@ -41,7 +41,7 @@ internal class SampleNativeComponentViewManager :
}

override fun createViewInstance(reactContext: ThemedReactContext): SampleNativeView =
SampleNativeView(reactContext)
SampleNativeView(reactContext)

@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
override fun changeBackgroundColor(view: SampleNativeView, color: String) {
Expand All @@ -52,20 +52,23 @@ internal class SampleNativeComponentViewManager :

override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
return mapOf(
"onColorChanged" to
"onColorChanged" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"bubbled" to "onColorChanged",
"captured" to "onColorChangedCapture",
)),
"topIntArrayChanged" to
"bubbled" to "onColorChanged",
"captured" to "onColorChangedCapture"
)
),
"topIntArrayChanged" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"bubbled" to "topIntArrayChanged",
"captured" to "topIntArrayChangedCapture",
)))
"bubbled" to "topIntArrayChanged",
"captured" to "topIntArrayChangedCapture"
)
)
)
}

@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
Expand All @@ -89,7 +92,7 @@ internal class SampleNativeComponentViewManager :
}

override fun getCommandsMap(): Map<String, Int> =
mapOf("changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR)
mapOf("changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR)

companion object {
const val REACT_CLASS = "SampleNativeComponent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ public class SampleNativeView(context: ThemedReactContext) : View(context) {
}

val payload =
Arguments.createMap().apply {
putArray("values", newIntArray)
putArray("boolValues", newBoolArray)
putArray("floats", newFloatArray)
putArray("doubles", newDoubleArray)
putArray("yesNos", newYesNoArray)
putArray("strings", newStringArray)
putArray("latLons", newObjectArray)
putArray("multiArrays", newArrayArray)
}
Arguments.createMap().apply {
putArray("values", newIntArray)
putArray("boolValues", newBoolArray)
putArray("floats", newFloatArray)
putArray("doubles", newDoubleArray)
putArray("yesNos", newYesNoArray)
putArray("strings", newStringArray)
putArray("latLons", newObjectArray)
putArray("multiArrays", newArrayArray)
}

val reactContext = context as ReactContext
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
Expand All @@ -86,9 +86,9 @@ public class SampleNativeView(context: ThemedReactContext) : View(context) {
}

private inner class OnIntArrayChangedEvent(
surfaceId: Int,
viewId: Int,
private val payload: WritableMap
surfaceId: Int,
viewId: Int,
private val payload: WritableMap
) : Event<OnIntArrayChangedEvent>(surfaceId, viewId) {
override fun getEventName() = "topIntArrayChanged"

Expand Down
Loading