forked from xgfe/react-native-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.android.js
123 lines (116 loc) · 3.45 KB
/
index.android.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
PanResponder
} from 'react-native';
import DatePicker from './index.js';
class datepicker extends Component {
constructor(props) {
super(props);
this.state = {
date: '',
time: '20:00',
datetime: '2016-05-05 20:00',
datetime1: '2016-05-05 20:00'
};
}
componentWillMount() {
this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: (e) => {console.log('onStartShouldSetPanResponder'); return true;},
onMoveShouldSetPanResponder: (e) => {console.log('onMoveShouldSetPanResponder'); return true;},
onPanResponderGrant: (e) => console.log('onPanResponderGrant'),
onPanResponderMove: (e) => console.log('onPanResponderMove'),
onPanResponderRelease: (e) => console.log('onPanResponderRelease'),
onPanResponderTerminate: (e) => console.log('onPanResponderTerminate')
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to react-native-datepicker example!
</Text>
<DatePicker
style={{width: 200}}
date={this.state.date}
mode="date"
placeholder="placeholder"
format="YYYY-MM-DD"
minDate="2016-05-01"
maxDate="2016-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
iconSource={require('./google_calendar.png')}
onDateChange={(date) => {this.setState({date: date});}}
/>
<Text style={styles.instructions}>date: {this.state.date}</Text>
<DatePicker
style={{width: 200}}
date={this.state.time}
mode="time"
format="HH:mm"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
minuteInterval={10}
onDateChange={(time) => {this.setState({time: time});}}
/>
<Text style={styles.instructions}>time: {this.state.time}</Text>
<DatePicker
style={{width: 200}}
date={this.state.datetime}
mode="datetime"
format="YYYY-MM-DD HH:mm"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
showIcon={false}
onDateChange={(datetime) => {this.setState({datetime: datetime});}}
/>
<Text style={styles.instructions}>datetime: {this.state.datetime}</Text>
<DatePicker
style={{width: 200}}
date={this.state.datetime1}
mode="datetime"
format="YYYY-MM-DD HH:mm"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
position: 'absolute',
left: 0,
top: 4,
marginLeft: 0
},
dateInput: {
marginLeft: 36
}
}}
minuteInterval={10}
onDateChange={(datetime) => {this.setState({datetime1: datetime});}}
/>
<Text style={styles.instructions}>datetime: {this.state.datetime1}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
}
});
AppRegistry.registerComponent('datepicker', () => datepicker);