verdnatura-chat/app/containers/message/PhotoModal.js

89 lines
2.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { View, Text, TouchableWithoutFeedback, ActivityIndicator, StyleSheet } from 'react-native';
import FastImage from 'react-native-fast-image';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import ImageViewer from 'react-native-image-zoom-viewer';
import { responsive } from 'react-native-responsive-ui';
const styles = StyleSheet.create({
imageWrapper: {
2017-11-23 19:12:18 +00:00
flex: 1
},
titleContainer: {
width: '100%',
alignItems: 'center',
2017-11-23 19:12:18 +00:00
marginVertical: 10
},
title: {
color: '#ffffff',
2017-11-23 19:12:18 +00:00
textAlign: 'center',
fontSize: 16,
fontWeight: '600'
},
description: {
color: '#ffffff',
textAlign: 'center',
fontSize: 14,
fontWeight: '500'
},
indicatorContainer: {
alignItems: 'center',
justifyContent: 'center'
}
});
const margin = 40;
@responsive
export default class PhotoModal extends React.PureComponent {
static propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string,
image: PropTypes.string.isRequired,
isVisible: PropTypes.bool,
onClose: PropTypes.func.isRequired,
window: PropTypes.object
}
render() {
2017-11-13 12:58:35 +00:00
const {
image, isVisible, onClose, title, description, window: { width, height }
2017-11-13 12:58:35 +00:00
} = this.props;
return (
<Modal
isVisible={isVisible}
style={{ alignItems: 'center' }}
onBackdropPress={onClose}
onBackButtonPress={onClose}
animationIn='fadeIn'
animationOut='fadeOut'
>
<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>
</View>
</Modal>
);
}
}