BenJeau / react-native-draw

SVG based data-driven React Native drawing component 🎨
https://www.npmjs.com/package/@benjeau/react-native-draw
MIT License
131 stars 41 forks source link

Move to Gesture API introduced with react-native-gesture-handler 2 #55

Closed gfringeli closed 2 years ago

gfringeli commented 2 years ago

Changes

Replaced the old gesture handling API of react-native-gesture-handler (RNGH) by the Gesutre API introduced in version 2 of RNGH. This change also required an update of the expo dependency.

Related Issues

This update implements #54 and resolves the issue mentioned therein.

closes #54

BenJeau commented 2 years ago

Thank you for the PR and the update to Expo!

Let me test it on my computer to see if the example still works, and if it does I will merge it and release a new version :)

BenJeau commented 2 years ago

It is working on iOS, but is crashing on the Android emulator:

03-22 15:39:29.087  6572  6788 E unknown:ReactNative: Exception in native call
03-22 15:39:29.087  6572  6788 E unknown:ReactNative: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Boolean
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.ReadableNativeArray.getBoolean(ReadableNativeArray.java:1)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.JavaMethodWrapper$1.extractArgument(JavaMethodWrapper.java:2)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.JavaMethodWrapper$1.extractArgument(JavaMethodWrapper.java:1)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:16)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:2)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at android.os.Handler.handleCallback(Handler.java:938)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:1)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at android.os.Looper.loopOnce(Looper.java:201)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at android.os.Looper.loop(Looper.java:288)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at abi44_0_0.com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:8)
03-22 15:39:29.087  6572  6788 E unknown:ReactNative:   at java.lang.Thread.run(Thread.java:920)

I've had similar errors on Android before and it was fixed by using Expo specific versions of dependencies. The latest commit fixes that error, although I still can seem to draw on Android for some reason and can't seem to figure out why it's not working correctly.

https://user-images.githubusercontent.com/22248828/159597180-1c7b47c4-8a8a-4af3-aa61-741bfb66adf6.mov

gfringeli commented 2 years ago

As indicated in the react-native-gesture-handler documentation it is advised to wrap the component that is using gestures in a GestureHandlerRootView component. See here. In our case, this means using GestureHandlerRootView as the top-level component of the Canvas component. With this change the example app works on Android as well.

BenJeau commented 2 years ago

Unsure why circleci is not being triggered - will merge it