|
1 | | -# react-native-gesture-image |
| 1 | +# @duocvo/react-native-gesture-image |
2 | 2 |
|
3 | | -This library provides a highly customizable and performant image viewer component for React Native applications. It supports advanced gestures such as pinch-to-zoom, panning, and double-tap to zoom in and out, making it ideal for creating rich, interactive image viewing experiences. |
| 3 | +This library provides a highly customizable and performant image viewer component for React Native applications. It supports advanced gestures such as pinch-to-zoom, panning, and double-tap to zoom in and out, making it ideal for creating rich, interactive image viewing experiences. Built with **[react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/)** for handling advanced touch gestures like pinch and pan, and **[react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/)** for providing smooth animations for zooming and panning. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +IOS|ANDROID |
| 6 | +--|-- |
| 7 | +<video src="https://github.com/user-attachments/assets/d4ed6e2d-129d-475e-ad4f-bfbd9f916cda">|<video src="https://github.com/user-attachments/assets/a2b18502-bd07-4c39-8f40-b0001ea0ec60"> |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +This library relies on the following dependencies to enable gesture and animation support: |
| 12 | +- **[react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/)**: Handles advanced touch gestures like pinch and pan. |
| 13 | +- **[react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/)**: Provides smooth animations for zooming and panning. |
| 14 | + |
| 15 | +Install these prerequisites along with the library: |
| 16 | + |
| 17 | +```sh |
| 18 | +npm install react-native-gesture-handler react-native-reanimated |
| 19 | +# or |
| 20 | +yarn add react-native-gesture-handler react-native-reanimated |
| 21 | +``` |
6 | 22 |
|
| 23 | +## Installation |
7 | 24 | ```sh |
8 | | -npm install react-native-gesture-image |
| 25 | +npm install @duocvo/react-native-gesture-image |
| 26 | +#or |
| 27 | +yarn add @duocvo/react-native-gesture-image |
9 | 28 | ``` |
10 | 29 |
|
11 | 30 | ## Usage |
12 | 31 |
|
| 32 | +First, wrap your app with `GestureHandlerRootView` component: |
13 | 33 |
|
14 | 34 | ```js |
15 | | -import { multiply } from 'react-native-gesture-image'; |
| 35 | +import { GestureHandlerRootView } from 'react-native-gesture-handler'; |
| 36 | + |
| 37 | +export default function App() { |
| 38 | + return ( |
| 39 | + <GestureHandlerRootView> |
| 40 | + <ActualApp /> |
| 41 | + </GestureHandlerRootView> |
| 42 | + ); |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Then, use the components provided by the library: |
16 | 47 |
|
17 | | -// ... |
| 48 | +```js |
| 49 | +import Gallery from '@duocvo/react-native-gesture-image'; |
18 | 50 |
|
19 | | -const result = await multiply(3, 7); |
| 51 | +// Example usage of Gallery |
| 52 | +const images = [ |
| 53 | + { uri: 'https://example.com/image1.jpg' }, |
| 54 | + { uri: 'https://example.com/image2.jpg' }, |
| 55 | + { uri: 'https://example.com/image3.jpg' }, |
| 56 | +]; |
| 57 | + |
| 58 | +<Gallery data={images} /> |
| 59 | +``` |
| 60 | +**Note:** Gallery is built on top of FlatList for rendering multiple images efficiently. If you don’t want to use FlatList and prefer a single image viewer, use ImageViewer instead. See the example below: |
| 61 | +```js |
| 62 | +import { ImageViewer } from '@duocvo/react-native-gesture-image'; |
| 63 | + |
| 64 | +// Example usage of ImageViewer |
| 65 | +const imageSource = { uri: 'https://example.com/image.jpg' }; |
| 66 | + |
| 67 | +<ImageViewer source={imageSource} /> |
20 | 68 | ``` |
21 | 69 |
|
| 70 | +## Props |
| 71 | + |
| 72 | +### Gallery |
| 73 | + |
| 74 | +| Prop | Type | Default | Description | Required | |
| 75 | +|-----------------------|----------|---------|--------------------------------------------------|----------| |
| 76 | +| `data` | `array` | `[]` | Array of image sources | Yes | |
| 77 | +| `style` | `object` | | Custom style for the gallery container | No | |
| 78 | +| `imageStyle` | `object` | | Custom style for each image | No | |
| 79 | +| `containerStyle` | `object` | | Custom style for the gallery container | No | |
| 80 | +| `contentContainerStyle` | `object` | | Custom style for the content container | No | |
| 81 | +| `backdropColor` | `string` | `black` | Background color of the gallery | No | |
| 82 | + |
| 83 | + |
| 84 | +### ImageViewer |
| 85 | + |
| 86 | +| Prop | Type | Default | Description | Required | |
| 87 | +|-------------------|----------|---------|--------------------------------------------------|----------| |
| 88 | +| `source` | `object` | | Source for the image | Yes | |
| 89 | +| `imageStyle` | `object` | | Custom style for the image | No | |
| 90 | + |
22 | 91 |
|
23 | 92 | ## Contributing |
24 | 93 |
|
|
0 commit comments