Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions assets/css/pdf.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
border-image: url(../images/shadow.png) 9 9 repeat;
background-color: rgba(255, 255, 255, 1);
}
.react-pdf__message {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

.react-pdf__Page__annotations {
height: 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ function AttachmentModal(props) {
onToggleKeyboard={updateConfirmButtonVisibility}
isWorkspaceAvatar={props.isWorkspaceAvatar}
fallbackSource={props.fallbackSource}
isUsedInAttachmentModal
/>
)
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, {memo} from 'react';
import styles from '../../../../styles/styles';
import {attachmentViewPdfPropTypes, attachmentViewPdfDefaultProps} from './propTypes';
import PDFView from '../../../PDFView';

function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, onPress, onScaleChanged, onToggleKeyboard, onLoadComplete}) {
function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, onPress, onScaleChanged, onToggleKeyboard, onLoadComplete, errorLabelStyles, style}) {
return (
<PDFView
onPress={onPress}
isFocused={isFocused}
sourceURL={encryptedSourceUrl}
fileName={file.name}
style={styles.imageModalPDF}
style={style}
onToggleKeyboard={onToggleKeyboard}
onScaleChanged={onScaleChanged}
onLoadComplete={onLoadComplete}
errorLabelStyles={errorLabelStyles}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {memo, useCallback, useContext, useEffect} from 'react';
import styles from '../../../../styles/styles';
import {attachmentViewPdfPropTypes, attachmentViewPdfDefaultProps} from './propTypes';
import PDFView from '../../../PDFView';
import AttachmentCarouselPagerContext from '../../AttachmentCarousel/Pager/AttachmentCarouselPagerContext';

function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarousel, onPress, onScaleChanged: onScaleChangedProp, onToggleKeyboard, onLoadComplete}) {
function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarousel, onPress, onScaleChanged: onScaleChangedProp, onToggleKeyboard, onLoadComplete, errorLabelStyles, style}) {
const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext);

useEffect(() => {
Expand Down Expand Up @@ -41,10 +40,11 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse
isFocused={isFocused}
sourceURL={encryptedSourceUrl}
fileName={file.name}
style={styles.imageModalPDF}
style={style}
onToggleKeyboard={onToggleKeyboard}
onScaleChanged={onScaleChanged}
onLoadComplete={onLoadComplete}
errorLabelStyles={errorLabelStyles}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import * as AttachmentsPropTypes from '../../propTypes';
import stylePropTypes from '../../../../styles/stylePropTypes';

const attachmentViewPdfPropTypes = {
/** File object maybe be instance of File or Object */
Expand All @@ -8,12 +9,20 @@ const attachmentViewPdfPropTypes = {
encryptedSourceUrl: PropTypes.string.isRequired,
onToggleKeyboard: PropTypes.func.isRequired,
onLoadComplete: PropTypes.func.isRequired,

/** Additional style props */
style: stylePropTypes,

/** Styles for the error label */
errorLabelStyles: stylePropTypes,
};

const attachmentViewPdfDefaultProps = {
file: {
name: '',
},
style: [],
errorLabelStyles: [],
};

export {attachmentViewPdfPropTypes, attachmentViewPdfDefaultProps};
4 changes: 4 additions & 0 deletions src/components/Attachments/AttachmentView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import DistanceEReceipt from '../../DistanceEReceipt';
import useNetwork from '../../../hooks/useNetwork';
import ONYXKEYS from '../../../ONYXKEYS';
import EReceipt from '../../EReceipt';
import cursor from '../../../styles/utilities/cursor';

const propTypes = {
...attachmentViewPropTypes,
Expand Down Expand Up @@ -75,6 +76,7 @@ function AttachmentView({
isWorkspaceAvatar,
fallbackSource,
transaction,
isUsedInAttachmentModal,
}) {
const [loadComplete, setLoadComplete] = useState(false);
const [imageError, setImageError] = useState(false);
Expand Down Expand Up @@ -132,6 +134,8 @@ function AttachmentView({
onScaleChanged={onScaleChanged}
onToggleKeyboard={onToggleKeyboard}
onLoadComplete={() => !loadComplete && setLoadComplete(true)}
errorLabelStyles={isUsedInAttachmentModal ? [styles.textLabel, styles.textLarge] : [cursor.cursorAuto]}
style={isUsedInAttachmentModal ? styles.imageModalPDF : styles.flex1}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Attachments/AttachmentView/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const attachmentViewPropTypes = {

/** Handles scale changed event */
onScaleChanged: PropTypes.func,

/** Whether this AttachmentView is shown as part of an AttachmentModal */
isUsedInAttachmentModal: PropTypes.bool,
};

const attachmentViewDefaultProps = {
Expand All @@ -33,6 +36,7 @@ const attachmentViewDefaultProps = {
isUsedInCarousel: false,
onPress: undefined,
onScaleChanged: () => {},
isUsedInAttachmentModal: false,
};

export {attachmentViewPropTypes, attachmentViewDefaultProps};
4 changes: 2 additions & 2 deletions src/components/PDFView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import PDFPasswordForm from './PDFPasswordForm';
import * as pdfViewPropTypes from './pdfViewPropTypes';
import withWindowDimensions from '../withWindowDimensions';
import withLocalize from '../withLocalize';
import Text from '../Text';
import compose from '../../libs/compose';
import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback';
import Log from '../../libs/Log';
import ONYXKEYS from '../../ONYXKEYS';
import Text from '../Text';

/**
* Each page has a default border. The app should take this size into account
Expand Down Expand Up @@ -283,7 +283,7 @@ class PDFView extends Component {
}) => this.setState({containerWidth: width, containerHeight: height})}
>
<Document
error={<Text style={[styles.textLabel, styles.textLarge]}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>}
error={<Text style={this.props.errorLabelStyles}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>}
loading={<FullScreenLoadingIndicator />}
file={this.props.sourceURL}
options={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/PDFView/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class PDFView extends Component {
<View style={containerStyles}>
{this.state.failedToLoadPDF && (
<View style={[styles.flex1, styles.justifyContentCenter]}>
<Text style={[styles.textLabel, styles.textLarge]}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>
<Text style={this.props.errorLabelStyles}>{this.props.translate('attachmentView.failedToLoadPDF')}</Text>
</View>
)}
{this.state.shouldAttemptPDFLoad && (
Expand Down
4 changes: 4 additions & 0 deletions src/components/PDFView/pdfViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const propTypes = {
/** Should focus to the password input */
isFocused: PropTypes.bool,

/** Styles for the error label */
errorLabelStyles: stylePropTypes,

...windowDimensionsPropTypes,
};

Expand All @@ -39,6 +42,7 @@ const defaultProps = {
onScaleChanged: () => {},
onLoadComplete: () => {},
isFocused: false,
errorLabelStyles: [],
};

export {propTypes, defaultProps};
1 change: 0 additions & 1 deletion src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,6 @@ const styles = (theme: ThemeDefault) =>
// It's being used on Web/Desktop only to vertically center short PDFs,
// while preventing the overflow of the top of long PDF files.
...display.dGrid,
backgroundColor: theme.modalBackground,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this one here, it's only used in the touched component on desktop, and does not really add anything. This was the one causing the weird background on hover.

width: '100%',
height: '100%',
justifyContent: 'center',
Expand Down