Skip to content

Commit

Permalink
added lightbox for image gallery
Browse files Browse the repository at this point in the history
fixed inverted option
  • Loading branch information
Jan Romaniak committed Jan 18, 2019
1 parent 7c6b7da commit 2dce9f5
Show file tree
Hide file tree
Showing 6 changed files with 892 additions and 1,295 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0"
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-postcss": "^1.6.3"
},
"dependencies": {
"md5": "2.2.1",
Expand All @@ -56,6 +57,7 @@
"react-art": "^16.6.3",
"react-dev-utils": "^6.1.1",
"react-dom": "^16.6.3",
"react-image-lightbox": "^5.1.0",
"react-native-web": "0.9.9",
"shallowequal": "1.1.0",
"uuid": "3.3.2"
Expand Down
4 changes: 4 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import fs from 'fs';


Expand Down Expand Up @@ -32,5 +33,8 @@ export default {
runtimeHelpers: true,
exclude: 'node_modules/**',
}),
postcss({
plugins: [],
}),
],
};
29 changes: 24 additions & 5 deletions src/MessageImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,38 @@ import {
ViewPropTypes,
Dimensions,
} from 'react-native';
import Lightbox from 'react-image-lightbox';
import 'react-image-lightbox/style.css';
import TouchableOpacity from './TouchableOpacity';

export default class MessageImage extends React.Component {
render() {
const {width, height} = Dimensions.get('window');
state = {
isOpen: false,
};

onClickImage = () => {
this.setState({ isOpen: true });
}

render() {
const { isOpen } = this.state;
return (
<View style={[styles.container, this.props.containerStyle]}>
<TouchableOpacity
onPress={this.onClickImage}
style={[styles.container, this.props.containerStyle]}
>
<Image
{...this.props.imageProps}
style={[styles.image, this.props.imageStyle]}
source={{uri: this.props.currentMessage.image}}
source={{ uri: this.props.currentMessage.image }}
/>
</View>
{isOpen && (
<Lightbox
mainSrc={this.props.currentMessage.image}
onCloseRequest={() => this.setState({ isOpen: false })}
/>
)}
</TouchableOpacity>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class WebScrollView extends Component {
render() {
const { ListHeaderComponent, ListFooterComponent, data, inverted } = this.props;
let messages = data;
if (inverted) {
if (!inverted) {
messages = data.slice().reverse();
}
return (
Expand Down
Loading

0 comments on commit 2dce9f5

Please sign in to comment.