React Native Swipe Drag Drop
1.0.0
文章链接
React Native社区尚未发布任何官方文件或来源,以实现组件上的拖放式触摸触摸手势。我在触摸手势上的某些项目中有一些经验,因此,我试图在简单的React本机应用程序上显示此功能。我希望它对您有帮助。
让我们开始安装所需的软件包。
yarn install我们需要在Android侧添加一些行。iOS不需要此步骤。添加的线条用“+”表示。路径是android/app/src/main/java/mainActivity.java
package com . gesturehandler ;
import com . facebook . react . ReactActivity ;
+ import com . facebook . react . ReactActivityDelegate ;
+ import com . facebook . react . ReactRootView ;
+ import com . swmansion . gesturehandler . react . RNGestureHandlerEnabledRootView ;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@ Override
protected String getMainComponentName ( ) {
return "gestureHandler" ;
}
+ @ Override
+ protected ReactActivityDelegate createReactActivityDelegate ( ) {
+ return new ReactActivityDelegate ( this , getMainComponentName ( ) ) {
+ @ Override
+ protected ReactRootView createRootView ( ) {
+ return new RNGestureHandlerEnabledRootView ( MainActivity . this ) ;
+ }
+ } ;
+ }
}我们的示例应用程序准备好了!
yarn run android我们可以在Android模拟器上使用上面的书面命令运行它。