Skip to content

Commit

Permalink
Refactor PointerEvents strings as constants (facebook#48537)
Browse files Browse the repository at this point in the history
Summary:

Refactor PointerEvents strings as constants

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D67924567
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 8, 2025
1 parent 7754d98 commit c02acfd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -798,62 +798,62 @@ private static void setPointerEventsFlag(
}

/* Experimental W3C Pointer events start */
@ReactProp(name = "onPointerEnter")
@ReactProp(name = ViewProps.ON_POINTER_ENTER)
public void setPointerEnter(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.ENTER, value);
}

@ReactProp(name = "onPointerEnterCapture")
@ReactProp(name = ViewProps.ON_POINTER_ENTER_CAPTURE)
public void setPointerEnterCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.ENTER_CAPTURE, value);
}

@ReactProp(name = "onPointerOver")
@ReactProp(name = ViewProps.ON_POINTER_OVER)
public void setPointerOver(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.OVER, value);
}

@ReactProp(name = "onPointerOverCapture")
@ReactProp(name = ViewProps.ON_POINTER_OVER_CAPTURE)
public void setPointerOverCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.OVER_CAPTURE, value);
}

@ReactProp(name = "onPointerOut")
@ReactProp(name = ViewProps.ON_POINTER_OUT)
public void setPointerOut(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.OUT, value);
}

@ReactProp(name = "onPointerOutCapture")
@ReactProp(name = ViewProps.ON_POINTER_OUT_CAPTURE)
public void setPointerOutCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.OUT_CAPTURE, value);
}

@ReactProp(name = "onPointerLeave")
@ReactProp(name = ViewProps.ON_POINTER_LEAVE)
public void setPointerLeave(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.LEAVE, value);
}

@ReactProp(name = "onPointerLeaveCapture")
@ReactProp(name = ViewProps.ON_POINTER_LEAVE_CAPTURE)
public void setPointerLeaveCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.LEAVE_CAPTURE, value);
}

@ReactProp(name = "onPointerMove")
@ReactProp(name = ViewProps.ON_POINTER_MOVE)
public void setPointerMove(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.MOVE, value);
}

@ReactProp(name = "onPointerMoveCapture")
@ReactProp(name = ViewProps.ON_POINTER_MOVE_CAPTURE)
public void setPointerMoveCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.MOVE_CAPTURE, value);
}

@ReactProp(name = "onClick")
@ReactProp(name = ViewProps.ON_CLICK)
public void setClick(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.CLICK, value);
}

@ReactProp(name = "onClickCapture")
@ReactProp(name = ViewProps.ON_CLICK_CAPTURE)
public void setClickCapture(@NonNull T view, boolean value) {
setPointerEventsFlag(view, PointerEventHelper.EVENT.CLICK_CAPTURE, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,23 @@ public abstract class BaseViewManagerDelegate<
ViewProps.Z_INDEX -> mViewManager.setZIndex(view, (value as Double?)?.toFloat() ?: 0.0f)

// Experimental pointer events
"onPointerEnter" -> mViewManager.setPointerEnter(view, value as Boolean? ?: false)
"onPointerEnterCapture" ->
ViewProps.ON_POINTER_ENTER -> mViewManager.setPointerEnter(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_ENTER_CAPTURE ->
mViewManager.setPointerEnterCapture(view, value as Boolean? ?: false)
"onPointerOver" -> mViewManager.setPointerOver(view, value as Boolean? ?: false)
"onPointerOverCapture" -> mViewManager.setPointerOverCapture(view, value as Boolean? ?: false)
"onPointerOut" -> mViewManager.setPointerOut(view, value as Boolean? ?: false)
"onPointerOutCapture" -> mViewManager.setPointerOutCapture(view, value as Boolean? ?: false)
"onPointerLeave" -> mViewManager.setPointerLeave(view, value as Boolean? ?: false)
"onPointerLeaveCapture" ->
ViewProps.ON_POINTER_OVER -> mViewManager.setPointerOver(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_OVER_CAPTURE ->
mViewManager.setPointerOverCapture(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_OUT -> mViewManager.setPointerOut(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_OUT_CAPTURE ->
mViewManager.setPointerOutCapture(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_LEAVE -> mViewManager.setPointerLeave(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_LEAVE_CAPTURE ->
mViewManager.setPointerLeaveCapture(view, value as Boolean? ?: false)
"onPointerMove" -> mViewManager.setPointerMove(view, value as Boolean? ?: false)
"onPointerMoveCapture" -> mViewManager.setPointerMoveCapture(view, value as Boolean? ?: false)
"onClick" -> mViewManager.setClick(view, value as Boolean? ?: false)
"onClickCapture" -> mViewManager.setClickCapture(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_MOVE -> mViewManager.setPointerMove(view, value as Boolean? ?: false)
ViewProps.ON_POINTER_MOVE_CAPTURE ->
mViewManager.setPointerMoveCapture(view, value as Boolean? ?: false)
ViewProps.ON_CLICK -> mViewManager.setClick(view, value as Boolean? ?: false)
ViewProps.ON_CLICK_CAPTURE -> mViewManager.setClickCapture(view, value as Boolean? ?: false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ public object ViewProps {
/** Used to locate views in end-to-end (UI) tests. */
public const val TEST_ID: String = "testID"
public const val NATIVE_ID: String = "nativeID"
internal const val ON_POINTER_ENTER = "onPointerEnter"
internal const val ON_POINTER_ENTER_CAPTURE = "onPointerEnterCapture"
internal const val ON_POINTER_OVER = "onPointerOver"
internal const val ON_POINTER_OVER_CAPTURE = "onPointerOverCapture"
internal const val ON_POINTER_OUT = "onPointerOut"
internal const val ON_POINTER_OUT_CAPTURE = "onPointerOutCapture"
internal const val ON_POINTER_LEAVE = "onPointerLeave"
internal const val ON_POINTER_LEAVE_CAPTURE = "onPointerLeaveCapture"
internal const val ON_POINTER_MOVE = "onPointerMove"
internal const val ON_POINTER_MOVE_CAPTURE = "onPointerMoveCapture"
internal const val ON_CLICK = "onClick"
internal const val ON_CLICK_CAPTURE = "onClickCapture"
@JvmField
public val BORDER_SPACING_TYPES: IntArray =
intArrayOf(
Expand Down

0 comments on commit c02acfd

Please sign in to comment.