forked from Cero-Studio/ReactNativeWheelPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWheelPicker.js
More file actions
72 lines (68 loc) · 2.29 KB
/
WheelPicker.js
File metadata and controls
72 lines (68 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
import { requireNativeComponent,View } from 'react-native';
var WheelPickerView = requireNativeComponent('WheelPicker', WheelPicker);
class WheelPicker extends React.Component {
constructor(props) {
super(props);
this.onItemSelected = this.onItemSelected.bind(this);
this.state = {
selectedItemPosition: 0
}
}
onItemSelected(event: Event) {
if (!this.props.onItemSelected) {
return;
}
this.props.onItemSelected(event.nativeEvent);
}
componentDidMount() {
this.setState({ selectedItemPosition: this.props.selectedItemPosition })
}
render() {
return (
<WheelPickerView
{...this.props}
onChange={this.onItemSelected}
data={this.props.data}
isCurved={this.props.isCurved}
isCyclic={this.props.isCyclic}
isAtmospheric={this.props.isAtmospheric}
selectedItemTextColor={this.props.selectedItemTextColor}
itemSpace={this.props.itemSpace}
visibleItemCount={this.props.visibleItemCount}
renderIndicator={this.props.renderIndicator}
indicatorColor={this.props.indicatorColor}
isCurtain={this.props.isCurtain}
curtainColor={this.props.curtainColor}
itemTextColor={this.props.itemTextColor}
itemTextSize={this.props.itemTextSize}
itemTextFontFamily={this.props.itemTextFontFamily}
selectedItemPosition={this.state.selectedItemPosition}
backgroundColor={this.props.backgroundColor}
/>
);
}
}
WheelPicker.propTypes = {
...View.propTypes,
onItemSelected: PropTypes.func,
data: PropTypes.array,
isCurved: PropTypes.bool,
isCyclic: PropTypes.bool,
isAtmospheric: PropTypes.bool,
selectedItemTextColor: PropTypes.string,
itemSpace: PropTypes.number,
visibleItemCount: PropTypes.number,
renderIndicator: PropTypes.bool,
indicatorColor: PropTypes.string,
isCurtain: PropTypes.bool,
curtainColor: PropTypes.string,
itemTextColor: PropTypes.string,
itemTextSize: PropTypes.number,
itemTextFontFamily: PropTypes.string,
selectedItemPosition: PropTypes.number,
backgroundColor: PropTypes.string,
};
module.exports = WheelPicker;