Skip to content

Commit 079237c

Browse files
Update docs
1 parent 7babe21 commit 079237c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ React Native date & time picker component for iOS, Android and Windows (please n
5555
<td><p align="center"><img src="./docs/images/android_material_date.jpg" width="200" height="400"/></p></td>
5656
<td><p align="center"><img src="./docs/images/android_material_time.jpg" width="200" height="400"/></p></td>
5757
</tr>
58+
<tr>
59+
<td colspan=2><p align="center"><img src="./docs/images/android_material_range.jpg" width="200" height="400"/></p></td>
60+
</tr>
5861
<tr><td colspan=1><strong>Windows</strong></td></tr>
5962
<tr>
6063
<td><p align="center"><img src="./docs/images/windows_date.png" width="380" height="430"/></p></td>
@@ -78,6 +81,7 @@ React Native date & time picker component for iOS, Android and Windows (please n
7881
- [Localization note](#localization-note)
7982
- [Android imperative API](#android-imperative-api)
8083
- [Android styling](#android-styling)
84+
- [Date range picker (Android only)](#date-range-picker)
8185
- [Props / params](#component-props--params-of-the-android-imperative-api)
8286
- [`mode` (`optional`)](#mode-optional)
8387
- [`display` (`optional`)](#display-optional)
@@ -301,6 +305,57 @@ Styling of the dialogs on Android can be easily customized by using the provided
301305

302306
Refer to this documentation for more information: [android-styling.md](/docs/android-styling.md).
303307

308+
### Date range picker (Android only)
309+
310+
Android has an additional component that allows users to select a range of dates (start and end dates). This is only available as a Material picker, meaning your application theme must inherit from `Theme.Material3.DayNight.NoActionBar` in `styles.xml`.
311+
312+
The component is accessible through an imperative API, similar to the Android date and time pickers.
313+
314+
```js
315+
MaterialRangePicker.open({
316+
value: {
317+
start: LAST_SUNDAY,
318+
end: NEXT_SUNDAY,
319+
},
320+
onChange: handleChange,
321+
fullscreen: true,
322+
});
323+
```
324+
325+
The range picker supports many of the same props as the Material date picker with a few modifications:
326+
327+
### `value` (`optional`)
328+
329+
The value is an optional object with two properties: `start` and `end`. Both properties can be `null` or a `Date` object.
330+
331+
```js
332+
MaterialRangePicker.open({
333+
value: {
334+
start: new Date(),
335+
end: new Date(),
336+
},
337+
});
338+
```
339+
340+
This will pre-select the range picker with the provided dates. If no value is provided, the user will be able to select any range.
341+
342+
### `onChange` (`required`)
343+
344+
Range change handler.
345+
346+
This is called when the user changes the range. It receives the event and the new range as parameters. The range will be in the same format as the `value` prop.
347+
348+
```js
349+
const setRange = (event: RangePickerEvent, range: Range) => {
350+
const {
351+
type,
352+
nativeEvent: {startTimestamp, endTimestamp, utcOffset},
353+
} = event;
354+
};
355+
```
356+
357+
The utcOffset field is only available on Android and iOS. It is the offset in minutes between the selected date and UTC time.
358+
304359
## Component props / params of the Android imperative api
305360

306361
> Please note that this library currently exposes functionality from [`UIDatePicker`](https://developer.apple.com/documentation/uikit/uidatepicker?language=objc) on iOS and [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog) + [TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) on Android, and [`CalendarDatePicker`](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/calendar-date-picker) + [TimePicker](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.timepicker?view=winrt-19041) on Windows.
106 KB
Loading

0 commit comments

Comments
 (0)