React Native Swipe Drag Drop
1.0.0
ลิงค์บทความ
React Native Community ยังไม่ได้เผยแพร่เอกสารหรือแหล่งที่มาอย่างเป็นทางการใด ๆ เพื่อรับรู้ท่าทางสัมผัสแบบลากเลื่อนบนส่วนประกอบ ฉันได้รับประสบการณ์เกี่ยวกับการใช้ท่าทางการสัมผัสกับส่วนประกอบบางโครงการดังนั้นฉันจึงพยายามแสดงคุณสมบัตินี้ในแอปพลิเคชัน Native Native ที่เรียบง่าย ฉันหวังว่ามันจะช่วยคุณได้
มาเริ่มติดตั้งแพ็คเกจที่ต้องการกันเถอะ
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