Skip to content

Commit

Permalink
Merge branch 'main' into @latekvo/remove-deprecated-classes-and-funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
latekvo committed Nov 22, 2024
2 parents 1e9b8db + 3daca2d commit a9e450c
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 1,964 deletions.
8 changes: 4 additions & 4 deletions FabricExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ PODS:
- React-logger (= 0.76.0)
- React-perflogger (= 0.76.0)
- React-utils (= 0.76.0)
- RNGestureHandler (2.21.1):
- RNGestureHandler (2.21.2):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1743,7 +1743,7 @@ SPEC CHECKSUMS:
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 9de51d2f67336348a6cd5b686330e436d1dbd522
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCT-Folly: 84578c8756030547307e4572ab1947de1685c599
RCTDeprecation: 4c2c4a088b6f0ccfcbd53c9d5614b0238ad57909
RCTRequired: 2d8a683a7848bc0baf5883f0792c1ac43f6267b5
RCTTypeSafety: 23df4344c69c602e1c5a8053a93c633af1bee825
Expand Down Expand Up @@ -1799,9 +1799,9 @@ SPEC CHECKSUMS:
React-utils: e74516d5b9483c5530ec61e249e28b88729321d2
ReactCodegen: ff7512e124e3dc1363a4930a209d033354d2042a
ReactCommon: cde69a75746e8d7131f61c27155ee9dc42117003
RNGestureHandler: 39ce07f10bbd98e5810ee79780ed3d6c02fafeb2
RNGestureHandler: a1d7f6a6b72f4f57127df353cbe06955b6354fd7
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: f8ec45ce98bba1bc93dd28f2ee37215180e6d2b6
Yoga: 1d66db49f38fd9e576a1d7c3b081e46ab4c28b9e

PODFILE CHECKSUM: 0789d64718cebced7436c418e1f61d0aa9d54889

