Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/CameraRollBrowser/ImageCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,24 @@ export default class ImageCell extends React.PureComponent {
imageSize
} = this.state;
const {
data, index, source, imageMargin, imagesPerRow,
data, index, source, imageComponent, imageMargin, imagesPerRow,
imageContainerStyle, renderIndividualHeader,
renderIndividualFooter
} = this.props;
const header = (renderIndividualHeader) &&
renderIndividualHeader(data, index);
const footer = (renderIndividualFooter) &&
renderIndividualFooter(data, index);

const style = {
height: imageSize,
width: imageSize,
backgroundColor: "lightgrey",
...imageContainerStyle
}

const handleLoad = () => this.setState({ imageLoaded: true });

return (
<TouchableOpacity
style={{
Expand All @@ -93,19 +103,14 @@ export default class ImageCell extends React.PureComponent {
onPress={() => this._onPressImage(source.uri)}
>
{header}
<Animated.Image
onLoad={() => {
this.setState({ imageLoaded: true });
}}
source={source}
resizeMode="cover"
style={{
height: imageSize,
width: imageSize,
backgroundColor: "lightgrey",
...imageContainerStyle
}}
/>
{imageComponent ? imageComponent({ onLoad: handleLoad, source, style }) :
<Animated.Image
onLoad={handleLoad}
source={source}
resizeMode="cover"
style={style}
/>
}
{footer}
</TouchableOpacity>
);
Expand Down
3 changes: 3 additions & 0 deletions src/CameraRollBrowser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class CameraRollBrowser extends React.PureComponent {
enableCameraRoll: PropTypes.bool,
onGetData: PropTypes.func,
itemCount: PropTypes.number,
imageComponent: PropTypes.func,
images: PropTypes.arrayOf(PropTypes.object).isRequired,
imagesPerRow: PropTypes.number,
initialNumToRender: PropTypes.number,
Expand Down Expand Up @@ -384,6 +385,7 @@ export default class CameraRollBrowser extends React.PureComponent {

_renderImage = ({ item, index }) => {
var {
imageComponent,
imageMargin,
imagesPerRow,
containerWidth,
Expand All @@ -399,6 +401,7 @@ export default class CameraRollBrowser extends React.PureComponent {
data={item}
imageId={item.id}
source={{ uri: item.uri }}
imageComponent={imageComponent}
imageMargin={imageMargin}
imagesPerRow={imagesPerRow}
containerWidth={containerWidth}
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class CameraRollGallery extends React.PureComponent {
"Videos",
"All",
]),
imageComponent: PropTypes.func,
imageMargin: PropTypes.number,
containerWidth: PropTypes.number,
backgroundColor: PropTypes.string,
Expand Down Expand Up @@ -198,6 +199,7 @@ export default class CameraRollGallery extends React.PureComponent {
onGetData={this.props.onGetData}
itemCount={this.props.itemCount}
images={this.state.resolvedData}
imageComponent={this.props.imageComponent}
imagesPerRow={this.props.imagesPerRow}
initialNumToRender={this.props.initialNumToRender}
removeClippedSubviews={this.props.removeClippedSubviews}
Expand Down