2017-09-21 17:08:00 +00:00
|
|
|
import React from 'react';
|
2018-07-17 19:10:27 +00:00
|
|
|
import { View, Text, TouchableWithoutFeedback, ActivityIndicator, StyleSheet } from 'react-native';
|
2018-05-07 20:41:36 +00:00
|
|
|
import FastImage from 'react-native-fast-image';
|
2017-09-21 17:08:00 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Modal from 'react-native-modal';
|
2018-07-17 19:10:27 +00:00
|
|
|
import ImageViewer from 'react-native-image-zoom-viewer';
|
|
|
|
import { responsive } from 'react-native-responsive-ui';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
2018-07-17 19:10:27 +00:00
|
|
|
const styles = StyleSheet.create({
|
2017-09-21 17:08:00 +00:00
|
|
|
imageWrapper: {
|
2017-11-23 19:12:18 +00:00
|
|
|
flex: 1
|
2017-09-21 17:08:00 +00:00
|
|
|
},
|
|
|
|
titleContainer: {
|
|
|
|
width: '100%',
|
|
|
|
alignItems: 'center',
|
2017-11-23 19:12:18 +00:00
|
|
|
marginVertical: 10
|
2017-09-21 17:08:00 +00:00
|
|
|
},
|
|
|
|
title: {
|
|
|
|
color: '#ffffff',
|
2017-11-23 19:12:18 +00:00
|
|
|
textAlign: 'center',
|
2017-09-21 17:08:00 +00:00
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: '600'
|
2018-07-17 19:10:27 +00:00
|
|
|
},
|
|
|
|
description: {
|
|
|
|
color: '#ffffff',
|
|
|
|
textAlign: 'center',
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: '500'
|
|
|
|
},
|
|
|
|
indicatorContainer: {
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center'
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2018-07-17 19:10:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const margin = 40;
|
2017-09-21 17:08:00 +00:00
|
|
|
|
2018-07-17 19:10:27 +00:00
|
|
|
@responsive
|
2018-02-08 14:08:50 +00:00
|
|
|
export default class PhotoModal extends React.PureComponent {
|
2017-09-21 17:08:00 +00:00
|
|
|
static propTypes = {
|
|
|
|
title: PropTypes.string.isRequired,
|
2018-07-17 19:10:27 +00:00
|
|
|
description: PropTypes.string,
|
2017-09-21 17:08:00 +00:00
|
|
|
image: PropTypes.string.isRequired,
|
|
|
|
isVisible: PropTypes.bool,
|
2018-07-17 19:10:27 +00:00
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
window: PropTypes.object
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
|
|
|
render() {
|
2017-11-13 12:58:35 +00:00
|
|
|
const {
|
2018-07-17 19:10:27 +00:00
|
|
|
image, isVisible, onClose, title, description, window: { width, height }
|
2017-11-13 12:58:35 +00:00
|
|
|
} = this.props;
|
2017-09-21 17:08:00 +00:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
isVisible={isVisible}
|
2018-07-17 19:10:27 +00:00
|
|
|
style={{ alignItems: 'center' }}
|
2017-09-21 17:08:00 +00:00
|
|
|
onBackdropPress={onClose}
|
|
|
|
onBackButtonPress={onClose}
|
2018-07-17 19:10:27 +00:00
|
|
|
animationIn='fadeIn'
|
|
|
|
animationOut='fadeOut'
|
2017-09-21 17:08:00 +00:00
|
|
|
>
|
2018-07-17 19:10:27 +00:00
|
|
|
<View style={{ width: width - margin, height: height - margin }}>
|
|
|
|
<TouchableWithoutFeedback onPress={onClose}>
|
|
|
|
<View style={styles.titleContainer}>
|
|
|
|
<Text style={styles.title}>{title}</Text>
|
|
|
|
<Text style={styles.description}>{description}</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableWithoutFeedback>
|
|
|
|
<View style={styles.imageWrapper}>
|
|
|
|
<ImageViewer
|
|
|
|
imageUrls={[{ url: encodeURI(image) }]}
|
|
|
|
onClick={onClose}
|
|
|
|
backgroundColor='transparent'
|
|
|
|
enableSwipeDown
|
|
|
|
onSwipeDown={onClose}
|
|
|
|
renderIndicator={() => {}}
|
|
|
|
renderImage={props => <FastImage {...props} />}
|
|
|
|
loadingRender={() => (
|
|
|
|
<View style={[styles.indicatorContainer, { width, height }]}>
|
|
|
|
<ActivityIndicator />
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
/>
|
2017-11-23 19:12:18 +00:00
|
|
|
</View>
|
2017-09-21 17:08:00 +00:00
|
|
|
</View>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|