11## react-native-paper-dates
22
3- - Smooth and fast cross platform Material Design date picker for React Native Paper
3+ - Smooth and fast cross platform Material Design ** date** picker and ** time ** picker for React Native Paper
44- Tested on Android, iOS and the web platform!
55- Uses the native Date.Intl API's which work out of the box on the web / iOS
66- Simple API
77- Typesafe
88- Endless scrolling
99- Performant
10+ - Great react-native-web support
1011
1112Older demo of this library.
1213<img src =" https://user-images.githubusercontent.com/6492229/90681177-4970f280-e263-11ea-8257-6810c5166f92.gif " />
@@ -66,8 +67,9 @@ function SingleDatePage() {
6667 onDismiss = { onDismiss }
6768 date = { date }
6869 onConfirm = { onChange }
69- saveLabel = { ' Save' } // optional
70- label = { ' Select period' } // optional
70+ saveLabel = " Save" // optional
71+ label = " Select date" // optional
72+ animationType = " slide" // optional, default is 'slide' on ios/android and 'none' on web
7173 />
7274 <Button onPress = { ()=> setVisible (true )} >
7375 Pick date
@@ -98,16 +100,17 @@ export default function RangeDatePage() {
98100 return (
99101 <>
100102 <DatePickerModal
101- mode = " range"
102- visible = { visible }
103- onDismiss = { onDismiss }
104- startDate = { undefined }
105- endDate = { undefined }
106- onConfirm = { onChange }
107- saveLabel = { ' Save' } // optional
108- label = { ' Select period' } // optional
109- startLabel = { ' From' } // optional
110- endLabel = { ' To' } // optional
103+ mode = " range"
104+ visible = { visible }
105+ onDismiss = { onDismiss }
106+ startDate = { undefined }
107+ endDate = { undefined }
108+ onConfirm = { onChange }
109+ saveLabel = " Save" // optional
110+ label = " Select period" // optional
111+ startLabel = " From" // optional
112+ endLabel = " To" // optional
113+ animationType = " slide" // optional, default is slide on ios/android and none on web
111114 />
112115 <Button onPress = { ()=> setVisible (true )} >
113116 Pick range
@@ -118,11 +121,70 @@ export default function RangeDatePage() {
118121```
119122
120123
124+ ### Time picker
125+ ``` tsx
126+ import * as React from ' react'
127+ import { Button } from ' react-native-paper'
128+ import { TimePickerModal } from ' react-native-paper-dates'
129+
130+ export default function TimePickerPage() {
131+ const [visible, setVisible] = React .useState (false )
132+ const onDismiss = React .useCallback (() => {
133+ setVisible (false )
134+ }, [setVisible ])
135+
136+ const onConfirm = React .useCallback (
137+ ({ hours , minutes }) => {
138+ setVisible (false );
139+ console .log ({ hours , minutes });
140+ },
141+ [setVisible ]
142+ );
143+
144+
145+ return (
146+ <>
147+ <TimePickerModal
148+ visible = { visible }
149+ onDismiss = { onDismiss }
150+ onConfirm = { onConfirm }
151+ hours = { 12 } // default: current hours
152+ minutes = { 14 } // default: current minutes
153+ label = " Select time" // optional, default 'Select time'
154+ cancelLabel = " Cancel" // optional, default: 'Cancel'
155+ confirmLabel = " Ok" // optional, default: 'Ok'
156+ animationType = " fade" // optional, default is 'none'
157+ />
158+ <Button onPress = { ()=> setVisible (true )} >
159+ Pick time
160+ </Button >
161+ </>
162+ )
163+ }
164+ ```
165+
166+
167+
168+
169+
121170
122171## Roadmap
123- Things on our roadmap are labeled with enhancement.
172+ Things on our roadmap have labels with ` enhancement ` .
124173https://github.com/web-ridge/react-native-paper-dates/issues
125174
175+ ## Tips & Tricks
176+ - Use 0.14+ version of React-Native-Web (Modal and better number input)
177+ - Try to avoid putting the pickers inside of a scrollView
178+ If that is ** not possible** use the following props on the surrounding ScrollViews/Flatlists
179+
180+ ``` javascript
181+ keyboardDismissMode= " on-drag"
182+ keyboardShouldPersistTaps= " handled"
183+ contentInsetAdjustmentBehavior= " always"
184+ ```
185+ This is to prevent the need to press 2 times before save works (1 press for closing keyboard, 1 press for confirm/close)
186+ (https://github.com/facebook/react-native/issues/10138 )
187+
126188## Android Caveats
127189
128190You will need to add a polyfill for the Intl API on Android if:
0 commit comments