Skip to content

Commit 7d50721

Browse files
Add something to readme
1 parent e6dc726 commit 7d50721

File tree

2 files changed

+76
-90
lines changed

2 files changed

+76
-90
lines changed

README.md

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,85 @@
1-
# react-native-paper-dates
1+
## react-native-paper-dates (WIP, no offical release yet)
22

3-
Performant Date Picker for React Native Paper
3+
Demo: (https://twitter.com/RichardLindhout/status/1294636692540985344)
44

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
639

7-
```sh
8-
npm install react-native-paper-dates
940
```
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');
1074

11-
## Usage (TODO)
75+
require('@formatjs/intl-locale/polyfill');
1276

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+
}
1583
```
1684

1785
## Contributing

src/README.md

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)