Skip to content

Commit

Permalink
fix: android gesture hoc
Browse files Browse the repository at this point in the history
  • Loading branch information
EQuimper committed Jun 7, 2023
1 parent 0f4f8bc commit e250700
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/Cropper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
Text,
LayoutChangeEvent,
} from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import {
Gesture,
GestureDetector,
gestureHandlerRootHOC,
} from 'react-native-gesture-handler';
import Animated, {
SharedValue,
useAnimatedStyle,
Expand Down Expand Up @@ -37,7 +41,7 @@ interface Props {
compress?: number;
}

export default function Cropper({
const Cropper = ({
imageSrc,
onClose,
minSize = 50,
Expand All @@ -46,7 +50,7 @@ export default function Cropper({
croppingBtnLabel,
onImageSave,
compress = 1,
}: Props) {
}: Props) => {
const { width } = useWindowDimensions();
const insets = useSafeAreaInsets();

Expand Down Expand Up @@ -588,4 +592,7 @@ export default function Cropper({
</View>
</View>
);
}
};

// @ts-ignore
export default gestureHandlerRootHOC(Cropper) as typeof Cropper;
6 changes: 3 additions & 3 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ImageResult } from 'expo-image-manipulator';

import { fakeId } from './utils';
import Cropper from './Cropper';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { View } from 'react-native';

export interface ModalRef {
present: () => void;
Expand Down Expand Up @@ -46,7 +46,7 @@ export default function Modal({

return (
<RnModal visible={visible} animationType="fade" key={id}>
<GestureHandlerRootView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<Cropper
onClose={() => {
setVisible(false);
Expand All @@ -61,7 +61,7 @@ export default function Modal({
saveBtnLabel={saveBtnLabel}
compress={compress}
/>
</GestureHandlerRootView>
</View>
</RnModal>
);
}

0 comments on commit e250700

Please sign in to comment.