-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-83-datepicker.js
50 lines (46 loc) · 1.32 KB
/
demo-83-datepicker.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
import React, { Component } from 'react';
import DatePicker from 'react-native-datepicker';
import {Container, Header, Content, Button, Text} from 'native-base';
export default class DatePickerExample extends Component {
constructor(props) {
super(props);
this.state = {chosenDate: new Date()}
this.setDate = this.setDate.bind(this);
}
setDate(date){
this.setState({chosenDate: date})
}
render() {
return (
<Container>
<Header />
<Content>
<DatePicker
date={this.state.chosenDate} //initial date from state
mode="date" //The enum of date, datetime and time
placeholder="select date"
format="DD-MM-YYYY"
//minDate="01-01-2016"
//maxDate="01-01-2019"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
//display: 'none',
position: 'absolute',
left: 0,
top: 4,
marginLeft: 0,
},
dateInput: {
marginLeft: 36,
},
}}
onDateChange={(date) => {this.setDate(date)}}
/>
<Text>{this.state.chosenDate.toString()}</Text>
</Content>
</Container>
);
}
}