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模擬器上使用上面的書面命令運行它。