xmflsct 2022-10-31 00:31:31 +01:00
parent eb5940b85d
commit da1ea314a4
2 changed files with 126 additions and 64 deletions

View File

@ -0,0 +1,68 @@
diff --git a/node_modules/react-native-reanimated-zoom/lib/typescript/zoom.d.ts b/node_modules/react-native-reanimated-zoom/lib/typescript/zoom.d.ts
index 9b3e4a3..558944d 100644
--- a/node_modules/react-native-reanimated-zoom/lib/typescript/zoom.d.ts
+++ b/node_modules/react-native-reanimated-zoom/lib/typescript/zoom.d.ts
@@ -4,6 +4,7 @@ declare type Props = {
children: React.ReactNode;
minimumZoomScale?: number;
maximumZoomScale?: number;
+ simultaneousGesture?: GestureType;
} & ViewProps;
export declare function Zoom(props: Props): JSX.Element;
export {};
diff --git a/node_modules/react-native-reanimated-zoom/src/zoom.tsx b/node_modules/react-native-reanimated-zoom/src/zoom.tsx
index 2c48163..bc2d3dd 100644
--- a/node_modules/react-native-reanimated-zoom/src/zoom.tsx
+++ b/node_modules/react-native-reanimated-zoom/src/zoom.tsx
@@ -8,13 +8,18 @@ import Animated, {
cancelAnimation,
runOnJS,
} from 'react-native-reanimated';
-import { Gesture, GestureDetector } from 'react-native-gesture-handler';
+import {
+ Gesture,
+ GestureDetector,
+ GestureType,
+} from 'react-native-gesture-handler';
import { ZoomListContext } from './zoom-list-context';
type Props = {
children: React.ReactNode;
minimumZoomScale?: number;
maximumZoomScale?: number;
+ simultaneousGesture?: GestureType;
} & ViewProps;
export function Zoom(props: Props) {
@@ -23,6 +28,7 @@ export function Zoom(props: Props) {
maximumZoomScale = 8,
style: propStyle,
onLayout,
+ simultaneousGesture,
} = props;
const zoomListContext = useContext(ZoomListContext);
@@ -198,11 +204,21 @@ export function Zoom(props: Props) {
);
}
- return Gesture.Race(doubleTap, Gesture.Simultaneous(pan, pinch));
+ return Gesture.Race(
+ doubleTap,
+ simultaneousGesture
+ ? Gesture.Simultaneous(pan, pinch, simultaneousGesture)
+ : Gesture.Simultaneous(pan, pinch)
+ );
// only add prop dependencies
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [maximumZoomScale, minimumZoomScale, zoomListContext]);
+ }, [
+ maximumZoomScale,
+ minimumZoomScale,
+ zoomListContext,
+ simultaneousGesture,
+ ]);
useDerivedValue(() => {
if (scale.value > 1 && !isZoomed.value) {

View File

@ -17,12 +17,9 @@ import {
ViewToken ViewToken
} from 'react-native' } from 'react-native'
import FlashMessage from 'react-native-flash-message' import FlashMessage from 'react-native-flash-message'
import { import { Directions, Gesture, LongPressGestureHandler } from 'react-native-gesture-handler'
Directions,
FlingGestureHandler,
LongPressGestureHandler
} from 'react-native-gesture-handler'
import { LiveTextImageView } from 'react-native-live-text-image-view' import { LiveTextImageView } from 'react-native-live-text-image-view'
import { runOnJS } from 'react-native-reanimated'
import { Zoom, createZoomListComponent } from 'react-native-reanimated-zoom' import { Zoom, createZoomListComponent } from 'react-native-reanimated-zoom'
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context' import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
import saveImage from './ImageViewer/save' import saveImage from './ImageViewer/save'
@ -106,6 +103,9 @@ const ScreenImagesViewer = ({
return ( return (
<Zoom <Zoom
maximumZoomScale={max > 8 ? 8 : max} maximumZoomScale={max > 8 ? 8 : max}
simultaneousGesture={Gesture.Fling()
.direction(Directions.DOWN)
.onStart(() => runOnJS(navigation.goBack)())}
children={ children={
<View <View
style={{ style={{
@ -172,67 +172,61 @@ const ScreenImagesViewer = ({
onPress={onPress} onPress={onPress}
/> />
</View> </View>
<FlingGestureHandler <LongPressGestureHandler
direction={Directions.DOWN} onEnded={() => {
numberOfPointers={1} analytics('imageviewer_more_press')
onEnded={() => navigation.goBack()} showActionSheetWithOptions(
> {
<LongPressGestureHandler options: [
onEnded={() => { t('content.options.save'),
analytics('imageviewer_more_press') t('content.options.share'),
showActionSheetWithOptions( t('content.options.cancel')
{ ],
options: [ cancelButtonIndex: 2,
t('content.options.save'), userInterfaceStyle: mode
t('content.options.share'), },
t('content.options.cancel') async buttonIndex => {
], switch (buttonIndex) {
cancelButtonIndex: 2, case 0:
userInterfaceStyle: mode analytics('imageviewer_more_save_press')
}, saveImage({ theme, image: imageUrls[currentIndex] })
async buttonIndex => { break
switch (buttonIndex) { case 1:
case 0: analytics('imageviewer_more_share_press')
analytics('imageviewer_more_save_press') switch (Platform.OS) {
saveImage({ theme, image: imageUrls[currentIndex] }) case 'ios':
break await Share.share({ url: imageUrls[currentIndex].url })
case 1: break
analytics('imageviewer_more_share_press') case 'android':
switch (Platform.OS) { await Share.share({
case 'ios': message: imageUrls[currentIndex].url
await Share.share({ url: imageUrls[currentIndex].url }) })
break break
case 'android': }
await Share.share({ break
message: imageUrls[currentIndex].url
})
break
}
break
}
} }
) }
)
}}
>
<ZoomFlatList
data={imageUrls}
pagingEnabled
horizontal
keyExtractor={item => item.id}
renderItem={renderItem}
onViewableItemsChanged={onViewableItemsChanged}
viewabilityConfig={{
itemVisiblePercentThreshold: 50
}} }}
> initialScrollIndex={initialIndex}
<ZoomFlatList getItemLayout={(_, index) => ({
data={imageUrls} length: SCREEN_WIDTH,
pagingEnabled offset: SCREEN_WIDTH * index,
horizontal index
keyExtractor={item => item.id} })}
renderItem={renderItem} />
onViewableItemsChanged={onViewableItemsChanged} </LongPressGestureHandler>
viewabilityConfig={{
itemVisiblePercentThreshold: 50
}}
initialScrollIndex={initialIndex}
getItemLayout={(_, index) => ({
length: SCREEN_WIDTH,
offset: SCREEN_WIDTH * index,
index
})}
/>
</LongPressGestureHandler>
</FlingGestureHandler>
</SafeAreaProvider> </SafeAreaProvider>
) )
} }