Skip to content

Commit f42a5e9

Browse files
refactor: simplify PDFViewProps and clean up type usage
1 parent c38965e commit f42a5e9

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/components/PDFView/index.native.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1313
import useWindowDimensions from '@hooks/useWindowDimensions';
1414
import CONST from '@src/CONST';
1515
import PDFPasswordForm from './PDFPasswordForm';
16-
import type {PDFViewNativeProps} from './types';
16+
import type PDFViewProps from './types';
1717

1818
/**
1919
* On the native layer, we use react-native-pdf/PDF to display PDFs. If a PDF is
@@ -33,7 +33,7 @@ import type {PDFViewNativeProps} from './types';
3333
const LOADING_THUMBNAIL_HEIGHT = 250;
3434
const LOADING_THUMBNAIL_WIDTH = 250;
3535

36-
function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused, onScaleChanged, sourceURL, onLoadError, isUsedAsChatAttachment}: PDFViewNativeProps) {
36+
function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused, onScaleChanged, sourceURL, onLoadError, isUsedAsChatAttachment}: PDFViewProps) {
3737
const [shouldRequestPassword, setShouldRequestPassword] = useState(false);
3838
const [shouldAttemptPDFLoad, setShouldAttemptPDFLoad] = useState(true);
3939
const [shouldShowLoadingIndicator, setShouldShowLoadingIndicator] = useState(true);

src/components/PDFView/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {PDFPreviewer} from 'react-fast-pdf';
66
import {View} from 'react-native';
77
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
88
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
9-
import useOnyx from '@hooks/useOnyx';
109
import useLocalize from '@hooks/useLocalize';
10+
import useOnyx from '@hooks/useOnyx';
1111
import usePrevious from '@hooks/usePrevious';
1212
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1313
import useStyleUtils from '@hooks/useStyleUtils';
@@ -18,7 +18,7 @@ import * as CanvasSize from '@userActions/CanvasSize';
1818
import CONST from '@src/CONST';
1919
import ONYXKEYS from '@src/ONYXKEYS';
2020
import PDFPasswordForm from './PDFPasswordForm';
21-
import type {PDFViewProps} from './types';
21+
import type PDFViewProps from './types';
2222

2323
const LOADING_THUMBNAIL_HEIGHT = 250;
2424
const LOADING_THUMBNAIL_WIDTH = 250;
@@ -147,4 +147,3 @@ function PDFView({onToggleKeyboard, fileName, onPress, isFocused, sourceURL, sty
147147
}
148148

149149
export default memo(PDFView);
150-

src/components/PDFView/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type PDFViewBaseProps = {
1414
onToggleKeyboard?: (isKeyboardOpen: boolean) => void;
1515

1616
/** Handles press events like toggling attachment arrows natively */
17-
onPress?: (event?: GestureResponderEvent | KeyboardEvent) => void;
17+
onPress?: ((event?: GestureResponderEvent | KeyboardEvent) => void) & ((page: number, x: number, y: number) => void);
1818

1919
/** Handles scale changed event in PDF component */
2020
onScaleChanged?: (newScale: number) => void;
@@ -34,8 +34,5 @@ type PDFViewBaseProps = {
3434

3535
type PDFViewProps = PDFViewBaseProps;
3636

37-
type PDFViewNativeProps = PDFViewBaseProps & {
38-
onPress?: (page: number, x: number, y: number) => void;
39-
};
37+
export default PDFViewProps;
4038

41-
export type {PDFViewNativeProps, PDFViewProps};

0 commit comments

Comments
 (0)