Skip to content

Commit ec5ba02

Browse files
committed
✨ feat: add doc for Preview
1 parent f0b513e commit ec5ba02

File tree

5 files changed

+84
-6
lines changed

5 files changed

+84
-6
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ React Native Multiple Image Picker **(RNMIP)** enables application to pick image
1414

1515
## Documentation 📚
1616

17-
1817
## Features 🔥
1918

2019
| 🤩 | ![Logo][Logo] |
@@ -78,10 +77,10 @@ const onPicker = async () => {
7877
- [x] Multiple Crop Image.
7978
- [x] Multiple Preview Image.
8079
- [x] Dynamic Theme.
81-
- [x] Dynamic Language.
82-
- [ ] Open Camera Controller.
80+
- [x] Dynamic Language
8381
- [x] Open Crop Controller.
84-
- [ ] Open Preview Controller.
82+
- [x] Open Preview Controller.
83+
- [ ] Open Camera Controller.
8584

8685
## Sponsor & Support ☕️
8786

docs/docs/PREVIEW.mdx

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
id: preview
3+
title: Open Preview
4+
sidebar_label: Open Preview
5+
slug: /preview
6+
---
7+
8+
import ReactPlayer from 'react-player'
9+
10+
## Overview
11+
12+
Preview is a simple image viewer that supports both local and remote media. It allows you to preview images and videos seamlessly.
13+
14+
<ReactPlayer
15+
playing
16+
controls
17+
width="100%"
18+
height="100%"
19+
url="https://github.com/user-attachments/assets/92a1c319-ad99-4d24-892c-7cd878787acd"
20+
/>
21+
22+
## Usage
23+
24+
```typescript
25+
import { openPreview } from '@baronha/react-native-multiple-image-picker'
26+
27+
const cropConfig: CropConfig = {
28+
language: 'system',
29+
}
30+
31+
const media: MediaPreview[] = [
32+
// remote image
33+
{
34+
path: 'https://images.unsplash.com/photo-1733235015085-fc29c17c4a16?w=500',
35+
type: 'image',
36+
},
37+
// local video
38+
{
39+
path: 'file://Documents/video-sample/mp4',
40+
thumbnail:
41+
'https://images.unsplash.com/photo-1733889886752-f4599c954608?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
42+
type: 'video',
43+
},
44+
// remote video
45+
{
46+
path: 'https://cdn.pixabay.com/video/2024/02/09/199958-911694865_large.mp4',
47+
type: 'video',
48+
},
49+
]
50+
51+
// call to preview
52+
openPreview(media, 2, cropConfig)
53+
```
54+
55+
## `MediaPreview[]`
56+
57+
`MediaPreview[]` is an array of media objects that you want to preview. Each object in the array should have the following properties:<br/>
58+
59+
**NOTE**: You can also use [`Result[]`](/result) from openPicker's return result
60+
61+
- `path`: A string representing the URL or file path of the media.
62+
- `type`: A string indicating the type of media, either `image` or `video`.
63+
- `thumbnail` (optional): A string representing the URL of the thumbnail image for videos.
64+
- `localIdentifier` (optional): A string representing the local identifier for media from device gallery.
65+
66+
## `index`
67+
68+
The `index` parameter in the `openPreview` function specifies the initial media item to display. It is a zero-based index, meaning that `0` will display the first item in the `MediaPreview` array.
69+
70+
## `cropConfig`
71+
72+
### [`language`](/config/#language)
73+
74+
## Additional Information
75+
76+
- Ensure that the media paths are accessible and correctly formatted.
77+
- The `openPreview` function is part of the `@baronha/react-native-multiple-image-picker` package, which should be installed and properly configured in your project.
78+
79+
For more detailed information, refer to the [official documentation](https://github.com/baronha/react-native-multiple-image-picker).

docs/sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const sidebars: SidebarsConfig = {
2525
},
2626

2727
'crop',
28+
'preview',
2829
],
2930
}
3031

example/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
Config,
2323
openCropper,
2424
openPreview,
25-
MediaPreview,
2625
} from '@baronha/react-native-multiple-image-picker'
2726
import { useImmer } from 'use-immer'
2827
import { StatusBar } from 'expo-status-bar'

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export async function openCropper(
9090
}
9191

9292
export function openPreview(
93-
media: Result[] | MediaPreview[],
93+
media: MediaPreview[] | Result[],
9494
index: number = 0,
9595
conf: PreviewConfig
9696
): void {

0 commit comments

Comments
 (0)