-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDatePickerIOS.js
58 lines (56 loc) · 1.59 KB
/
DatePickerIOS.js
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
'use strict';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
StyleSheet,
View,
NativeModules,
requireNativeComponent,
} from 'react-native';
class DatePickerIOS extends Component {
_onChange = (event) => {
const timestamp = event.nativeEvent.timestamp;
const date = event.nativeEvent.date;
this.props.onChange && this.props.onChange({ date, timestamp });
}
render() {
const props = this.props;
return (
<View style={props.style}>
<RCTDatePickerIos
mode={props.mode}
calendar={props.calendar}
onChange={this._onChange}
date={props.date}
maximumDate={props.maximumDate}
minimumDate={props.minimumDate}
dateFormat={props.dateFormat}
style={styles.datePickerIOS}
/>
</View>
);
}
};
DatePickerIOS.propTypes = {
date: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
maximumDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
minimumDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
mode: PropTypes.oneOf(['date', 'time', 'datetime']),
timeZoneOffsetInMinutes: PropTypes.number,
dateFormat: PropTypes.string,
calendar: PropTypes.string,
}
DatePickerIOS.defaultProps = {
mode: 'datetime',
date: new Date().getTime(),
dateFormat: "dd-MM-yyyy",
calendar: "Gregorian"
};
const styles = StyleSheet.create({
datePickerIOS: {
height: 216,
},
});
var RCTDatePickerIos = requireNativeComponent("RCTDatePickerIos", DatePickerIOS);
module.exports = DatePickerIOS;