From 0175ef47a9ffd3d734c898a51d3e6dad01db2acb Mon Sep 17 00:00:00 2001 From: Artem Kolichenkov Date: Sat, 16 May 2020 00:23:32 +0300 Subject: [PATCH] Update demo app Added debuggin page to test handlers --- demo/App.js | 2 ++ demo/DebugImage.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++ demo/HomeScreen.js | 3 ++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 demo/DebugImage.js diff --git a/demo/App.js b/demo/App.js index 0fa5acd..e063c88 100644 --- a/demo/App.js +++ b/demo/App.js @@ -4,6 +4,7 @@ import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import HomeScreen from './HomeScreen'; import BigImage from './BigImage'; +import DebugImage from './DebugImage'; const Stack = createStackNavigator(); @@ -14,6 +15,7 @@ export default class App extends React.Component { + ); diff --git a/demo/DebugImage.js b/demo/DebugImage.js new file mode 100644 index 0000000..48c549b --- /dev/null +++ b/demo/DebugImage.js @@ -0,0 +1,50 @@ +import React, { useState } from 'react'; +import { Text, View, Image, Dimensions } from 'react-native'; +import ImageZoom from './built/index'; + +const formatEventData = (evt) => { + const { locationX, locationY, pageX, pageY } = evt; + return `x ${locationX.toFixed(2)} y ${locationY.toFixed(2)} pageX ${pageX.toFixed(2)} pageY ${pageY.toFixed(2)}`; +}; + +const DebugImage = () => { + const [longPressData, setLongPressData] = useState("LongPress: Haven't long pressed yet"); + const [doubleClickData, setDoubleClickData] = useState("DoubleClick: Haven't doubleclicked yet"); + const longPressHandler = (evt) => { + const data = formatEventData(evt); + setLongPressData(`LongPress: ${data}`); + }; + const doubleClickHandler = (evt) => { + const data = formatEventData(evt); + setDoubleClickData(`DoubleClick: ${data}`); + }; + return ( + + {longPressData} + {doubleClickData} + + + + + ); +}; + +export default DebugImage; diff --git a/demo/HomeScreen.js b/demo/HomeScreen.js index e5659a8..cf323bf 100644 --- a/demo/HomeScreen.js +++ b/demo/HomeScreen.js @@ -3,7 +3,8 @@ import { Button, View, Text } from 'react-native'; const HomeScreen = ({ navigation }) => { return ( - + +