Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Gesture.Simultaneous accept variable number of arguments #1625

Merged
merged 3 commits into from
Sep 20, 2021

Conversation

j-piasecki
Copy link
Member

Description

Current implementation of nesting gestures in pairs may suggest that the ordering of the gestures in Simultaneous matters, and it is not really necessary to limit it in this way. This change allows Gesture.Simultaneous to accept multiple gestures at once.

Test plan

Updated and tested on the Example app.

@j-piasecki j-piasecki merged commit 28eb8d3 into software-mansion:new-api Sep 20, 2021
@j-piasecki j-piasecki deleted the update-simultaneous branch September 20, 2021 06:42
tomekzaw added a commit that referenced this pull request Mar 1, 2022
* Attach for device events (#1561)

Add support for sending gesture events as device events alongside direct events.

* Add Reanimated as dependency (#1573)

Temporarily add Reanimated as peer dependency to allow for testing interactions between it and the new api. This change should be reverted in the future.

* Add Gestures with InteractionBuilder (#1572)

Add classes representing all basic gestures.
Add InteractionBuilder for easy composition of gestures.
Updates old gesture handlers to share parts of config with the new gestures.

* Add GestureMonitor and hooks (#1574)

Add GestureMonitor, useGesture and useAnimatedGesture, which allows for using the new API.

* Add more examples (#1584)

Adds a few more examples:
- Imitation of a camera viewfinder with filters, pinch-to-zoom, and option to long-press the shutter button to record video
- Imitation of a calculator app with expandable side panels and scrollable history
- Simple transformations demo
- Test for overlapping elements

* Fix TS errors and handlers not attaching (#1589)

Fixed TypeScript type errors
Removed unnecessary setImmediate that caused callback to be set too late

* Fix wrong variable name (#1591)

Fix wrong variable name.

* Add conditional import of Reanimated (#1592)

Adds Reanimated as an optional dependency.

Co-authored-by: Jakub <jakub.gonet@swmansion.com>

* Rename gestures methods' to remove set (#1596)

Remove set prefix from gestures methods'.

* Remove hooks and consolidate logic in GestureMonitor (#1595)

The useGesture and useAnimatedGesture hooks have been removed. Instead of them you can pass BaseGesture or InteractionBuilder directly to gesture (or the new animatedGesture) prop of the GestureMonitor.
GestureMonitor has been refactored and inherited most of the logic from hooks.
Examples have been updated to support these changes.

* Remove InteractionBuilder and replace it with explicit interactions (#1597)

Remove InteractionBuilder because the way it was building relations between gestures was not obvious.
Add Gesture.exclusive, Gesture.simultaneous and Gesture.requireToFail methods for more explicit way of composing gestures. While this method is more verbose, it should be easily understandable.

* Rename methods and GestureMonitor (#1600)

Rename methods used for creating gestures to start with an upper case letter.
Rename GestureMonitor to GestureDetector.

* Update docs (#1604)

Adds basic docs about the new api. Parts about gestures are nearly identical to those about gesture handlers with slight naming modifications and type annotations. The docs will need to be updated when we solidify naming convention and update types.
Moves minPointers prop only to Pan and Tap gestures and gesture handlers as they are the only ones that use it.
Changes type in FlingGesture direction to be consistent with the docs.

* Rename composition methods (#1614)

Rename Gesture.Exclusive to Gesture.Race.
Rename Gesture.RequireToFail to Gesture.Exclusive.
Rename gestureInteractions.ts to gestureComposition.ts.

* Remove leftover set prefix (#1619)

Remove leftover set prefix.

* Add collapsable prop to the child of the Wrap (#1636)

Modifies the Wrap component used by the GestureDetector to find the viewTag of the view it should attach to. By adding the collapsable: false prop it makes sure that the child view of the wrap ends up in the view hierarchy.
Note that there are still problems when there is a View used just to group components (no props) inside a functional component that is a child of a GestureDetector.

* Make Gesture.Simultaneous accept variable number of arguments (#1625)

Current implementation of nesting gestures in pairs may suggest that the ordering of the gestures in Simultaneous matters, and it is not really necessary to limit it in this way. This change allows Gesture.Simultaneous to accept multiple gestures at once.

* Make external relations methods accept variable number of arguments (#1633)

Makes simultaneousWithExternalGesture and requireExternalGestureToFail accept a variable number of arguments.

* Make Gesture.Exclusive accept a variable number of arguments (#1629)

While I don't think there are many use cases where deep nesting of Gesture.Exclusive would be required, with Gesture.Simultaneous and Gesture.Race both accepting a variable number of arguments I changed Exclusive to also accept more than two for the sake of consistency.

* Add native gesture (#1628)

Adds a NativeGesture object alongside Gesture.Native() method to incorporate NativeViewGestureHandler to the new API.

* Use arrow functions in the Gesture object (#1632)

Changes the member methods of the exported Gesture object to use the arrow syntax for explicit binding of this. Because of this you no longer get eslint error when destructuring it.

* Create a BetterDrawerLayout component (#1623)

Create a new BetterDrawerLayout component built with the new API of the gesture handler and Reanimated 2. It is supposed to be an almost drop-in replacement for the previous DrawerLayout.

* Export gesture types (#1641)

Exporty types of gesture objects

* Remove leftover set prefix in ForceTouchGesture (#1645)

Remove leftover set prefix from setMinForce.

* Add Drag and Drop example with new API (#1635)

Add example showcasing drag and drop using new api and Reanimated 2.

Co-authored-by: Dawid Jagieła <dawid.jagiela@ext.chime.com>
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>

* Update examples (#1660)

Update camera example to use the Exclusive with variable number of arguments.
Update better drawer example to not crash on newer versions of Reanimated.

* Update pan gesture to use the same set of properties as PanGestureHandler (#1662)

Move all shared properties of PanGesture and PanGestureHandler to the CommonPanProperties interface. This allows PanGesture to utlize all (non-deprecated) properties available to the PanGestureHandler.
Added PanGesture config methods corresponding to the moved props.
Removed deprecated props from PanGestureHandler.

* Remove animatedGesture prop, use animated gesture automatically (#1665)

Remove animatedGesture prop from GestureDetector component and add automatic check whether the gesture callbacks are worklets. If any one of them is a worklet, gesture will be initialized the same way it would be via animatedGesture. If no callback is a worklet, then the gesture will be initialized without using Reanimated.

* Get rid of specifying optionalDependencies in package.json

The optionalDependencies option was causing reanimated to be installed in other projects as indirect dependency because optionals need to be specified at the project scope and not at the dependency scope. As a result projects using pre-released versions would end up with two versions of reanimated installed under node_modules which in turn was causing a number of different issues specifically around reanimated's ConfigHelper functionality.

* Move reanimated to devDependencies

* Add  chat_heads example with new api (#1624)

Co-authored-by: Dawid Jagieła <dawid.jagiela@ext.chime.com>
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>

* Bottom Sheet example with new API (#1637)

Co-authored-by: Dawid Jagieła <dawid.jagiela@ext.chime.com>
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>

* Setup development environment

* Rename all .m files to .mm

* Rename onBegan to onBegin (#1689)

Rename onBegan to onBegin in order to be more consistent with naming.

* Integrate with Reanimated

* Assign viewTag for RNReanimated eventHash

* Return viewTag in e.target for classic JS callbacks

* Add examples

* Animated with `USE_NATIVE_DRIVER=true` works!

* Remove BetterDrawerLayout component (#1690)

Remove BetterDrawerLayoutComponent in order not to force the users into using Reanimated and move to the Example app.

* Update types (#1736)

Changes regarding types:

Rename UnwrappedGestureHandlerEvent to GestureUpdateEvent and export it
Rename UnwrappedGestureHandlerStateChangeEvent to GestureStateChangeEvent and export it
export GestureType
change gesture refs type to React.RefObject<GestureType | undefined>
add React.RefObject<React.ComponentType | undefined> to GestureRef not to show error when adding a gesture handler

* Add touch events and manual gesture (#1737)

Add GestureTouchEvent containing data about specific touch
Add onTouchesDown, onTouchesMove, onTouchesMove, onTouchesCancelled callbacks to gestures
Add manualActivation prop to continuous gestures
Add ManualGesture
Add GestureStateManager that utilizes Reanimated to allow for synchronous control of gesture state

* Improve bouncing box example

* Improve draggable box example

* Update examples status list

* Update yarn.lock

* Use onBegin instead of onBegan

* Fix example

* Update package.json

* Update yarn.lock

* Build React Native Gesture Handler

* Bring back Gesture Handler

* Ignore old API warning

* Add ultimate example

* Update yarn.lock

* Reset color on gesture fail

* Remove old docs

* Update ultimate example

* Disable auto-workletization

* Fix useNativeDriver

* Somehow it works

* It works part 2

* Use `.toString()` method

* Improve comments

* Mark some methods as never used

* Workaround for buggy native animated module on fast refresh

* Improve comments

* Distinguish event action types on iOS

* Somehow it works on Android

* Update yarn.lock

* Add manual touches example

* Remove unused methods

* Implement `onTouchEvent` on Android

* Refactor RNGestureHandlerModule methods

* Improve naming

* Create Fabric example app

* FabricExample + RNGestureHandlerButton on iOS

* Fix Android build

* Fix GestureHandlerRootView name on Android

* Make it work on both platforms

* Add RNGestureHandlerButton on Android

* Remove button property

* Add switches

* Remove additional config steps required when running Fabric version on Android

* Fix view flattening

* Add UltimateExample

* Fix warning message

* Return when view is nil

* Improve comment in `RNGestureHandlerRootViewCls`

* Fix TypeScript and `findHostInstance_DEPRECATED` import

* Attach to the contentView of RCTViewComponentView when possible

* Add comment before extracting contentView

* Add comment about view flattening on Android

* Use React Native 0.68.0-rc.1

* Setup navigation in FabricExample

* Remove auto-wrapping with non-collapsable view, replaced with error

* Remove imports

* Improve FabricExample

* Move GestureHandlerRootView to App.tsx

* Update build.gradle

* Add ComponentsExample, fix component name

* Remove unused prop

* Fix TS types

* Restore Android

* Introduce ActionType enum in TypeScript

* Introduce ActionType in Kotlin

* Introduce ActionType on iOS

* Paper and Fabric interoperability (part 1)

* Paper and Fabric interoperability (part 2)

* Rename .mm files back to .m

* Restore old example app

* Rename .mm files back to .m

* Update package.json

* Init FabricExample

* Rename some .m files to .mm

* Send direct events for old API on Paper on iOS

* Fix events on iOS

* Android with Fabric enabled works!

* Basic Fabric & Paper on Android

* Fix Fabric

* Remove comment

* Add comment

* Fix comment

* Restore comment

* Fabric & Paper on Android 2

* Update package

* Move codegen'en files to Paper srcDirs

* Update Android.mk

* Update README.md

* Update Android.mk

* Import fireEvent conditionally

* Add MBFingerTipWindow to FabricExample

* Update Android.mk

* Minor improvements

* Use original NDK version

* Update README

* Remove react-native-codegen from library dependencies

* Update yarn.lock

* Fix typos in build.gradle

* Add using namespace react in cpp-adapter.cpp

* Add MBFingerTipWindow to FabricExample

* Update RNGestureHandlerModule.mm

* Remove `*` from imports

* Remove unnecessary files

* Import `utils.tsx` once.

* Enable `RCT_NEW_ARCH_ENABLED` by default in Podfile

* Add TODO note about `ENABLE_FABRIC` flag

* Add icons to FabricExample

* Ignore flow `js` files for codegen on CI

* Move eslintIgnore to package.json

* Update babel.config

* Use `isFabric` function instead of constant

* Add comment about codegen files in android repo

* Improve FabricExample app

* Improve comments

* Minor improvements

* Fix typo in FabricExample

* Fix web

* Update dependencies in FabricExample

* Reformat FabricExample

* Add GestureCompositionScreen

* Change screen animation

* Minor improvements in FabricExample

* Update README.md

Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>

* Add comment about getShadowNodeFromRef on web

* Add `android/src/main/jni/` to `package.json`

* Revert "Import fireEvent conditionally"

This reverts commit 1a760e4.

* Revert changes to utils

* Sort imports

* Update RNGestureHandlerComponentsRegistry.cpp

* Improve RNGestureHandler.podspec

* Change header title

* Fix gesture handler attaching too early sometimes

* Update Podfile.lock

* Update comments in methods for sending events

* Remove excluded archs

* Update .prettierrc

* Revert "Add MBFingerTipWindow to FabricExample"

This reverts commit 51514c2.

* Remove import

* Restore `R.` in place of `android.R`

* `android.R` is fine

* Fix typo in ViewFlatteningScreen.tsx

Co-authored-by: Kacper Kapuściak <39658211+kacperkapusciak@users.noreply.github.com>

* Remove unused argument in GestureCompositionScreen.tsx

Co-authored-by: Kacper Kapuściak <39658211+kacperkapusciak@users.noreply.github.com>

* Add exception

* Fix attach gesture handler delay caused by console.error

* Use `tagMessage`

* Bump FabricExample to 0.68.0-rc.2

* Remove count from view flattening demo

* Set correct library name

* Remove super invalidate call

* Use SoLoader instead of System

* Remove TODO from OnLoad.cpp

* Use `RNGestureHandlerActionType` instead of `NSNumber *`

* Fix custom events on React Native 0.63.4

* Bump react-native-screens to 3.13.0 in FabricExample

* Revert "Restore `R.` in place of `android.R`"

This reverts commit aadd131.

* Restore original Podfile in example app

* Remove console.logs

Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
Co-authored-by: Jakub Gonet <jakub.gonet@swmansion.com>
Co-authored-by: Dawid Jagieła <dawid0000@gmail.com>
Co-authored-by: Dawid Jagieła <dawid.jagiela@ext.chime.com>
Co-authored-by: Krzysztof Magiera <krzys@swmansion.com>
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Co-authored-by: Kacper Kapuściak <39658211+kacperkapusciak@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants