forked from tiaanduplessis/react-native-datepicker-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
49 lines (43 loc) · 1.2 KB
/
example.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
import React from 'react'
import { StyleSheet, Text } from 'react-native'
import ModalDatePicker from 'react-native-datepicker-modal'
import colors from '../config/colors'
import spacing from '../config/spacing'
import fontSize from '../config/fontSize'
const DatePicker = ({ style, ...props }) => (
<ModalDatePicker
style={[styles.container, style]}
renderDate={({ year, month, day, date }) => {
if (!date) {
return <Text style={[styles.text, styles.placeholderText]}>Date of birth</Text>
}
const dateStr = `${day}-${month}-${year}`
return <Text style={styles.text}>{dateStr}</Text>
}}
{...props}
/>
)
const styles = StyleSheet.create({
container: {
backgroundColor: colors.white,
borderBottomColor: colors.gray.veryLight,
borderBottomWidth: 1,
marginVertical: spacing[1],
marginHorizontal: spacing[0],
justifyContent: 'center',
borderRadius: 2,
height: 50
},
placeholderText: {
color: colors.gray.light
},
text: {
width: '100%',
paddingHorizontal: spacing[1],
paddingVertical: spacing[0],
fontFamily: 'Montserrat',
fontSize: fontSize.medium,
color: colors.gray.dark
}
})
export default DatePicker