Skip to content

Commit 2e4d3da

Browse files
authored
docs: minor readme improvements (#571)
* docs: minor readme improvements * add missing TOC entry * minor change
1 parent 7abeaf9 commit 2e4d3da

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

README.md

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ The module is still published on `npm` under the old namespace (as documented) b
2222

2323
React Native date & time picker component for iOS, Android and Windows.
2424

25+
<details>
26+
<summary>Expand for screenshots</summary>
27+
2528
<table>
2629
<tr><td colspan=2><strong>iOS</strong></td></tr>
2730
<tr>
@@ -43,6 +46,8 @@ React Native date & time picker component for iOS, Android and Windows.
4346
</tr>
4447
</table>
4548

49+
</details>
50+
4651
## Table of Contents
4752

4853
- [React Native DateTimePicker](#react-native-datetimepicker)
@@ -53,6 +58,7 @@ React Native date & time picker component for iOS, Android and Windows.
5358
- [RN < 0.60](#rn--060-1)
5459
- [General Usage](#general-usage)
5560
- [Basic usage with state](#basic-usage-with-state)
61+
- [Localization note](#localization-note)
5662
- [Props](#props)
5763
- [`mode` (`optional`)](#mode-optional)
5864
- [`display` (`optional`)](#display-optional)
@@ -66,7 +72,7 @@ React Native date & time picker component for iOS, Android and Windows.
6672
- [`dateFormat` (`optional`, `Windows only`)](#dateFormat-optional-windows-only)
6773
- [`firstDayOfWeek` (`optional`, `Windows only`)](#firstDayOfWeek-optional-windows-only)
6874
- [`textColor` (`optional`, `iOS only`)](#textColor-optional-ios-only)
69-
- [`themeVariant` (`optional`, `iOS only`)](#themeVariant-optional-ios-only)
75+
- [`themeVariant` (`optional`, `iOS only`)](#themevariant-optional-ios-only)
7076
- [`locale` (`optional`, `iOS only`)](#locale-optional-ios-only)
7177
- [`is24Hour` (`optional`, `Windows and Android only`)](#is24hour-optional-windows-and-android-only)
7278
- [`neutralButtonLabel` (`optional`, `Android only`)](#neutralbuttonlabel-optional-android-only)
@@ -175,10 +181,13 @@ export const App = () => {
175181

176182
On Android, the picker will be controlled by the system locale. If you wish to change it, [see instructions here](https://stackoverflow.com/a/2900144/2070942).
177183

178-
On iOS, the locale can be controlled from Xcode, as [documented here](https://developer.apple.com/documentation/xcode/adding-support-for-languages-and-regions).
179-
> To localize the calendar days (avoid mixed language for month and day names): If you use a library like [i18next](https://github.com/i18next/react-i18next) or [react-localize-redux](https://github.com/ryandrewjohnson/react-localize-redux) to manage your translations, it is sufficient to add your target languages in the `project.pbxproj` as described in the Apple Documentation - but you are not required to add any localization keys (like the days of the week). iOS will automatically display the correct localized strings as long as the target language is contained in `project.pbxproj`.
184+
On iOS, use XCode, as [documented here](https://developer.apple.com/documentation/xcode/adding-support-for-languages-and-regions) to inform the OS about the locales your application supports. iOS will automatically display the correctly localized DateTimePicker as long as the target language is contained in `project.pbxproj`.
185+
186+
> If you use a library like [i18next](https://github.com/i18next/react-i18next) or [react-localize-redux](https://github.com/ryandrewjohnson/react-localize-redux) to manage your translations, it is sufficient to add your target languages as described in the Apple Documentation - but you are not required to add any localization keys (like, for example, the days of the week). iOS will automatically display the correct localized strings as long as the target language is contained in `project.pbxproj`.
187+
188+
For testing your localization setup, refer [here](https://developer.apple.com/documentation/xcode/testing-localizations-when-running-your-app).
180189

181-
There is also the iOS-only locale prop that can be used to force locale in some cases but its usage is discouraged due to [not working robustly in all picker modes](./docs/images/ios_date_new.png) (note the mixed month and day names).
190+
There is also the iOS-only locale prop that can be used to force locale in some cases but its usage is discouraged due to [not working robustly in all picker modes](./docs/images/ios_date_new.png) (note the mixed month and day names). To the best of our knowledge, it works reliably in the `spinner` mode.
182191

183192
For Expo, follow the [localization docs](https://docs.expo.dev/distribution/app-stores/#localizing-your-ios-app).
184193

@@ -315,6 +324,21 @@ Allows changing of the textColor of the date picker. Has effect only when `displ
315324
<RNDateTimePicker textColor="red" />
316325
```
317326

327+
#### `themeVariant` (`optional`, `iOS only`)
328+
329+
Allows overriding system theme variant (dark or light mode) used by the date picker.
330+
331+
:warning: Has effect only on iOS 14 and later. On iOS 13 & less, use `textColor` to make the picker dark-theme compatible
332+
333+
List of possible values:
334+
335+
- `"light"`
336+
- `"dark"`
337+
338+
```js
339+
<RNDateTimePicker themeVariant="light" />
340+
```
341+
318342
#### `locale` (`optional`, `iOS only`)
319343

320344
Allows changing the locale of the component. This affects the displayed text and the date / time formatting. By default, the device's locale is used. Please note using this prop is discouraged due to not working reliably in all picker modes.
@@ -326,7 +350,7 @@ Prefer localization as documented in [Localization note](#localization-note).
326350

327351
#### `is24Hour` (`optional`, `Windows and Android only`)
328352

329-
Allows changing of the time picker to a 24 hour format. By default, this value is decided automatcially based on the user's chosen locale and other preferences.
353+
Allows changing of the time picker to a 24 hour format. By default, this value is decided automatcially based on the locale and other preferences.
330354

331355
```js
332356
<RNDateTimePicker is24Hour={true} />
@@ -346,7 +370,7 @@ Pressing button can be observed in onChange handler as `event.type === 'neutralB
346370
The interval at which minutes can be selected.
347371
Possible values are: `1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30`
348372

349-
(On Windows, this can be any number between 0-59.)
373+
On Windows, this can be any number between 0-59.
350374

351375
on iOS, this in only supported when `display="spinner"`
352376

@@ -356,31 +380,17 @@ on iOS, this in only supported when `display="spinner"`
356380

357381
#### `style` (`optional`, `iOS only`)
358382

359-
Sets style directly on picker component. By default, the picker height is fixed to 216px.
383+
Sets style directly on picker component. By default, the picker height is determined based on the `display` prop.
360384

361385
Please note that by default, picker's text color is controlled by the application theme (light / dark mode). In dark mode, text is white and in light mode, text is black.
362386

363-
This means that eg. if the device has dark mode turned on, and your screen background color is white, you will not see the picker. Please use the `Appearance` api to adjust the picker's background color so that it is visible, as we do in the [example App](/example/App.js), use `themeVariant` prop or [opt-out from dark mode](https://stackoverflow.com/a/56546554/2070942).
387+
This means that eg. if the device has dark mode turned on, and your screen background color is white, you will not see the picker. Please use the `Appearance` api to adjust the picker's background color so that it is visible, as we do in the [example App](/example/App.js).
388+
Alternatively, use the `themeVariant` prop or [opt-out from dark mode (discouraged)](https://stackoverflow.com/a/56546554/2070942).
364389

365390
```js
366391
<RNDateTimePicker style={{flex: 1}} />
367392
```
368393

369-
#### `themeVariant` (`optional`, `iOS only`)
370-
371-
Allows overriding system theme variant (dark or light mode) used by the date picker.
372-
373-
:warning: Has effect only on iOS 14 and later. On iOS 13 & less, use `textColor` to make the picker dark-theme compatible
374-
375-
List of possible values:
376-
377-
- `"light"`
378-
- `"dark"`
379-
380-
```js
381-
<RNDateTimePicker themeVariant="light" />
382-
```
383-
384394
#### `disabled` (`optional`, `iOS only`)
385395

386396
If true, the user won't be able to interact with the view.
@@ -404,7 +414,7 @@ Please see [manual-installation.md](/docs/manual-installation.md)
404414
3. Install required pods by running `npx pod-install`
405415
4. Run `yarn start` to start Metro Bundler
406416
5. Run `yarn run start:ios` or `yarn run start:android` or `yarn run start:windows`
407-
6. To do any development on the library, open the example project (in the example folder!) in xCode or Android Studio. The example project depends on the library code, which you can edit and observe any changes in the example project.
417+
6. To do any development on the library, open the example project (in the `example` folder) in xCode or Android Studio. The example project depends on the library code, which you can edit and observe any changes in the example project.
408418

409419
[circle-ci-badge]: https://img.shields.io/circleci/project/github/react-native-community/datetimepicker/master.svg?style=flat-square
410420
[circle-ci-status]: https://circleci.com/gh/react-native-datetimepicker/datetimepicker.svg?style=svg

0 commit comments

Comments
 (0)