Skip to content

Commit 3ccc141

Browse files
elicwhitehramos
authored andcommitted
Put View ViewConfig in JS
Summary: Moving this config to native for android so we skip the native lookup for the config. Reviewed By: yungsters Differential Revision: D9415726 fbshipit-source-id: 84cac3f0dfa4f6ea8800de77676f1e2896ee463d
1 parent cbad158 commit 3ccc141

File tree

2 files changed

+290
-4
lines changed

2 files changed

+290
-4
lines changed

Libraries/Components/View/ViewNativeComponent.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@
1010

1111
'use strict';
1212

13+
const Platform = require('Platform');
1314
const ReactNative = require('ReactNative');
1415

1516
const requireNativeComponent = require('requireNativeComponent');
17+
const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry');
1618

1719
import type {ViewProps} from 'ViewPropTypes';
1820

1921
type ViewNativeComponentType = Class<ReactNative.NativeComponent<ViewProps>>;
2022

21-
const ViewNativeComponent = ((requireNativeComponent(
22-
'RCTView',
23-
): any): ViewNativeComponentType);
23+
let NativeViewComponent;
2424

25-
module.exports = ViewNativeComponent;
25+
if (Platform.OS === 'Android') {
26+
NativeViewComponent = ReactNativeViewConfigRegistry.register('RCTView', () =>
27+
require('ViewNativeComponentAndroidConfig'),
28+
);
29+
} else {
30+
NativeViewComponent = requireNativeComponent('RCTView');
31+
}
32+
33+
module.exports = ((NativeViewComponent: any): ViewNativeComponentType);
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
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+
* @format
8+
* @flow
9+
*/
10+
11+
'use strict';
12+
13+
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
14+
15+
const processColor = require('processColor');
16+
17+
const colorHandler = {diff: null, process: processColor};
18+
19+
const ViewNativeComponentAndroidConfig = {
20+
bubblingEventTypes: {
21+
topChange: {
22+
phasedRegistrationNames: {
23+
captured: 'onChangeCapture',
24+
bubbled: 'onChange',
25+
},
26+
},
27+
topTouchCancel: {
28+
phasedRegistrationNames: {
29+
captured: 'onTouchCancelCapture',
30+
bubbled: 'onTouchCancel',
31+
},
32+
},
33+
topTouchMove: {
34+
phasedRegistrationNames: {
35+
captured: 'onTouchMoveCapture',
36+
bubbled: 'onTouchMove',
37+
},
38+
},
39+
topTouchStart: {
40+
phasedRegistrationNames: {
41+
captured: 'onTouchStartCapture',
42+
bubbled: 'onTouchStart',
43+
},
44+
},
45+
topTouchEnd: {
46+
phasedRegistrationNames: {
47+
captured: 'onTouchEndCapture',
48+
bubbled: 'onTouchEnd',
49+
},
50+
},
51+
topSelect: {
52+
phasedRegistrationNames: {
53+
captured: 'onSelectCapture',
54+
bubbled: 'onSelect',
55+
},
56+
},
57+
},
58+
Commands: {setPressed: 2, hotspotUpdate: 1},
59+
directEventTypes: {
60+
topLoadingError: {registrationName: 'onLoadingError'},
61+
topLayout: {registrationName: 'onLayout'},
62+
topScrollBeginDrag: {registrationName: 'onScrollBeginDrag'},
63+
topContentSizeChange: {registrationName: 'onContentSizeChange'},
64+
topMomentumScrollBegin: {registrationName: 'onMomentumScrollBegin'},
65+
topScrollEndDrag: {registrationName: 'onScrollEndDrag'},
66+
topMomentumScrollEnd: {registrationName: 'onMomentumScrollEnd'},
67+
topLoadingStart: {registrationName: 'onLoadingStart'},
68+
topSelectionChange: {registrationName: 'onSelectionChange'},
69+
topLoadingFinish: {registrationName: 'onLoadingFinish'},
70+
topMessage: {registrationName: 'onMessage'},
71+
topScroll: {registrationName: 'onScroll'},
72+
},
73+
NativeProps: {
74+
accessibilityComponentType: 'String',
75+
accessibilityHint: 'String',
76+
accessibilityLabel: 'String',
77+
accessibilityLiveRegion: 'String',
78+
accessibilityRole: 'String',
79+
accessibilityStates: 'Array',
80+
accessible: 'boolean',
81+
alignContent: 'String',
82+
alignItems: 'String',
83+
alignSelf: 'String',
84+
aspectRatio: 'number',
85+
backgroundColor: 'Color',
86+
borderBottomColor: 'Color',
87+
borderBottomEndRadius: 'number',
88+
borderBottomLeftRadius: 'number',
89+
borderBottomRightRadius: 'number',
90+
borderBottomStartRadius: 'number',
91+
borderBottomWidth: 'number',
92+
borderColor: 'Color',
93+
borderEndColor: 'Color',
94+
borderEndWidth: 'number',
95+
borderLeftColor: 'Color',
96+
borderLeftWidth: 'number',
97+
borderRadius: 'number',
98+
borderRightColor: 'Color',
99+
borderRightWidth: 'number',
100+
borderStartColor: 'Color',
101+
borderStartWidth: 'number',
102+
borderStyle: 'String',
103+
borderTopColor: 'Color',
104+
borderTopEndRadius: 'number',
105+
borderTopLeftRadius: 'number',
106+
borderTopRightRadius: 'number',
107+
borderTopStartRadius: 'number',
108+
borderTopWidth: 'number',
109+
borderWidth: 'number',
110+
bottom: 'Dynamic',
111+
collapsable: 'boolean',
112+
display: 'String',
113+
elevation: 'number',
114+
end: 'Dynamic',
115+
flex: 'number',
116+
flexBasis: 'Dynamic',
117+
flexDirection: 'String',
118+
flexGrow: 'number',
119+
flexShrink: 'number',
120+
flexWrap: 'String',
121+
hasTVPreferredFocus: 'boolean',
122+
height: 'Dynamic',
123+
hitSlop: 'Map',
124+
importantForAccessibility: 'String',
125+
justifyContent: 'String',
126+
left: 'Dynamic',
127+
margin: 'Dynamic',
128+
marginBottom: 'Dynamic',
129+
marginEnd: 'Dynamic',
130+
marginHorizontal: 'Dynamic',
131+
marginLeft: 'Dynamic',
132+
marginRight: 'Dynamic',
133+
marginStart: 'Dynamic',
134+
marginTop: 'Dynamic',
135+
marginVertical: 'Dynamic',
136+
maxHeight: 'Dynamic',
137+
maxWidth: 'Dynamic',
138+
minHeight: 'Dynamic',
139+
minWidth: 'Dynamic',
140+
nativeBackgroundAndroid: 'Map',
141+
nativeForegroundAndroid: 'Map',
142+
nativeID: 'String',
143+
needsOffscreenAlphaCompositing: 'boolean',
144+
onLayout: 'boolean',
145+
opacity: 'number',
146+
overflow: 'String',
147+
padding: 'Dynamic',
148+
paddingBottom: 'Dynamic',
149+
paddingEnd: 'Dynamic',
150+
paddingHorizontal: 'Dynamic',
151+
paddingLeft: 'Dynamic',
152+
paddingRight: 'Dynamic',
153+
paddingStart: 'Dynamic',
154+
paddingTop: 'Dynamic',
155+
paddingVertical: 'Dynamic',
156+
pointerEvents: 'String',
157+
position: 'String',
158+
removeClippedSubviews: 'boolean',
159+
renderToHardwareTextureAndroid: 'boolean',
160+
right: 'Dynamic',
161+
rotation: 'number',
162+
scaleX: 'number',
163+
scaleY: 'number',
164+
start: 'Dynamic',
165+
testID: 'String',
166+
top: 'Dynamic',
167+
transform: 'Array',
168+
translateX: 'number',
169+
translateY: 'number',
170+
width: 'Dynamic',
171+
zIndex: 'number',
172+
},
173+
174+
uiViewClassName: 'RCTView',
175+
validAttributes: {
176+
accessibilityComponentType: true,
177+
accessibilityHint: true,
178+
accessibilityLabel: true,
179+
accessibilityLiveRegion: true,
180+
accessibilityRole: true,
181+
accessibilityStates: true,
182+
accessible: true,
183+
alignContent: true,
184+
alignItems: true,
185+
alignSelf: true,
186+
aspectRatio: true,
187+
backgroundColor: colorHandler,
188+
borderBottomColor: colorHandler,
189+
borderBottomEndRadius: true,
190+
borderBottomLeftRadius: true,
191+
borderBottomRightRadius: true,
192+
borderBottomStartRadius: true,
193+
borderBottomWidth: true,
194+
borderColor: colorHandler,
195+
borderEndColor: colorHandler,
196+
borderEndWidth: true,
197+
borderLeftColor: colorHandler,
198+
borderLeftWidth: true,
199+
borderRadius: true,
200+
borderRightColor: colorHandler,
201+
borderRightWidth: true,
202+
borderStartColor: colorHandler,
203+
borderStartWidth: true,
204+
borderStyle: true,
205+
borderTopColor: colorHandler,
206+
borderTopEndRadius: true,
207+
borderTopLeftRadius: true,
208+
borderTopRightRadius: true,
209+
borderTopStartRadius: true,
210+
borderTopWidth: true,
211+
borderWidth: true,
212+
bottom: true,
213+
collapsable: true,
214+
display: true,
215+
elevation: true,
216+
end: true,
217+
flex: true,
218+
flexBasis: true,
219+
flexDirection: true,
220+
flexGrow: true,
221+
flexShrink: true,
222+
flexWrap: true,
223+
hasTVPreferredFocus: true,
224+
height: true,
225+
hitSlop: true,
226+
importantForAccessibility: true,
227+
justifyContent: true,
228+
left: true,
229+
margin: true,
230+
marginBottom: true,
231+
marginEnd: true,
232+
marginHorizontal: true,
233+
marginLeft: true,
234+
marginRight: true,
235+
marginStart: true,
236+
marginTop: true,
237+
marginVertical: true,
238+
maxHeight: true,
239+
maxWidth: true,
240+
minHeight: true,
241+
minWidth: true,
242+
nativeBackgroundAndroid: true,
243+
nativeForegroundAndroid: true,
244+
nativeID: true,
245+
needsOffscreenAlphaCompositing: true,
246+
onLayout: true,
247+
opacity: true,
248+
overflow: true,
249+
padding: true,
250+
paddingBottom: true,
251+
paddingEnd: true,
252+
paddingHorizontal: true,
253+
paddingLeft: true,
254+
paddingRight: true,
255+
paddingStart: true,
256+
paddingTop: true,
257+
paddingVertical: true,
258+
pointerEvents: true,
259+
position: true,
260+
removeClippedSubviews: true,
261+
renderToHardwareTextureAndroid: true,
262+
right: true,
263+
rotation: true,
264+
scaleX: true,
265+
scaleY: true,
266+
start: true,
267+
testID: true,
268+
top: true,
269+
transform: true,
270+
translateX: true,
271+
translateY: true,
272+
width: true,
273+
zIndex: true,
274+
style: ReactNativeStyleAttributes,
275+
},
276+
};
277+
278+
module.exports = ViewNativeComponentAndroidConfig;

0 commit comments

Comments
 (0)