-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathindex.native.js
50 lines (42 loc) · 1.38 KB
/
index.native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react';
import PropTypes from 'prop-types';
import {TouchableWithoutFeedback} from 'react-native';
import PDF from 'react-native-pdf';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions';
import FullScreenLoadingIndicator from '../FullscreenLoadingIndicator';
const propTypes = {
/** URL to full-sized image */
sourceURL: PropTypes.string,
/** Any additional styles to apply */
// eslint-disable-next-line react/forbid-prop-types
style: PropTypes.any,
...windowDimensionsPropTypes,
};
const defaultProps = {
sourceURL: '',
style: {},
};
/**
* On the native layer, we use a pdf library to display PDFs
*
* @param props
* @returns {JSX.Element}
*/
const PDFView = props => (
<TouchableWithoutFeedback style={[styles.flex1, props.style]}>
<PDF
activityIndicator={<FullScreenLoadingIndicator />}
source={{uri: props.sourceURL}}
style={[
styles.imageModalPDF,
StyleUtils.getWidthAndHeightStyle(props.windowWidth, props.windowHeight),
]}
/>
</TouchableWithoutFeedback>
);
PDFView.propTypes = propTypes;
PDFView.defaultProps = defaultProps;
PDFView.displayName = 'PDFView';
export default withWindowDimensions(PDFView);