mattermost-mobile/app/components/post_attachment_image/index.js
Elias Nahum dbd7bc8a51
Gallery Improvements (#4837)
* Open/Close Gallery transitions

* Include postId in file info & disable opening the gallery in some cases

* Add progress bar component

* Transition to gallery based on platform

* Improve getting the filename for non attachments

* Patch RNFetchBlob TS definition

* Add gallery types

* fix unit tests for message and post attachment

* add getLocalPath method

* Add react-native-share dependency

* Re-style gallery footer

* Refactor Gallery screen

* Double tap zoom in/out and translate

* Make android activity "transparent"

* Do not animate to height on dismissing gallery

* Open gallery for file uploads

* Fix borderRadius for gallery action button

* Use progress bar for file uploads

* Replace progress bar for file attachment document

* Upgrade RNN to 7.1.0 to fix share elements transitions

* Fix Gallery unit tests

* translate down when popping screen on iOS

* Swipe, Pan & Tap fixes

* fix gallery footer avatar eslint

* Fix gallery snapshot tests

* Use CompassIcon in Gallery

* Feedback from UX review

* Fix gallery UI for other file types

* Set other file type gallery button to 48pt
2020-11-06 21:17:27 -03:00

71 lines
2.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React from 'react';
import {StyleSheet, View} from 'react-native';
import ProgressiveImage from 'app/components/progressive_image';
import TouchableWithFeedback from 'app/components/touchable_with_feedback';
import {isGifTooLarge} from 'app/utils/images';
export default class PostAttachmentImage extends React.PureComponent {
static propTypes = {
height: PropTypes.number.isRequired,
id: PropTypes.string,
imageMetadata: PropTypes.object,
onError: PropTypes.func.isRequired,
onImagePress: PropTypes.func.isRequired,
uri: PropTypes.string,
width: PropTypes.number.isRequired,
};
static defaultProps = {
frameCount: 0,
};
handlePress = () => {
this.props.onImagePress();
};
render() {
if (isGifTooLarge(this.props.imageMetadata)) {
return null;
}
// Note that TouchableWithoutFeedback only works if its child is a View
return (
<TouchableWithFeedback
onPress={this.handlePress}
style={[styles.imageContainer, {height: this.props.height}]}
type={'none'}
>
<View>
<ProgressiveImage
id={this.props.id}
style={[styles.image, {width: this.props.width, height: this.props.height}]}
imageUri={this.props.uri}
resizeMode='contain'
onError={this.props.onError}
/>
</View>
</TouchableWithFeedback>
);
}
}
const styles = StyleSheet.create({
imageContainer: {
alignItems: 'flex-start',
justifyContent: 'flex-start',
marginBottom: 6,
marginTop: 10,
},
image: {
alignItems: 'center',
borderRadius: 3,
justifyContent: 'center',
marginVertical: 1,
},
});