Skip to content

Commit a75f21c

Browse files
committed
docs: add todos
1 parent 004dd67 commit a75f21c

File tree

1 file changed

+47
-41
lines changed

1 file changed

+47
-41
lines changed

README.md

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
![@georstat:react-native-image-gallery default_demo](https://user-images.githubusercontent.com/717975/142775046-475bfc3b-6326-4b3d-afa3-58189e003043.gif)
2424

25-
2625
## Installation
2726

2827
#### yarn:
@@ -68,12 +67,14 @@ const MyGallery = () => {
6867
```
6968

7069
#### Custom Gallery without thumbs:
70+
7171
For more info check [example](https://github.com/georstat/react-native-image-gallery/tree/main/example/src)
7272

7373
This example uses [georstat/react-native-image-cache](https://github.com/georstat/react-native-image-cache) for image caching
74+
7475
```tsx
75-
import {CacheManager, CachedImage} from '@georstat/react-native-image-cache';
76-
import {Dirs} from 'react-native-file-access';
76+
import { CacheManager, CachedImage } from '@georstat/react-native-image-cache';
77+
import { Dirs } from 'react-native-file-access';
7778

7879
CacheManager.config = {
7980
baseDir: `${Dirs.CacheDir}/images_cache/`,
@@ -83,53 +84,53 @@ CacheManager.config = {
8384
};
8485

8586
const MyGallery = () => {
86-
const [isOpen, setIsOpen] = useState(false);
87-
const openGallery = () => setIsOpen(true);
88-
const closeGallery = () => setIsOpen(false);
87+
const [isOpen, setIsOpen] = useState(false);
88+
const openGallery = () => setIsOpen(true);
89+
const closeGallery = () => setIsOpen(false);
8990

90-
const renderHeaderComponent = (image: any, currentIndex: number) => {
91-
return <Header currentIndex={currentIndex} />;
92-
};
93-
94-
const renderFooterComponent = (image: any, currentIndex: number) => {
95-
return <Footer total={images.length} currentIndex={currentIndex} />;
96-
};
97-
98-
const renderCustomImage = (image: Image) => {
99-
return (
100-
<View style={styles.customImageContainer}>
101-
<CachedImage
102-
resizeMode="cover"
103-
source={image.url}
104-
style={styles.customImage}
105-
thumbnailSource="https://via.placeholder.com/350x150"
106-
/>
107-
</View>
108-
);
109-
};
91+
const renderHeaderComponent = (image: any, currentIndex: number) => {
92+
return <Header currentIndex={currentIndex} />;
93+
};
94+
95+
const renderFooterComponent = (image: any, currentIndex: number) => {
96+
return <Footer total={images.length} currentIndex={currentIndex} />;
97+
};
98+
99+
const renderCustomImage = (image: Image) => {
110100
return (
111-
<View>
112-
<Button onPress={openGallery} title="Open Gallery" />
113-
<ImageGallery
114-
close={closeCustomGallery}
115-
hideThumbs
116-
images={images}
117-
isOpen={isCustomGalleryOpen}
118-
renderCustomImage={renderCustomImage}
119-
renderFooterComponent={renderFooterComponent}
120-
renderHeaderComponent={renderHeaderComponent}
121-
/>
122-
</View>
123-
)
124-
}
101+
<View style={styles.customImageContainer}>
102+
<CachedImage
103+
resizeMode="cover"
104+
source={image.url}
105+
style={styles.customImage}
106+
thumbnailSource="https://via.placeholder.com/350x150"
107+
/>
108+
</View>
109+
);
110+
};
111+
return (
112+
<View>
113+
<Button onPress={openGallery} title="Open Gallery" />
114+
<ImageGallery
115+
close={closeCustomGallery}
116+
hideThumbs
117+
images={images}
118+
isOpen={isCustomGalleryOpen}
119+
renderCustomImage={renderCustomImage}
120+
renderFooterComponent={renderFooterComponent}
121+
renderHeaderComponent={renderHeaderComponent}
122+
/>
123+
</View>
124+
);
125+
};
125126
```
126127

127128
## Props
128129

129130
#### `CachedImage` accepts the following props:
130131

131132
| Properties | PropType | Description |
132-
|-------------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------|
133+
| ----------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
133134
| `isOpen` | `Boolean` | (**Required**) when to show the gallery. |
134135
| `images` | `Array` | (**Required**) array of objects. Every image must have a `url` (required), a thumbUrl (optional) and id (optional) and any other info you need |
135136
| `resizeMode` | `string` | React Native Image component [resizeMode](https://reactnative.dev/docs/image#resizemode) defaults to `contain`, used on images |
@@ -144,6 +145,11 @@ const MyGallery = () => {
144145
| `renderHeaderComponent` | `Func` | Function to render a custom header at the top of the screen. Accepts image and current index, eg. `(image:Image, currentIndex:number) => ...` |
145146
| `renderFooterComponent` | `Func` | Function to render a custom header at the top of the screen. Accepts image and current index eg. `(image:Image, currentIndex:number) => ...` |
146147

148+
## Todo:
149+
150+
- Add zoom factor
151+
- Add prop to keep zoom and double tap to zoom out
152+
147153
## Authors:
148154

149155
- [Efstathios Ntonas](https://github.com/efstathiosntonas)

0 commit comments

Comments
 (0)