1 | import PropTypes from 'prop-types';
|
2 | import React, { Component } from 'react';
|
3 | import { Image, StyleSheet, View, } from 'react-native';
|
4 |
|
5 |
|
6 | import Lightbox from 'react-native-lightbox';
|
7 | import { StylePropType } from './utils';
|
8 | const styles = StyleSheet.create({
|
9 | container: {},
|
10 | image: {
|
11 | width: 150,
|
12 | height: 100,
|
13 | borderRadius: 13,
|
14 | margin: 3,
|
15 | resizeMode: 'cover',
|
16 | },
|
17 | imageActive: {
|
18 | flex: 1,
|
19 | resizeMode: 'contain',
|
20 | },
|
21 | });
|
22 | export default class MessageImage extends Component {
|
23 | render() {
|
24 | const { containerStyle, lightboxProps, imageProps, imageStyle, currentMessage, } = this.props;
|
25 | if (!!currentMessage) {
|
26 | return (<View style={[styles.container, containerStyle]}>
|
27 | <Lightbox activeProps={{
|
28 | style: styles.imageActive,
|
29 | }} {...lightboxProps}>
|
30 | <Image {...imageProps} style={[styles.image, imageStyle]} source={{ uri: currentMessage.image }}/>
|
31 | </Lightbox>
|
32 | </View>);
|
33 | }
|
34 | return null;
|
35 | }
|
36 | }
|
37 | MessageImage.defaultProps = {
|
38 | currentMessage: {
|
39 | image: null,
|
40 | },
|
41 | containerStyle: {},
|
42 | imageStyle: {},
|
43 | imageProps: {},
|
44 | lightboxProps: {},
|
45 | };
|
46 | MessageImage.propTypes = {
|
47 | currentMessage: PropTypes.object,
|
48 | containerStyle: StylePropType,
|
49 | imageStyle: StylePropType,
|
50 | imageProps: PropTypes.object,
|
51 | lightboxProps: PropTypes.object,
|
52 | };
|
53 | //# sourceMappingURL=MessageImage.js.map |
\ | No newline at end of file |