mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-06 22:38:37 +08:00
Native view manager event types exposed to JS via view config
Differential Revision: D5814210 fbshipit-source-id: 41291f0d6b39af77f66173f6a699d88f9f4ccc74
This commit is contained in:
committed by
Facebook Github Bot
parent
e9780bdc0f
commit
75c94a8907
@@ -68,6 +68,15 @@ import com.facebook.react.uimanager.events.TouchEventType;
|
||||
"onTouchEnd",
|
||||
"captured",
|
||||
"onTouchEndCapture")))
|
||||
.put(
|
||||
TouchEventType.CANCEL.getJSEventName(),
|
||||
MapBuilder.of(
|
||||
"phasedRegistrationNames",
|
||||
MapBuilder.of(
|
||||
"bubbled",
|
||||
"onTouchCancel",
|
||||
"captured",
|
||||
"onTouchCancelCapture")))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,10 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
*/
|
||||
/* package */ class UIManagerModuleConstantsHelper {
|
||||
|
||||
private static final String CUSTOM_BUBBLING_EVENT_TYPES_KEY = "customBubblingEventTypes";
|
||||
private static final String CUSTOM_DIRECT_EVENT_TYPES_KEY = "customDirectEventTypes";
|
||||
|
||||
/**
|
||||
* Generates map of constants that is then exposed by {@link UIManagerModule}. The constants map
|
||||
* contains the following predefined fields for 'customBubblingEventTypes' and
|
||||
* 'customDirectEventTypes'. Provided list of {@param viewManagers} is then used to populate
|
||||
* content of those predefined fields using
|
||||
* Generates map of constants that is then exposed by {@link UIManagerModule}.
|
||||
* Provided list of {@param viewManagers} is then used to populate content of
|
||||
* those predefined fields using
|
||||
* {@link ViewManager#getExportedCustomBubblingEventTypeConstants} and
|
||||
* {@link ViewManager#getExportedCustomDirectEventTypeConstants} respectively. Each view manager
|
||||
* is in addition allowed to expose viewmanager-specific constants that are placed under the key
|
||||
@@ -53,15 +49,21 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
.arg("ViewManager", viewManager.getName())
|
||||
.flush();
|
||||
try {
|
||||
Map viewManagerConstants = MapBuilder.newHashMap();
|
||||
Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants();
|
||||
if (viewManagerBubblingEvents != null) {
|
||||
recursiveMerge(bubblingEventTypesConstants, viewManagerBubblingEvents);
|
||||
recursiveMerge(viewManagerBubblingEvents, bubblingEventTypesConstants);
|
||||
viewManagerConstants.put("bubblingEventTypes", viewManagerBubblingEvents);
|
||||
} else {
|
||||
viewManagerConstants.put("bubblingEventTypes", bubblingEventTypesConstants);
|
||||
}
|
||||
Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants();
|
||||
if (viewManagerDirectEvents != null) {
|
||||
recursiveMerge(directEventTypesConstants, viewManagerDirectEvents);
|
||||
recursiveMerge(viewManagerDirectEvents, directEventTypesConstants);
|
||||
viewManagerConstants.put("directEventTypes", viewManagerDirectEvents);
|
||||
} else {
|
||||
viewManagerConstants.put("directEventTypes", directEventTypesConstants);
|
||||
}
|
||||
Map viewManagerConstants = MapBuilder.newHashMap();
|
||||
Map customViewConstants = viewManager.getExportedViewConstants();
|
||||
if (customViewConstants != null) {
|
||||
viewManagerConstants.put("Constants", customViewConstants);
|
||||
@@ -82,8 +84,6 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
}
|
||||
}
|
||||
|
||||
constants.put(CUSTOM_BUBBLING_EVENT_TYPES_KEY, bubblingEventTypesConstants);
|
||||
constants.put(CUSTOM_DIRECT_EVENT_TYPES_KEY, directEventTypesConstants);
|
||||
constants.put("AndroidLazyViewManagersEnabled", lazyViewManagersEnabled);
|
||||
|
||||
return constants;
|
||||
|
||||
@@ -140,6 +140,14 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
||||
return MapBuilder.<String, Object>builder()
|
||||
.put(ScrollEventType.SCROLL.getJSEventName(), MapBuilder.of("registrationName", "onScroll"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Map<String, Integer> getCommandsMap() {
|
||||
return MapBuilder.of("focusTextInput", FOCUS_TEXT_INPUT, "blurTextInput", BLUR_TEXT_INPUT);
|
||||
|
||||
Reference in New Issue
Block a user