Skip to content

Commit 5259fd8

Browse files
committed
Moved to prop-types
1 parent e4ecdfe commit 5259fd8

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"dependencies": {
3232
"moment": "^2.18.1",
33+
"prop-types": "15.5.10",
3334
"react-native-modal": "^2.4.0"
3435
},
3536
"devDependencies": {
@@ -49,4 +50,4 @@
4950
"git add"
5051
]
5152
}
52-
}
53+
}

src/CustomDatePickerAndroid/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
23
import { DatePickerAndroid, TimePickerAndroid } from 'react-native';
34
import moment from 'moment';
45

src/CustomDatePickerIOS/index.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
23
import { DatePickerIOS, Text, TouchableOpacity, View } from 'react-native';
34
import ReactNativeModal from 'react-native-modal';
45

@@ -12,7 +13,7 @@ export default class CustomDatePickerIOS extends Component {
1213
customConfirmButtonIOS: PropTypes.node,
1314
customConfirmButtonWhileInteractingIOS: PropTypes.node,
1415
customTitleContainerIOS: PropTypes.node,
15-
datePickerContainerStyleIOS: View.propTypes.style,
16+
datePickerContainerStyleIOS: PropTypes.any,
1617
date: PropTypes.instanceOf(Date),
1718
mode: PropTypes.oneOf(['date', 'time', 'datetime']),
1819
onConfirm: PropTypes.func.isRequired,
@@ -46,9 +47,9 @@ export default class CustomDatePickerIOS extends Component {
4647
_handleConfirm = () => this.props.onConfirm(this.state.date);
4748

4849
_handleDateChange = date => {
49-
this.setState({
50-
date,
51-
userIsInteractingWithPicker: false,
50+
this.setState({
51+
date,
52+
userIsInteractingWithPicker: false,
5253
});
5354
};
5455

@@ -57,7 +58,7 @@ export default class CustomDatePickerIOS extends Component {
5758
userIsInteractingWithPicker: true,
5859
});
5960
return false;
60-
}
61+
};
6162

6263
render() {
6364
const {
@@ -82,25 +83,29 @@ export default class CustomDatePickerIOS extends Component {
8283
</View>
8384
);
8485
let confirmButton;
85-
86-
if (customConfirmButtonIOS) { // if we have a custom confirm btn
87-
if (customConfirmButtonWhileInteractingIOS // if we have a custom confirm btn while we're interacting
88-
&& this.state.userIsInteractingWithPicker) { // and if we're currently interacting
86+
87+
if (customConfirmButtonIOS) {
88+
// if we have a custom confirm btn
89+
if (
90+
customConfirmButtonWhileInteractingIOS && // if we have a custom confirm btn while we're interacting
91+
this.state.userIsInteractingWithPicker
92+
) {
93+
// and if we're currently interacting
8994
confirmButton = customConfirmButtonWhileInteractingIOS;
90-
} else { // otherwise if we're not interacting etc
91-
confirmButton = customConfirmButtonIOS; // just set our confirm button as the custom confirmation button
95+
} else {
96+
// otherwise if we're not interacting etc
97+
confirmButton = customConfirmButtonIOS; // just set our confirm button as the custom confirmation button
9298
}
93-
} else { // else if we don't even have a custom confirmation button just create a component now
94-
confirmButton = <Text style={styles.confirmText}>{confirmTextIOS}</Text>
99+
} else {
100+
// else if we don't even have a custom confirmation button just create a component now
101+
confirmButton = <Text style={styles.confirmText}>{confirmTextIOS}</Text>;
95102
}
96103
const cancelButton = <Text style={styles.cancelText}>{cancelTextIOS}</Text>;
97104
return (
98105
<ReactNativeModal isVisible={isVisible} style={styles.contentContainer}>
99106
<View style={[styles.datepickerContainer, datePickerContainerStyleIOS]}>
100107
{customTitleContainerIOS || titleContainer}
101-
<View
102-
onStartShouldSetResponderCapture={this._handleUserTouchInit}
103-
>
108+
<View onStartShouldSetResponderCapture={this._handleUserTouchInit}>
104109
<DatePickerIOS
105110
date={this.state.date}
106111
mode={mode}

0 commit comments

Comments
 (0)