Skip to content

Commit aab7dd0

Browse files
revert: undo simplification of PDFViewProps to restore type safety
1 parent cd96b5d commit aab7dd0

3 files changed

Lines changed: 9 additions & 5 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 PDFViewProps from './types';
16+
import type {PDFViewNativeProps} 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 PDFViewProps 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}: PDFViewProps) {
36+
function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused, onScaleChanged, sourceURL, onLoadError, isUsedAsChatAttachment}: PDFViewNativeProps) {
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {retrieveMaxCanvasArea, retrieveMaxCanvasHeight, retrieveMaxCanvasWidth}
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;

src/components/PDFView/types.ts

Lines changed: 6 additions & 2 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) & ((page: number, x: number, y: number) => void);
17+
onPress?: (event?: GestureResponderEvent | KeyboardEvent) => void;
1818

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

3535
type PDFViewProps = PDFViewBaseProps;
3636

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

0 commit comments

Comments
 (0)