|
1 | | -# react-native-paper-dates |
| 1 | +## react-native-paper-dates (WIP, no offical release yet) |
2 | 2 |
|
3 | | -Performant Date Picker for React Native Paper |
| 3 | +Demo: (https://twitter.com/RichardLindhout/status/1294636692540985344) |
4 | 4 |
|
5 | | -## Installation |
| 5 | +- Uses the native Date.Intl API's which work out of the box on the web / iOS |
| 6 | +- Simple API |
| 7 | +- Endless scrolling on both web (with react-window) / and VirtualizedList on other platforms |
| 8 | +- Performant |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +import from '...' |
| 13 | + |
| 14 | +## Roadmap |
| 15 | + |
| 16 | +- Follow all things in spec (https://material.io/components/date-pickers#mobile-pickers) |
| 17 | +- TimePicker component |
| 18 | +- Selecting year in single input |
| 19 | +- Optional locale overriding (date formatting) |
| 20 | +- Optional timezone overriding |
| 21 | +- Option to start day of week on monday (or read this from timezone/locale) |
| 22 | +- Direct input with modal suffix |
| 23 | +- Mobile input picker |
| 24 | + |
| 25 | +### Android Caveats |
| 26 | + |
| 27 | +You will need to add a polyfill for the Intl API on Android if: |
| 28 | + |
| 29 | +- You have Hermes enabled (https://github.com/facebook/hermes/issues/23) |
| 30 | +- You have Hermes disabled and you want to support locales outside of en-US and you don't have the org.webkit:android-jsc-intl:+ variant enabled in your app/build.gradle |
| 31 | + |
| 32 | +Install polyfills with Yarn |
| 33 | + |
| 34 | +``` |
| 35 | +yarn add react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale |
| 36 | +``` |
| 37 | + |
| 38 | +or npm |
6 | 39 |
|
7 | | -```sh |
8 | | -npm install react-native-paper-dates |
9 | 40 | ``` |
| 41 | +npm install react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale --save |
| 42 | +``` |
| 43 | + |
| 44 | +`./index.js` |
| 45 | + |
| 46 | +```javascript |
| 47 | +// on top of your index.js file |
| 48 | +const isAndroid = require('react-native').Platform.OS === 'android'; |
| 49 | +const isHermesEnabled = !!global.HermesInternal; |
| 50 | + |
| 51 | +// in your index.js file |
| 52 | +if (isHermesEnabled || isAndroid) { |
| 53 | + require('@formatjs/intl-getcanonicallocales/polyfill'); |
| 54 | + |
| 55 | + require('@formatjs/intl-pluralrules/polyfill'); |
| 56 | + require('@formatjs/intl-pluralrules/locale-data/nl.js'); // use your language files |
| 57 | + |
| 58 | + require('@formatjs/intl-relativetimeformat/polyfill'); |
| 59 | + require('@formatjs/intl-relativetimeformat/locale-data/nl.js'); // use your language files |
| 60 | + |
| 61 | + require('@formatjs/intl-listformat/polyfill'); |
| 62 | + require('@formatjs/intl-listformat/locale-data/nl.js'); // use your language files |
| 63 | + |
| 64 | + require('@formatjs/intl-displaynames/polyfill'); |
| 65 | + require('@formatjs/intl-displaynames/locale-data/nl.js'); // use your language files |
| 66 | + |
| 67 | + require('@formatjs/intl-numberformat/polyfill'); |
| 68 | + require('@formatjs/intl-numberformat/locale-data/nl.js'); // use your language files |
| 69 | + |
| 70 | + require('@formatjs/intl-datetimeformat/polyfill'); |
| 71 | + require('@formatjs/intl-datetimeformat/locale-data/nl.js'); // use your language files |
| 72 | + |
| 73 | + require('@formatjs/intl-datetimeformat/add-all-tz.js'); |
10 | 74 |
|
11 | | -## Usage (TODO) |
| 75 | + require('@formatjs/intl-locale/polyfill'); |
12 | 76 |
|
13 | | -```js |
14 | | -// ... |
| 77 | + // https://formatjs.io/docs/polyfills/intl-datetimeformat/#default-timezone |
| 78 | + let RNLocalize = require('react-native-localize'); |
| 79 | + if ('__setDefaultTimeZone' in Intl.DateTimeFormat) { |
| 80 | + Intl.DateTimeFormat.__setDefaultTimeZone(RNLocalize.getTimeZone()); |
| 81 | + } |
| 82 | +} |
15 | 83 | ``` |
16 | 84 |
|
17 | 85 | ## Contributing |
|
0 commit comments