Skip to content

Commit e52bc2a

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
Use generated view config for Slider
Summary: This diff uses the generated view config for the slider component � Reviewed By: JoshuaGross, TheSavior, mdvacca Differential Revision: D15336089 fbshipit-source-id: 46c458805fd947e202e2084df65c8c83560cf106
1 parent ca78341 commit e52bc2a

File tree

5 files changed

+82
-7
lines changed

5 files changed

+82
-7
lines changed

Libraries/Components/Slider/Slider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
const Platform = require('../../Utilities/Platform');
14-
const RCTSliderNativeComponent = require('./RCTSliderNativeComponent');
14+
const SliderNativeComponent = require('./SliderNativeComponent');
1515
const React = require('react');
1616
const ReactNative = require('../../Renderer/shims/ReactNative');
1717
const StyleSheet = require('../../StyleSheet/StyleSheet');
@@ -197,7 +197,7 @@ type Props = $ReadOnly<{|
197197
*/
198198
const Slider = (
199199
props: Props,
200-
forwardedRef?: ?React.Ref<typeof RCTSliderNativeComponent>,
200+
forwardedRef?: ?React.Ref<typeof SliderNativeComponent>,
201201
) => {
202202
const style = StyleSheet.compose(
203203
styles.slider,
@@ -227,7 +227,7 @@ const Slider = (
227227
: null;
228228

229229
return (
230-
<RCTSliderNativeComponent
230+
<SliderNativeComponent
231231
{...localProps}
232232
ref={forwardedRef}
233233
style={style}

Libraries/Components/Slider/RCTSliderNativeComponent.js renamed to Libraries/Components/Slider/SliderNativeComponent.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
14-
1513
import type {
1614
Float,
1715
BubblingEvent,
@@ -61,4 +59,4 @@ type Options = {
6159

6260
type SliderType = CodegenNativeComponent<'Slider', NativeProps, Options>;
6361

64-
module.exports = ((requireNativeComponent('RCTSlider'): any): SliderType);
62+
module.exports = ((require('SliderNativeViewConfig'): any): SliderType);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
/**
3+
* Copyright (c) Facebook, Inc. and its affiliates.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
* @flow
9+
*/
10+
11+
'use strict';
12+
13+
const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry');
14+
const ReactNativeViewViewConfig = require('ReactNativeViewViewConfig');
15+
const verifyComponentAttributeEquivalence = require('verifyComponentAttributeEquivalence');
16+
17+
const SliderViewConfig = {
18+
uiViewClassName: 'RCTSlider',
19+
Commands: {},
20+
21+
bubblingEventTypes: {
22+
...ReactNativeViewViewConfig.bubblingEventTypes,
23+
24+
topChange: {
25+
phasedRegistrationNames: {
26+
captured: 'onChangeCapture',
27+
bubbled: 'onChange',
28+
},
29+
},
30+
31+
topValueChange: {
32+
phasedRegistrationNames: {
33+
captured: 'onValueChangeCapture',
34+
bubbled: 'onValueChange',
35+
},
36+
},
37+
},
38+
39+
directEventTypes: {
40+
...ReactNativeViewViewConfig.directEventTypes,
41+
42+
topSlidingComplete: {
43+
registrationName: 'onSlidingComplete',
44+
},
45+
},
46+
47+
validAttributes: {
48+
...ReactNativeViewViewConfig.validAttributes,
49+
disabled: true,
50+
enabled: true,
51+
maximumTrackImage: { process: require('resolveAssetSource') },
52+
maximumTrackTintColor: { process: require('processColor') },
53+
maximumValue: true,
54+
minimumTrackImage: { process: require('resolveAssetSource') },
55+
minimumTrackTintColor: { process: require('processColor') },
56+
minimumValue: true,
57+
step: true,
58+
testID: true,
59+
thumbImage: { process: require('resolveAssetSource') },
60+
thumbTintColor: { process: require('processColor') },
61+
trackImage: { process: require('resolveAssetSource') },
62+
value: true,
63+
onChange: true,
64+
onValueChange: true,
65+
onSlidingComplete: true,
66+
},
67+
};
68+
69+
verifyComponentAttributeEquivalence('RCTSlider', SliderViewConfig);
70+
71+
ReactNativeViewConfigRegistry.register(
72+
'RCTSlider',
73+
() => SliderViewConfig,
74+
);
75+
76+
module.exports = 'RCTSlider'; // RCT prefix present for paper support

Libraries/Components/Slider/SliderSchema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const SliderSchema: SchemaType = {
1818
components: {
1919
Slider: {
2020
interfaceOnly: true,
21+
isDeprecatedPaperComponentNameRCT: true,
2122
extendsProps: [
2223
{
2324
type: 'ReactNativeBuiltInType',

packages/react-native-codegen/src/cli/viewconfigs/generate-view-configs-cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const yargv = yargs.strict().option('t', {
2323
const argv = yargv.argv;
2424
const fileList = argv._[0].split('\n');
2525

26-
const CURRENT_VIEW_CONFIG_FILES = [];
26+
const CURRENT_VIEW_CONFIG_FILES = ['SliderNativeComponent.js'];
2727

2828
generate(
2929
fileList.filter(fileName =>

0 commit comments

Comments
 (0)