Skip to content

Commit 85697c0

Browse files
authored
Thumbnails (#2)
* Added support for thumbnails * Updated docs
1 parent 760f206 commit 85697c0

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

README.md

+35-13
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ A React Native component to display a gallery of images.
2424

2525
#### iOS
2626

27-
1. In Xcode, in the project navigator, right click `Libraries` ➜ `Add Files to
28-
[your project's name]`
29-
2. Go to `node_modules``react-native-interactive-image-gallery` and add
30-
`RNIKInteractiveImageLibrary.xcodeproj`
31-
3. In XCode, in the project navigator, select your project. Add
32-
`libRNIKInteractiveImageLibrary.a` to your project's `Build Phases` ➜ `Link
33-
Binary With Libraries`
34-
4. Run your project (`Cmd+R`)<
27+
1. In Xcode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
28+
2. Go to `node_modules``react-native-interactive-image-gallery` and add
29+
`RNIKInteractiveImageLibrary.xcodeproj`
30+
3. In XCode, in the project navigator, select your project. Add
31+
`libRNIKInteractiveImageLibrary.a` to your project's `Build Phases``Link Binary With Libraries`
32+
4. Run your project (`Cmd+R`)<
3533

3634
#### Android
3735

@@ -40,27 +38,51 @@ No additional setup needed.
4038
## Usage
4139

4240
```javascript
43-
import ImageBrowser from 'react-native-interactive-image-gallery';
41+
import ImageBrowser from 'react-native-interactive-image-gallery'
4442

4543
class Images extends React.PureComponent<Props> {
4644
render() {
4745
const imageURLs: Array<Object> = this.props.images.map(
4846
(img: Object, index: number) => ({
4947
URI: img.uri,
48+
thumbnail: img.thumbnail,
5049
id: String(index),
5150
title: img.title,
5251
description: img.description
5352
})
54-
);
55-
return <ImageBrowser images={imageURLs} />;
53+
)
54+
return <ImageBrowser images={imageURLs} />
5655
}
5756
}
5857
```
5958

6059
## API
6160

62-
Work in progress 🚧👷🏻. Some features are experimental and the API will change in
63-
the future.
61+
The `<ImageBrowser />` component accepts the following props
62+
63+
### Props
64+
65+
| Prop | Type | Mandatory |
66+
| ------------------------------------- | --------------------- | --------- |
67+
| `images` | `Array<ImageSource>` | **Yes** |
68+
| `onPressImage` | `Function` |
69+
| `topMargin` | `number` |
70+
| `closeText` | `string` |
71+
| `infoTitleStyles` | `Animated.View.style` |
72+
| `infoDescriptionStyles` | `Animated.View.style` |
73+
| `enableTilt` (experimental, iOS only) | `boolean` |
74+
75+
Where `ImageSource` represents
76+
77+
### `ImageSource`
78+
79+
| Name | Type | Mandatory |
80+
| ------------- | -------- | --------- |
81+
| `id` | `string` | **Yes** |
82+
| `URI` | `string` | **Yes** |
83+
| `thumbnail` | `string` | **Yes** |
84+
| `title` | `string` |
85+
| `description` | `string` |
6486

6587
## Aknowledgements
6688

lib/ImageBrowser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import ImageViewer from './ImageViewer'
1515
export type ImageSource = {
1616
id: string,
1717
URI: string,
18+
thumbnail: string,
1819
title: ?string,
1920
description: ?string
2021
}
@@ -111,8 +112,7 @@ class ImageBrowser extends React.Component<Props, State> {
111112
visible={true}
112113
transparent={true}
113114
animationType={Platform.OS === 'ios' ? 'none' : 'fade'}
114-
onRequestClose={this.closeImageViewer}
115-
>
115+
onRequestClose={this.closeImageViewer}>
116116
<ImageViewer
117117
images={this.props.images}
118118
imageId={this.state.imageId}

lib/ImageListContainer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ImageListContainer extends React.PureComponent<Props> {
2020
images: PropTypes.arrayOf(
2121
PropTypes.shape({
2222
id: PropTypes.string.isRequired,
23-
URI: PropTypes.string.isRequired
23+
thumbnail: PropTypes.string.isRequired
2424
})
2525
).isRequired,
2626
onPressImage: PropTypes.func.isRequired,
@@ -35,7 +35,7 @@ class ImageListContainer extends React.PureComponent<Props> {
3535
<ImageCell
3636
key={`ImageCellId-${item.item.id}`}
3737
imageId={item.item.id}
38-
source={{ uri: item.item.URI }}
38+
source={{ uri: item.item.thumbnail }}
3939
onPressImage={this.props.onPressImage}
4040
shouldHideDisplayedImage={
4141
displayImageViewer && displayedImageId === item.item.id

0 commit comments

Comments
 (0)