Skip to content

Commit

Permalink
prettier diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
ishpaul777 committed Mar 15, 2024
1 parent 3ace4d3 commit 830a392
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/components/PDFView/index.native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { View } from 'react-native';
import React, {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';
import PDF from 'react-native-pdf';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
Expand All @@ -11,7 +11,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import CONST from '@src/CONST';
import PDFPasswordForm from './PDFPasswordForm';
import { defaultProps, propTypes as pdfViewPropTypes } from './pdfViewPropTypes';
import {defaultProps, propTypes as pdfViewPropTypes} from './pdfViewPropTypes';

const propTypes = {
...pdfViewPropTypes,
Expand All @@ -35,18 +35,18 @@ const propTypes = {
const LOADING_THUMBNAIL_HEIGHT = 250;
const LOADING_THUMBNAIL_WIDTH = 250;

function PDFView({ onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused, onScaleChanged, sourceURL, onError, isUsedAsChatAttachment }) {
function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused, onScaleChanged, sourceURL, onError, isUsedAsChatAttachment}) {
const [shouldRequestPassword, setShouldRequestPassword] = useState(false);
const [shouldAttemptPDFLoad, setShouldAttemptPDFLoad] = useState(true);
const [shouldShowLoadingIndicator, setShouldShowLoadingIndicator] = useState(true);
const [isPasswordInvalid, setIsPasswordInvalid] = useState(false);
const [failedToLoadPDF, setFailedToLoadPDF] = useState(false);
const [successToLoadPDF, setSuccessToLoadPDF] = useState(false);
const [password, setPassword] = useState('');
const { windowWidth, windowHeight, isSmallScreenWidth } = useWindowDimensions();
const { translate } = useLocalize();
const {windowWidth, windowHeight, isSmallScreenWidth} = useWindowDimensions();
const {translate} = useLocalize();
const themeStyles = useThemeStyles();
const { isKeyboardShown } = useKeyboardState();
const {isKeyboardShown} = useKeyboardState();
const StyleUtils = useStyleUtils();

useEffect(() => {
Expand Down Expand Up @@ -131,7 +131,9 @@ function PDFView({ onToggleKeyboard, onLoadComplete, fileName, onPress, isFocuse
}
const containerStyles =
isUsedAsChatAttachment || (shouldRequestPassword && isSmallScreenWidth) ? [themeStyles.w100, themeStyles.flex1] : [themeStyles.alignItemsCenter, themeStyles.flex1];
const loadingIndicatorStyles = isUsedAsChatAttachment ? [themeStyles.chatItemPDFAttachmentLoading, StyleUtils.getWidthAndHeightStyle(LOADING_THUMBNAIL_WIDTH, LOADING_THUMBNAIL_HEIGHT)] : [];
const loadingIndicatorStyles = isUsedAsChatAttachment
? [themeStyles.chatItemPDFAttachmentLoading, StyleUtils.getWidthAndHeightStyle(LOADING_THUMBNAIL_WIDTH, LOADING_THUMBNAIL_HEIGHT)]
: [];

return (
<View style={containerStyles}>
Expand All @@ -140,7 +142,7 @@ function PDFView({ onToggleKeyboard, onLoadComplete, fileName, onPress, isFocuse
fitPolicy={0}
trustAllCerts={false}
renderActivityIndicator={() => <FullScreenLoadingIndicator style={loadingIndicatorStyles} />}
source={{ uri: sourceURL, cache: true, expiration: 864000 }}
source={{uri: sourceURL, cache: true, expiration: 864000}}
style={pdfStyles}
onError={handleFailureToLoadPDF}
password={password}
Expand Down

0 comments on commit 830a392

Please sign in to comment.