Skip to content

Commit

Permalink
Back out "Fix Static View Config for RCTView"
Browse files Browse the repository at this point in the history
Summary: Changelog: [internal]

Reviewed By: arushikesarwani94

Differential Revision: D33042498

fbshipit-source-id: 42667f0fb17d502494139645a42dc54dea9904b7
  • Loading branch information
GijsWeterings authored and facebook-github-bot committed Dec 11, 2021
1 parent 0c744de commit 34efaab
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 121 deletions.
140 changes: 54 additions & 86 deletions Libraries/Components/View/ReactNativeViewViewConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,17 @@
*/

import type {ViewConfig} from '../../Renderer/shims/ReactNativeTypes';
import {DynamicallyInjectedByGestureHandler} from '../../NativeComponent/ViewConfigIgnore';
import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid';
import {Platform} from 'react-native';

const ReactNativeViewViewConfigAndroid = {
bubblingEventTypes: {},
directEventTypes: {
topAccessibilityAction: {
registrationName: 'onAccessibilityAction',
},
topPointerEnter: {
registrationName: 'pointerenter',
},
topPointerLeave: {
registrationName: 'pointerleave',
},
topPointerMove: {
registrationName: 'pointermove',
},
},
validAttributes: {
elevation: true,
hasTVPreferredFocus: true,
focusable: true,
nativeBackgroundAndroid: true,
nativeForegroundAndroid: true,
nextFocusDown: true,
nextFocusForward: true,
nextFocusLeft: true,
nextFocusRight: true,
nextFocusUp: true,
renderToHardwareTextureAndroid: true,
translateX: true,
scaleX: true,
scaleY: true,
importantForAccessibility: true,
accessibilityLiveRegion: true,
rotation: true,
translateY: true,
transform: true,
hitSlop: true,
pointerenter: true,
pointerleave: true,
pointermove: true,
},
};

