Open file attachment preview when tapping on the filename (#2049)
This commit is contained in:
parent
ebe7317c5f
commit
2a54c00e16
4 changed files with 11 additions and 15 deletions
|
|
@ -25,14 +25,12 @@ export default class FileAttachment extends PureComponent {
|
|||
file: PropTypes.object.isRequired,
|
||||
index: PropTypes.number.isRequired,
|
||||
onCaptureRef: PropTypes.func,
|
||||
onInfoPress: PropTypes.func,
|
||||
onPreviewPress: PropTypes.func,
|
||||
theme: PropTypes.object.isRequired,
|
||||
navigator: PropTypes.object,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
onInfoPress: () => true,
|
||||
onPreviewPress: () => true,
|
||||
};
|
||||
|
||||
|
|
@ -45,7 +43,11 @@ export default class FileAttachment extends PureComponent {
|
|||
};
|
||||
|
||||
handlePreviewPress = () => {
|
||||
this.props.onPreviewPress(this.props.index);
|
||||
if (this.documentElement) {
|
||||
this.documentElement.handlePreviewPress();
|
||||
} else {
|
||||
this.props.onPreviewPress(this.props.index);
|
||||
}
|
||||
};
|
||||
|
||||
renderFileInfo() {
|
||||
|
|
@ -79,12 +81,15 @@ export default class FileAttachment extends PureComponent {
|
|||
);
|
||||
}
|
||||
|
||||
setDocumentRef = (ref) => {
|
||||
this.documentElement = ref;
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
canDownloadFiles,
|
||||
deviceWidth,
|
||||
file,
|
||||
onInfoPress,
|
||||
theme,
|
||||
navigator,
|
||||
} = this.props;
|
||||
|
|
@ -105,6 +110,7 @@ export default class FileAttachment extends PureComponent {
|
|||
} else if (isDocument(data)) {
|
||||
fileAttachmentComponent = (
|
||||
<FileAttachmentDocument
|
||||
ref={this.setDocumentRef}
|
||||
canDownloadFiles={canDownloadFiles}
|
||||
file={file}
|
||||
navigator={navigator}
|
||||
|
|
@ -129,7 +135,7 @@ export default class FileAttachment extends PureComponent {
|
|||
<View style={[style.fileWrapper, {width}]}>
|
||||
{fileAttachmentComponent}
|
||||
<TouchableOpacity
|
||||
onPress={onInfoPress}
|
||||
onPress={this.handlePreviewPress}
|
||||
style={style.fileInfoContainer}
|
||||
>
|
||||
{this.renderFileInfo()}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ export default class FileAttachmentList extends Component {
|
|||
isFailed: PropTypes.bool,
|
||||
navigator: PropTypes.object,
|
||||
onLongPress: PropTypes.func,
|
||||
onPress: PropTypes.func,
|
||||
postId: PropTypes.string.isRequired,
|
||||
theme: PropTypes.object.isRequired,
|
||||
toggleSelected: PropTypes.func.isRequired,
|
||||
|
|
@ -125,11 +124,6 @@ export default class FileAttachmentList extends Component {
|
|||
this.items[idx] = ref;
|
||||
};
|
||||
|
||||
handleInfoPress = () => {
|
||||
this.props.hideOptionsContext();
|
||||
this.props.onPress();
|
||||
};
|
||||
|
||||
handlePreviewPress = preventDoubleTap((idx) => {
|
||||
this.props.hideOptionsContext();
|
||||
Keyboard.dismiss();
|
||||
|
|
@ -180,7 +174,6 @@ export default class FileAttachmentList extends Component {
|
|||
index={idx}
|
||||
navigator={navigator}
|
||||
onCaptureRef={this.handleCaptureRef}
|
||||
onInfoPress={this.handleInfoPress}
|
||||
onPreviewPress={this.handlePreviewPress}
|
||||
theme={this.props.theme}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -264,7 +264,6 @@ export default class PostBody extends PureComponent {
|
|||
fileIds,
|
||||
isFailed,
|
||||
navigator,
|
||||
onPress,
|
||||
postId,
|
||||
showLongPost,
|
||||
toggleSelected,
|
||||
|
|
@ -286,7 +285,6 @@ export default class PostBody extends PureComponent {
|
|||
hideOptionsContext={this.hideOptionsContext}
|
||||
isFailed={isFailed}
|
||||
onLongPress={this.showOptionsContext}
|
||||
onPress={onPress}
|
||||
postId={postId}
|
||||
toggleSelected={toggleSelected}
|
||||
navigator={navigator}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ export default class LongPost extends PureComponent {
|
|||
hideOptionsContext={emptyFunction}
|
||||
isFailed={false}
|
||||
onLongPress={emptyFunction}
|
||||
onPress={this.handlePress}
|
||||
postId={postId}
|
||||
toggleSelected={emptyFunction}
|
||||
navigator={navigator}
|
||||
|
|
|
|||
Loading…
Reference in a new issue