Expand Down
2 changes: 1 addition & 1 deletion FabricExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5630,7 +5630,7 @@ prompts@^2.0.1, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down
10 changes: 7 additions & 3 deletions MacOSExample/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ GEM
base64
nkf
rexml
activesupport (7.2.1)
activesupport (7.1.5)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.15.2)
Expand Down Expand Up @@ -80,6 +83,7 @@ GEM
logger (1.6.1)
minitest (5.25.1)
molinillo (0.8.0)
mutex_m (0.2.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
Expand Down
10 changes: 5 additions & 5 deletions MacOSExample/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ PODS:
- React-utils (= 0.74.6)
- RNCAsyncStorage (1.24.0):
- React-Core
- RNGestureHandler (2.21.1):
- RNGestureHandler (2.21.2):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1443,10 +1443,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 0686b6af8cbd638c784fea5afb789be66699823c
DoubleConversion: acaf5db79676d2e9119015819153f0f99191de12
DoubleConversion: 5b92c4507c560bb62e7aa1acdf2785ea3ff08b3b
FBLazyVector: 8f41053475f558b29633b434bd62929813a38560
fmt: 03574da4b7ba40de39da59677ca66610ce8c4a02
glog: 6df0a3d6e2750a50609471fd1a01fd2948d405b5
glog: ba31c1afa7dcf1915a109861bccdb4421be6175b
hermes-engine: 2102c92e54a031a270fd1fe84169ec8a0901b7bd
RCT-Folly: 2edbb9597acadc2312235c7ad6243d49852047a3
RCTDeprecation: 5f1d7e1f8ef6c53f0207e3ac0d0ca23575e8a6ab
Expand Down Expand Up @@ -1496,11 +1496,11 @@ SPEC CHECKSUMS:
React-utils: d1f30e28b14bea6aa6b009be03ab502bbf2cf5c6
ReactCommon: 68cae4af53cf2d34e6a26c0099f434f170495dd1
RNCAsyncStorage: ec53e44dc3e75b44aa2a9f37618a49c3bc080a7a
RNGestureHandler: b7a0ffadce234020252d803904e7b32405945e27
RNGestureHandler: 280c8940cbc21ce8c189ddb4b32e2046c49f858f
RNReanimated: 45553a3ae29a75a76269595f8554d07d4090e392
RNSVG: 4590aa95758149fa27c5c83e54a6a466349a1688
SocketRocket: f6c6249082c011e6de2de60ed641ef8bbe0cfac9
Yoga: 2b5a8ace4c52fd28c52de828b9a66aede21c3a9c
Yoga: e0cc115eebe05a9f8da381a8de541b189f89f682

PODFILE CHECKSUM: 3d6bcfcb4beca113bbf03f2652ec9272037c8111

Expand Down
2 changes: 1 addition & 1 deletion MacOSExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6273,7 +6273,7 @@ prompts@^2.0.1, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def shouldUseCommonInterfaceFromReanimated() {
def json = new JsonSlurper().parseText(inputFile.text)
def reanimatedVersion = json.version as String
def (major, minor, patch) = reanimatedVersion.tokenize('.')
return (Integer.parseInt(major) == 2 && Integer.parseInt(minor) >= 3) || Integer.parseInt(major) == 3
return (Integer.parseInt(major) == 2 && Integer.parseInt(minor) >= 3) || Integer.parseInt(major) >= 3
} else {
return false
}
Expand Down
201 changes: 201 additions & 0 deletions docs/docs/components/reanimated-drawer-layout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
id: reanimated-drawer-layout
title: Reanimated Drawer Layout
sidebar_label: Reanimated Drawer Layout
---

import useBaseUrl from '@docusaurus/useBaseUrl';

Cross-platform replacement for the React Native's [DrawerLayoutAndroid](http://reactnative.dev/docs/drawerlayoutandroid.html) component.
For detailed usage of standard parameters, please refer to the [React Native docs](http://reactnative.dev/docs/drawerlayoutandroid.html).

### Usage:

To use it, import it in the following way:

```js
import ReanimatedDrawerLayout from 'react-native-gesture-handler/ReanimatedDrawerLayout';
```

## Properties:

### `drawerType`

specifies the way the drawer will be displayed.
Accepts values of the `DrawerPosition` enum. Defaults to `FRONT`.

- `FRONT` the drawer will be displayed above the content view.
- `BACK` the drawer will be displayed below the content view, revealed by sliding away the content view.
- `SLIDE` the drawer will appear attached to the content view, opening it slides both the drawer and the content view.

| `FRONT` | `BACK` | `SLIDE` |
| ----------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------- |
| <img src={useBaseUrl('gifs/new-drawer-front.gif')} /> | <img src={useBaseUrl('gifs/new-drawer-back.gif')} /> | <img src={useBaseUrl('gifs/new-drawer-slide.gif')} /> |

### `edgeWidth`

width of the invisible, draggable area on the edge of the content view, which can be dragged to open the drawer.

### `hideStatusBar`

a boolean value. When set to `true`, drawer component will use [StatusBar API](http://reactnative.dev/docs/statusbar.html) to hide the OS status bar when the drawer is dragged or idle in the `open` position.

### `statusBarAnimation`

a string with possible values: `slide`, `none` or `fade`. Defaults to `slide`.
May be used in combination with `hideStatusBar` to select the animation used for hiding the status bar.
See [StatusBar API](http://reactnative.dev/docs/statusbar.html#statusbaranimation) docs.

### `overlayColor`

color of the background overlay on top of the content window when the drawer is `open`.
This color's opacity animates from 0% to 100% as the drawer transitions from closed to open. Defaults to `rgba(0, 0, 0, 0.7)`.

### `renderNavigationView`

a renderer function for the drawer component, provided with a `progress` parameter.

- `progress` - `SharedValue` that indicates the progress of drawer opening/closing animation.
- equals `0` when the `drawer` is closed and `1` when the `drawer` is opened
- can be used by the `drawer` component to animated its children while the `drawer` is opening or closing

### `onDrawerClose`

a function which is called when the drawer has been closed.

### `onDrawerOpen`

a function which is called when the drawer has been opened.

### `onDrawerSlide`

a function which is called when drawer is moving or animating, provided with a `progress` parameter.

- `progress` - `SharedValue` that indicates the progress of drawer opening/closing animation.
- equals `0` when the `drawer` is closed and `1` when the `drawer` is opened
- can be used by the `drawer` component to animated its children while the `drawer` is opening or closing

### `onDrawerStateChanged`

a function which is called when the status of the drawer changes. It takes two arguments:

- `newState` - interaction state of the drawer. It can be one of the following:
- `DrawerState.IDLE`
- `DrawerState.DRAGGING`
- `DrawerState.SETTLING`
- `drawerWillShow` - `true` when `drawer` started animating to `open` position, `false` otherwise.

### `enableTrackpadTwoFingerGesture` (iOS only)

enables two-finger gestures on supported devices, for example iPads with trackpads.
If not enabled, the gesture will require click + drag, with `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger the gesture.

### `children`

either a component that's rendered in the content view or a function.
If `children` is a function, it is provided with a `progress` parameter.

- `progress` - `SharedValue` that indicates the progress of drawer opening/closing animation.
- equals `0` when the `drawer` is closed and `1` when the `drawer` is opened
- can be used by the `drawer` component to animated its children while the `drawer` is opening or closing

### `mouseButton(value: MouseButton)` (Web & Android only)

allows users to choose which mouse button should handler respond to.
The enum `MouseButton` consists of the following predefined fields:

- `LEFT`
- `RIGHT`
- `MIDDLE`
- `BUTTON_4`
- `BUTTON_5`
- `ALL`

Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`. Defaults to `MouseButton.LEFT`.

### `enableContextMenu(value: boolean)` (Web only)

specifies whether context menu should be enabled after clicking on underlying view with right mouse button. Defaults to `false`.

## Methods

### `openDrawer(options)`

`openDrawer` accepts an optional `options` parameter, which is an object with the following optional properties:

- `initialVelocity` - the initial velocity of the object attached to the spring. Defaults to `0`.
- `animationSpeed` - controls speed of the animation. Defaults to `1`.

### `closeDrawer(options)`

`closeDrawer` accepts an optional `options` parameter, which is an object with the following optional properties:

- `initialVelocity` - initial velocity of the object attached to the spring. Defaults to `0`.
- `animationSpeed` - controls speed of the animation. Defaults to `1`.

## Example:

See the [reanimated drawer layout example](https://github.com/software-mansion/react-native-gesture-handler/blob/main/example/src/release_tests/reanimatedDrawerLayout/index.tsx) from GestureHandler example app.

```js
import React, { useRef } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

import ReanimatedDrawerLayout, {
DrawerType,
DrawerPosition,
DrawerLayoutMethods,
} from 'react-native-gesture-handler/ReanimatedDrawerLayout';

const DrawerPage = () => {
return (
<View style={styles.drawerContainer}>
<Text>Lorem ipsum</Text>
</View>
);
};

export default function ReanimatedDrawerExample() {
const drawerRef = useRef < DrawerLayoutMethods > null;
const tapGesture = Gesture.Tap()
.runOnJS(true)
.onStart(() => drawerRef.current?.openDrawer());

return (
<ReanimatedDrawerLayout
ref={drawerRef}
renderNavigationView={() => <DrawerPage />}
drawerPosition={DrawerPosition.LEFT}
drawerType={DrawerType.FRONT}>
<View style={styles.innerContainer}>
<GestureDetector gesture={tapGesture}>
<View style={styles.box}>
<Text>Open drawer</Text>
</View>
</GestureDetector>
</View>
</ReanimatedDrawerLayout>
);
}

const styles = StyleSheet.create({
drawerContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'pink',
},
innerContainer: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center',
gap: 20,
},
box: {
padding: 20,
backgroundColor: 'pink',
},
});
```
Binary file added docs/static/gifs/new-drawer-back.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/gifs/new-drawer-front.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/gifs/new-drawer-slide.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7284,7 +7284,7 @@ prompts@^2.0.1, prompts@^2.3.2, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down
16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-gesture-handler",
"version": "2.21.1",
"version": "2.21.2",
"description": "Declarative API exposing native platform touch and gesture system to React Native",
"scripts": {
"prepare": "bob build && husky install",
Expand Down Expand Up @@ -66,44 +66,36 @@
"dependencies": {
"@egjs/hammerjs": "^2.0.17",
"hoist-non-react-statics": "^3.3.0",
"invariant": "^2.2.4",
"prop-types": "^15.7.2"
"invariant": "^2.2.4"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@babel/runtime": "^7.12.5",
"@react-native/babel-preset": "^0.74.85",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.5.1",
"@types/hammerjs": "^2.0.38",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/invariant": "^2.2.37",
"@types/jest": "^27.0.3",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"babel-jest": "^26.6.3",
"babel-plugin-module-resolver": "^5.0.2",
"clang-format": "^1.8.0",
"eslint": "^7.32.0",
"eslint-config-satya164": "^3.1.8",
"eslint-import-resolver-babel-module": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^26.0.0",
"expo": "^35.0.1",
"husky": "^8.0.1",
"jest": "^28.1.0",
"lint-staged": "^12.3.2",
"madge": "^6.1.0",
"prettier": "2.7.1",
"react": "18.2.0",
"react-dom": "^16.12.0",
"react-native": "0.74.3",
"react-native-builder-bob": "^0.17.1",
"react-native-reanimated": "^3.12.0",
"react-native-web": "^0.11.7",
"react-test-renderer": "18.2.0",
"release-it": "^13.6.5",
"typescript": "5.0.4"
Expand Down
Loading

0 comments on commit a9e450c

Please sign in to comment.