Skip to content

Commit 35fa95b

Browse files
authored
Merge pull request #6 from Wadjetz/master
Support of min and max date for android
2 parents 26dadc0 + 6426fed commit 35fa95b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export default class DateTimePickerTester extends Component {
7070
| onConfirm | func | **REQUIRED** | Function called on date picked |
7171
| onCancel | func | **REQUIRED** | Function called on dismiss |
7272
| titleIOS | string | 'Pick a date' | The title text on iOS |
73+
| minDateAndroid | Date | undefined | Min Date
74+
| maxDateAndroid | Date | undefined | Max Date
7375

7476
All the [DatePickerIOS props](https://facebook.github.io/react-native/docs/datepickerios.html) are also supported!
7577

src/CustomDatePickerAndroid/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export default class CustomDatePickerAndroid extends Component {
88
mode: PropTypes.oneOf(['date', 'time', 'datetime']),
99
onCancel: PropTypes.func.isRequired,
1010
onConfirm: PropTypes.func.isRequired,
11-
isVisible: PropTypes.bool
11+
isVisible: PropTypes.bool,
12+
minDateAndroid: PropTypes.instanceOf(Date),
13+
maxDateAndroid: PropTypes.instanceOf(Date)
1214
}
1315

1416
static defaultProps = {
@@ -30,7 +32,9 @@ export default class CustomDatePickerAndroid extends Component {
3032
_showDatePickerAndroid = async () => {
3133
try {
3234
const { action, year, month, day } = await DatePickerAndroid.open({
33-
date: this.props.date
35+
date: this.props.date,
36+
minDate: this.props.minDateAndroid,
37+
maxDate: this.props.maxDateAndroid
3438
})
3539
if (action !== DatePickerAndroid.dismissedAction) {
3640
const date = moment({ year, month, day }).toDate()

0 commit comments

Comments
 (0)