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

Create ReanimatedDrawerLayout component #3146

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
339305a
setup new drawer layout package
latekvo Oct 9, 2024
61f132b
create a basic drawer example, add drawer to babel config
latekvo Oct 9, 2024
26037ca
translate animated implementation into reanimated
latekvo Oct 9, 2024
cb76ac4
rewrite drawer to be a functional component
latekvo Oct 9, 2024
12d7cd1
create a separate example out of the drawer layout example
latekvo Oct 9, 2024
f135243
fix malformed request crashes, added default values for every prop
latekvo Oct 10, 2024
ca4bb3e
fix crashes from rules of hooks violations
latekvo Oct 10, 2024
ddee862
fix types, unify enum usage
latekvo Oct 10, 2024
b989601
add new api gestures, flatten internal render function centralize pro…
latekvo Oct 10, 2024
37ef758
gesturize tap gesture, cleanup
latekvo Oct 10, 2024
c0aa3a1
expose drawer functions via ref, attach it to the inner component
latekvo Oct 10, 2024
51f3622
cleanup, eslint
latekvo Oct 14, 2024
b36191f
add proper forwardRef typing
latekvo Oct 14, 2024
4caf4a1
synchronize JS and UI threads
latekvo Oct 14, 2024
117dc80
Merge branch 'main' into @latekvo/reanimate-drawer-component
latekvo Oct 14, 2024
df3f1d1
use animated styles for styles using shared values
latekvo Oct 15, 2024
b78b830
simplify expressions, rename temporary variables
latekvo Oct 15, 2024
93c1fd6
feat: animation is smooth | convert all interpolated dependencies of …
latekvo Oct 15, 2024
579f0f1
clean, remove and resolve legacy comments
latekvo Oct 16, 2024
3d2758b
replace ref based prop system with reanimated one, move multiple func…
latekvo Oct 16, 2024
d17e412
fix spring config to remove bouncing, fix dynamic animated props
latekvo Oct 16, 2024
b8d1819
minor update optimization, more comments
latekvo Oct 16, 2024
19c3ef7
memoize all functions and gestures, cleanup
latekvo Oct 16, 2024
fd96a74
Fix new hitslop state crashing when closing drawer
latekvo Oct 16, 2024
fc6d368
fix ocassional translation overextension and stutters
latekvo Oct 16, 2024
4be9b66
fix ocassional jumping to the open position before animating
latekvo Oct 16, 2024
675c96e
fix opacity jumping, memoize overlay component
latekvo Oct 16, 2024
ae144e6
remove legacy events
latekvo Oct 16, 2024
baff276
fix drawer crashes due to low rea version - bumped to latest
latekvo Oct 16, 2024
23afa87
fix rea crashes when some props are present
latekvo Oct 16, 2024
5715c3f
improve spring config
latekvo Oct 18, 2024
b7cd612
fix anti-rubberband mechanism
latekvo Oct 18, 2024
13193cd
consolidate drawer translation variables into a single variable, fixi…
latekvo Oct 18, 2024
e21972b
memoize, resolve multiple todos
latekvo Oct 18, 2024
7b93d67
add more comments, resolve others
latekvo Oct 21, 2024
4402e50
cleanup unused SV, fixes
latekvo Oct 21, 2024
531b184
workletize handleRelease, simplify hitslop init
latekvo Oct 21, 2024
bf01739
add ability to freely move drawer while it's open
latekvo Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MacOSExample/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module.exports = {
'react-native-reanimated': './node_modules/react-native-reanimated',
'react-native-gesture-handler/ReanimatedSwipeable':
'../src/components/ReanimatedSwipeable',
'react-native-gesture-handler/ReanimatedDrawerLayout':
'../src/components/ReanimatedDrawerLayout',
'react-native-gesture-handler/Swipeable':
'../src/components/Swipeable',
'react-native-gesture-handler': '../src/index',
Expand Down
6 changes: 6 additions & 0 deletions ReanimatedDrawerLayout/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"main": "../lib/commonjs/components/ReanimatedDrawerLayout",
"module": "../lib/module/components/ReanimatedDrawerLayout",
"react-native": "../src/components/ReanimatedDrawerLayout",
"types": "../lib/typescript/components/ReanimatedDrawerLayout.d.ts"
}
2 changes: 2 additions & 0 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import Fling from './src/basic/fling';
import WebStylesResetExample from './src/release_tests/webStylesReset';
import StylusData from './src/release_tests/StylusData';
import ReanimatedDrawerLayout from './src/release_tests/reanimatedDrawerLayout';

import Camera from './src/new_api/camera';
import Transformations from './src/new_api/transformations';
Expand Down Expand Up @@ -200,6 +201,7 @@
unsupportedPlatforms: new Set(['android', 'ios', 'macos']),
},
{ name: 'PointerType', component: PointerType },
{ name: 'Reanimated Drawer Layout', component: ReanimatedDrawerLayout },
{ name: 'Swipeable Reanimation', component: SwipeableReanimation },
{ name: 'RectButton (borders)', component: RectButtonBorders },
{ name: 'Gesturized pressable', component: GesturizedPressable },
Expand Down Expand Up @@ -313,7 +315,7 @@
renderSectionHeader={({ section: { sectionTitle } }) => (
<Text style={styles.sectionTitle}>{sectionTitle}</Text>
)}
ItemSeparatorComponent={() => <View style={styles.separator} />}

Check warning on line 318 in example/App.tsx

View workflow job for this annotation

GitHub Actions / check (example)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “MainScreen” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true
/>
</SafeAreaView>
);
Expand Down
2 changes: 2 additions & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = function (api) {
alias: {
'react-native-gesture-handler/ReanimatedSwipeable':
'../src/components/ReanimatedSwipeable',
'react-native-gesture-handler/ReanimatedDrawerLayout':
'../src/components/ReanimatedDrawerLayout',
'react-native-gesture-handler': '../src/index',
},
},
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react-dom": "18.2.0",
"react-native": "0.74.1",
"react-native-gesture-handler": "link:..",
"react-native-reanimated": "3.10.0",
"react-native-reanimated": "3.15.5",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
Expand Down
45 changes: 45 additions & 0 deletions example/src/release_tests/reanimatedDrawerLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useRef } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import ReanimatedDrawerLayout from 'react-native-gesture-handler/ReanimatedDrawerLayout';
import { SharedValue } from 'react-native-reanimated';

const DrawerPage = ({ progress }: { progress?: SharedValue }) => {
progress && console.log('Drawer opening progress:', progress);
return <View style={styles.drawerContainer} />;
};

export default function ReanimatedDrawerExample() {
const drawerRef = useRef<any>(null);

const tapGesture = Gesture.Tap()
.runOnJS(true)
.onStart(() => drawerRef.current?.openDrawer());

return (
<ReanimatedDrawerLayout
ref={drawerRef}
renderNavigationView={() => <DrawerPage />}>
<GestureDetector gesture={tapGesture}>
<View style={styles.innerContainer}>
<Text>Open drawer</Text>
</View>
</GestureDetector>
</ReanimatedDrawerLayout>
);
}

const styles = StyleSheet.create({
drawerContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'pink',
},
innerContainer: {
margin: 'auto',
padding: 35,
paddingHorizontal: 25,
backgroundColor: 'pink',
},
});
281 changes: 277 additions & 4 deletions example/yarn.lock

Large diffs are not rendered by default.

Loading
Loading