React Native Swipe Drag Drop
1.0.0
기사 링크
React Native Community는 구성 요소에서 Drag-Drop-Swipe Touch 제스처를 실현하기 위해 공식 문서 나 소스를 게시하지 않았습니다. 나는 일부 프로젝트에 대한 터치 제스처 사용에 대한 경험이 있으므로 간단한 React Native Application 에이 기능을 보여 주려고 노력했습니다. 도움이되기를 바랍니다.
필요한 패키지를 설치하기 시작하겠습니다.
yarn install안드로이드쪽에 추가해야 할 몇 줄이 있습니다.이 단계는 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안드로이드 에뮬레이터에서 위의 서면 명령으로 실행할 수 있습니다.