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
11 changes: 7 additions & 4 deletions PhotoGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PhotoGrid extends PureComponent {
static defaultProps = {
numberImagesToShow: 0,
onPressImage: () => {},
activeOpacity: 0.7,
}

isLastImage = (index, secondViewImages) => {
Expand Down Expand Up @@ -74,7 +75,7 @@ class PhotoGrid extends PureComponent {
<View style={[{ flexDirection: direction, width, height }, this.props.styles]}>
<View style={{ flex: 1, flexDirection: direction === 'row' ? 'column' : 'row' }}>
{firstViewImages.map((image, index) => (
<TouchableOpacity activeOpacity={0.7} key={index} style={{ flex: 1 }}
<TouchableOpacity activeOpacity={this.props.activeOpacity} key={index} style={{ flex: 1 }}
onPress={event => this.handlePressImage(event, { image })}>
<ImageLoad
style={[styles.image, { width: firstImageWidth, height: firstImageHeight }, this.props.imageStyle]}
Expand All @@ -88,7 +89,7 @@ class PhotoGrid extends PureComponent {
secondViewImages.length ? (
<View style={{ width: secondViewWidth, height: secondViewHeight, flexDirection: direction === 'row' ? 'column' : 'row' }}>
{secondViewImages.map((image, index) => (
<TouchableOpacity activeOpacity={0.7} key={index} style={{ flex: 1 }}
<TouchableOpacity activeOpacity={this.props.activeOpacity} key={index} style={{ flex: 1 }}
onPress={event => this.handlePressImage(event, { image, index }, secondViewImages)}>
{this.isLastImage(index, secondViewImages) ? (
<ImageBackground
Expand Down Expand Up @@ -123,7 +124,8 @@ PhotoGrid.prototypes = {
imageStyle: PropTypes.object,
onPressImage: PropTypes.func,
ratio: PropTypes.float,
imageProps: PropTypes.object
imageProps: PropTypes.object,
activeOpacity: PropTypes.number
}

PhotoGrid.defaultProps = {
Expand All @@ -132,7 +134,8 @@ PhotoGrid.defaultProps = {
imageProps: {},
width: width,
height: 400,
ratio: 1 / 3
ratio: 1 / 3,
activeOpacity: 0.7
}

const styles = {
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ style | PropTypes.object | Container styles
imageStyle | PropTypes.object | Image styles
imageProps | PropTypes.object | Image props
onPressImage | PropTypes.func | Callback when press image
activeOpacity | PropTypes.number | Opacity when an image is pressed

# Image props
Property | Description
Expand All @@ -69,4 +70,4 @@ isShowActivity | Show ActivityIndicator loading
placeholderStyle | Style placeholder image

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fduyluonglc%2Freact-native-thumbnail-grid.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fduyluonglc%2Freact-native-thumbnail-grid?ref=badge_large)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fduyluonglc%2Freact-native-thumbnail-grid.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fduyluonglc%2Freact-native-thumbnail-grid?ref=badge_large)