const ReactNativeViewViewConfigIOS = {
const ReactNativeViewConfig: ViewConfig = {
uiViewClassName: 'RCTView',
baseModuleName: null,
Manager: 'ViewManager',
Commands: {},
Constants: {},
bubblingEventTypes: {
...ReactNativeViewViewConfigAndroid.bubblingEventTypes,
topBlur: {
phasedRegistrationNames: {
bubbled: 'onBlur',
Expand Down Expand Up @@ -125,6 +88,7 @@ const ReactNativeViewViewConfigIOS = {
},
},
directEventTypes: {
...ReactNativeViewViewConfigAndroid.directEventTypes,
topAccessibilityAction: {
registrationName: 'onAccessibilityAction',
},
Expand All @@ -140,56 +104,36 @@ const ReactNativeViewViewConfigIOS = {
topMagicTap: {
registrationName: 'onMagicTap',
},
},
validAttributes: {
accessibilityElementsHidden: true,
accessibilityIgnoresInvertColors: true,
accessibilityViewIsModal: true,
direction: true,
onAccessibilityAction: true,
onAccessibilityEscape: true,
onAccessibilityTap: true,
onMagicTap: true,
shadowOffset: {diff: require('../../Utilities/differ/sizesDiffer')},
shadowOpacity: true,
shadowRadius: true,
shouldRasterizeIOS: true,
transform: {diff: require('../../Utilities/differ/matricesDiffer')},
hitSlop: {diff: require('../../Utilities/differ/insetsDiffer')},
},
};

const PlatformSpecificViewConfig =
Platform.OS === 'android'
? ReactNativeViewViewConfigAndroid
: ReactNativeViewViewConfigIOS;

const ReactNativeViewConfig: ViewConfig = {
uiViewClassName: 'RCTView',
baseModuleName: null,
Manager: 'ViewManager',
Commands: {},
Constants: {},
bubblingEventTypes: PlatformSpecificViewConfig.bubblingEventTypes,
directEventTypes: {
...PlatformSpecificViewConfig.directEventTypes,
topPointerEnter: {
registrationName: 'pointerenter',
},
topPointerLeave: {
registrationName: 'pointerleave',
},
topPointerMove: {
registrationName: 'pointermove',
},
// Events for react-native-gesture-handler (T45765076)
// Remove once this library can handle JS View Configs
onGestureHandlerEvent: DynamicallyInjectedByGestureHandler({
onGestureHandlerEvent: {
registrationName: 'onGestureHandlerEvent',
}),
onGestureHandlerStateChange: DynamicallyInjectedByGestureHandler({
},
onGestureHandlerStateChange: {
registrationName: 'onGestureHandlerStateChange',
}),
},
},
validAttributes: {
...PlatformSpecificViewConfig.validAttributes,
...ReactNativeViewViewConfigAndroid.validAttributes,
accessibilityActions: true,
accessibilityElementsHidden: true,
accessibilityHint: true,
accessibilityIgnoresInvertColors: true,
accessibilityLabel: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityState: true,
accessibilityValue: true,
accessibilityViewIsModal: true,
accessible: true,
alignContent: true,
alignItems: true,
Expand Down Expand Up @@ -222,8 +166,11 @@ const ReactNativeViewConfig: ViewConfig = {
borderTopWidth: true,
borderWidth: true,
bottom: true,
clickable: true,
collapsable: true,
direction: true,
display: true,
elevation: true,
end: true,
flex: true,
flexBasis: true,
Expand All @@ -232,6 +179,8 @@ const ReactNativeViewConfig: ViewConfig = {
flexShrink: true,
flexWrap: true,
height: true,
hitSlop: {diff: require('../../Utilities/differ/insetsDiffer')},
importantForAccessibility: true,
justifyContent: true,
left: true,
margin: true,
Expand All @@ -252,7 +201,11 @@ const ReactNativeViewConfig: ViewConfig = {
onAccessibilityAction: true,
onAccessibilityEscape: true,
onAccessibilityTap: true,
pointerenter: true,
pointerleave: true,
pointermove: true,
onLayout: true,
onMagicTap: true,
opacity: true,
overflow: true,
padding: true,
Expand All @@ -267,8 +220,16 @@ const ReactNativeViewConfig: ViewConfig = {
pointerEvents: true,
position: true,
removeClippedSubviews: true,
renderToHardwareTextureAndroid: true,
right: true,
rotation: true,
scaleX: true,
scaleY: true,
shadowColor: {process: require('../../StyleSheet/processColor')},
shadowOffset: {diff: require('../../Utilities/differ/sizesDiffer')},
shadowOpacity: true,
shadowRadius: true,
shouldRasterizeIOS: true,
start: true,
style: {
alignContent: true,
Expand Down Expand Up @@ -372,9 +333,10 @@ const ReactNativeViewConfig: ViewConfig = {
textTransform: true,
tintColor: {process: require('../../StyleSheet/processColor')},
top: true,
transform: {
process: require('../../StyleSheet/processTransform'),
},
transform:
Platform.OS === 'ios'
? {diff: require('../../Utilities/differ/matricesDiffer')}
: {process: require('../../StyleSheet/processTransform')},
transformMatrix: true,
translateX: true,
translateY: true,
Expand All @@ -384,6 +346,12 @@ const ReactNativeViewConfig: ViewConfig = {
},
testID: true,
top: true,
transform:
Platform.OS === 'ios'
? {diff: require('../../Utilities/differ/matricesDiffer')}
: {process: require('../../StyleSheet/processTransform')},
translateX: true,
translateY: true,
width: true,
zIndex: true,
},
Expand Down
83 changes: 83 additions & 0 deletions Libraries/Components/View/ReactNativeViewViewConfigAndroid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

const ReactNativeViewViewConfigAndroid = {
uiViewClassName: 'RCTView',
bubblingEventTypes: {
topSelect: {
phasedRegistrationNames: {
bubbled: 'onSelect',
captured: 'onSelectCapture',
},
},
topAssetDidLoad: {
phasedRegistrationNames: {
bubbled: 'onAssetDidLoad',
captured: 'onAssetDidLoadCapture',
},
},
},
directEventTypes: {
topClick: {
registrationName: 'onClick',
},
topContentSizeChange: {
registrationName: 'onContentSizeChange',
},
topLoadingError: {
registrationName: 'onLoadingError',
},
topLoadingFinish: {
registrationName: 'onLoadingFinish',
},
topLoadingStart: {
registrationName: 'onLoadingStart',
},
topMessage: {
registrationName: 'onMessage',
},
topMomentumScrollBegin: {
registrationName: 'onMomentumScrollBegin',
},
topMomentumScrollEnd: {
registrationName: 'onMomentumScrollEnd',
},
topScroll: {
registrationName: 'onScroll',
},
topScrollBeginDrag: {
registrationName: 'onScrollBeginDrag',
},
topScrollEndDrag: {
registrationName: 'onScrollEndDrag',
},
topSelectionChange: {
registrationName: 'onSelectionChange',
},
onAssetDidLoad: {
registrationName: 'onAssetDidLoad',
},
},
validAttributes: {
hasTVPreferredFocus: true,
focusable: true,
nativeBackgroundAndroid: true,
nativeForegroundAndroid: true,
nextFocusDown: true,
nextFocusForward: true,
nextFocusLeft: true,
nextFocusRight: true,
nextFocusUp: true,
},
};

module.exports = ReactNativeViewViewConfigAndroid;
10 changes: 7 additions & 3 deletions Libraries/Components/View/ViewNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@

import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import Platform from '../../Utilities/Platform';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid';
import {type ViewProps as Props} from './ViewPropTypes';
import * as React from 'react';

const ViewNativeComponent: HostComponent<Props> =
NativeComponentRegistry.get<Props>('RCTView', () => ({
uiViewClassName: 'RCTView',
}));
NativeComponentRegistry.get<Props>('RCTView', () =>
Platform.OS === 'android'
? ReactNativeViewViewConfigAndroid
: {uiViewClassName: 'RCTView'},
);

interface NativeCommands {
+hotspotUpdate: (
Expand Down
6 changes: 1 addition & 5 deletions Libraries/NativeComponent/StaticViewConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes';
import {isIgnored} from './ViewConfigIgnore';

type Difference =
| {
Expand Down Expand Up @@ -145,10 +144,7 @@ function accumulateDifferences(
}

for (const staticKey in staticObject) {
if (
!nativeObject.hasOwnProperty(staticKey) &&
!isIgnored(staticObject[staticKey])
) {
if (!nativeObject.hasOwnProperty(staticKey)) {
differences.push({
path: [...path, staticKey],
type: 'unexpected',
Expand Down
27 changes: 0 additions & 27 deletions Libraries/NativeComponent/ViewConfigIgnore.js

This file was deleted.

0 comments on commit 34efaab

Please sign in to comment.