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

95 lines
2.3 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';
2019-03-29 19:36:07 +00:00
import sharedStyles from '../../views/Styles';
import { COLOR_WHITE } from '../../constants/colors';
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: {
2019-03-29 19:36:07 +00:00
color: COLOR_WHITE,
2017-11-23 19:12:18 +00:00
textAlign: 'center',
fontSize: 16,
2019-03-29 19:36:07 +00:00
...sharedStyles.textSemibold
},
description: {
2019-03-29 19:36:07 +00:00
color: COLOR_WHITE,
textAlign: 'center',
fontSize: 14,
2019-03-29 19:36:07 +00:00
...sharedStyles.textMedium
},
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>
);
}
}