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

66 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
2017-11-23 19:12:18 +00:00
import { ScrollView, View, Text, TouchableWithoutFeedback } from 'react-native';
import FastImage from 'react-native-fast-image';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
const styles = {
imageWrapper: {
2017-11-23 19:12:18 +00:00
alignItems: 'stretch',
flex: 1
},
image: {
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'
}
};
export default class PhotoModal extends React.PureComponent {
static propTypes = {
title: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
isVisible: PropTypes.bool,
onClose: PropTypes.func.isRequired
}
render() {
2017-11-13 12:58:35 +00:00
const {
image, isVisible, onClose, title
} = this.props;
return (
<Modal
isVisible={isVisible}
onBackdropPress={onClose}
onBackButtonPress={onClose}
>
2017-11-23 19:12:18 +00:00
<TouchableWithoutFeedback onPress={onClose}>
<View style={styles.titleContainer}>
<Text style={styles.title}>{title}</Text>
</View>
</TouchableWithoutFeedback>
<View style={styles.imageWrapper}>
2017-11-23 19:12:18 +00:00
<ScrollView contentContainerStyle={styles.imageWrapper} maximumZoomScale={5}>
<TouchableWithoutFeedback onPress={onClose}>
<FastImage
2017-11-23 19:12:18 +00:00
style={styles.image}
source={{ uri: encodeURI(image) }}
mutable
resizeMode='contain'
/>
</TouchableWithoutFeedback>
</ScrollView>
</View>
</Modal>
);
}
}