|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +package com.facebook.react.uimanager |
| 9 | + |
| 10 | +import android.view.accessibility.AccessibilityEvent |
| 11 | +import android.widget.ImageView |
| 12 | +import com.facebook.react.uimanager.events.TouchEventType |
| 13 | +import com.facebook.react.uimanager.events.TouchEventType.Companion.getJSEventName |
| 14 | + |
| 15 | +/** Constants exposed to JS from [UIManagerModule]. */ |
| 16 | +internal object UIManagerModuleConstants { |
| 17 | + const val ACTION_DISMISSED: String = "dismissed" |
| 18 | + const val ACTION_ITEM_SELECTED: String = "itemSelected" |
| 19 | + |
| 20 | + @JvmField |
| 21 | + val bubblingEventTypeConstants: Map<String, Any> = |
| 22 | + mapOf( |
| 23 | + "topChange" to |
| 24 | + mapOf( |
| 25 | + "phasedRegistrationNames" to |
| 26 | + mapOf("bubbled" to "onChange", "captured" to "onChangeCapture")), |
| 27 | + "topSelect" to |
| 28 | + mapOf( |
| 29 | + "phasedRegistrationNames" to |
| 30 | + mapOf("bubbled" to "onSelect", "captured" to "onSelectCapture")), |
| 31 | + TouchEventType.getJSEventName(TouchEventType.START) to |
| 32 | + mapOf( |
| 33 | + "phasedRegistrationNames" to |
| 34 | + mapOf("bubbled" to "onTouchStart", "captured" to "onTouchStartCapture")), |
| 35 | + TouchEventType.getJSEventName(TouchEventType.MOVE) to |
| 36 | + mapOf( |
| 37 | + "phasedRegistrationNames" to |
| 38 | + mapOf("bubbled" to "onTouchMove", "captured" to "onTouchMoveCapture")), |
| 39 | + TouchEventType.getJSEventName(TouchEventType.END) to |
| 40 | + mapOf( |
| 41 | + "phasedRegistrationNames" to |
| 42 | + mapOf("bubbled" to "onTouchEnd", "captured" to "onTouchEndCapture")), |
| 43 | + TouchEventType.getJSEventName(TouchEventType.CANCEL) to |
| 44 | + mapOf( |
| 45 | + "phasedRegistrationNames" to |
| 46 | + mapOf("bubbled" to "onTouchCancel", "captured" to "onTouchCancelCapture"))) |
| 47 | + |
| 48 | + @JvmField |
| 49 | + val directEventTypeConstants: Map<String, Any> = run { |
| 50 | + val rn = "registrationName" |
| 51 | + mapOf( |
| 52 | + "topContentSizeChange" to mapOf(rn to "onContentSizeChange"), |
| 53 | + "topLayout" to mapOf(rn to "onLayout"), |
| 54 | + "topLoadingError" to mapOf(rn to "onLoadingError"), |
| 55 | + "topLoadingFinish" to mapOf(rn to "onLoadingFinish"), |
| 56 | + "topLoadingStart" to mapOf(rn to "onLoadingStart"), |
| 57 | + "topSelectionChange" to mapOf(rn to "onSelectionChange"), |
| 58 | + "topMessage" to mapOf(rn to "onMessage"), |
| 59 | + |
| 60 | + // Scroll events are added as per task T22348735. |
| 61 | + // Subject for further improvement. |
| 62 | + "topScrollBeginDrag" to mapOf(rn to "onScrollBeginDrag"), |
| 63 | + "topScrollEndDrag" to mapOf(rn to "onScrollEndDrag"), |
| 64 | + "topScroll" to mapOf(rn to "onScroll"), |
| 65 | + "topMomentumScrollBegin" to mapOf(rn to "onMomentumScrollBegin"), |
| 66 | + "topMomentumScrollEnd" to mapOf(rn to "onMomentumScrollEnd")) |
| 67 | + } |
| 68 | + |
| 69 | + @JvmField |
| 70 | + val constants: Map<String, Any> = |
| 71 | + mapOf( |
| 72 | + "UIView" to |
| 73 | + mapOf( |
| 74 | + "ContentMode" to |
| 75 | + mapOf( |
| 76 | + "ScaleAspectFit" to ImageView.ScaleType.FIT_CENTER.ordinal, |
| 77 | + "ScaleAspectFill" to ImageView.ScaleType.CENTER_CROP.ordinal, |
| 78 | + "ScaleAspectCenter" to ImageView.ScaleType.CENTER_INSIDE.ordinal)), |
| 79 | + "StyleConstants" to |
| 80 | + mapOf( |
| 81 | + "PointerEventsValues" to |
| 82 | + mapOf( |
| 83 | + "none" to PointerEvents.NONE.ordinal, |
| 84 | + "boxNone" to PointerEvents.BOX_NONE.ordinal, |
| 85 | + "boxOnly" to PointerEvents.BOX_ONLY.ordinal, |
| 86 | + "unspecified" to PointerEvents.AUTO.ordinal)), |
| 87 | + "AccessibilityEventTypes" to |
| 88 | + mapOf( |
| 89 | + "typeWindowStateChanged" to AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, |
| 90 | + "typeViewFocused" to AccessibilityEvent.TYPE_VIEW_FOCUSED, |
| 91 | + "typeViewClicked" to AccessibilityEvent.TYPE_VIEW_CLICKED)) |
| 92 | +} |
0 commit comments