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

feat: add screen "go back" transition animations based on gestures using Reanimated #1913

Merged
merged 82 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a6b4d8d
feat: first look at adding full screen swipe
WoLewicki Oct 5, 2023
ed2c270
feat: add reanimated
WoLewicki Oct 6, 2023
2df7cbb
Add reanimated
piaskowyk Oct 9, 2023
e8c650c
fix: android attaching screen below
WoLewicki Oct 9, 2023
ac59bcc
Gestures boundaries
piaskowyk Oct 10, 2023
8040066
Many things
piaskowyk Oct 18, 2023
65841a2
Clean up part 1
piaskowyk Oct 19, 2023
67cf2df
Lint
piaskowyk Oct 19, 2023
2d91bdd
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Oct 19, 2023
64b9881
Restore package json
piaskowyk Oct 19, 2023
dd298fd
Update dependencies
piaskowyk Oct 19, 2023
c05bc9c
Add too many
piaskowyk Oct 19, 2023
8bbc98f
Run native methods on UI
piaskowyk Oct 20, 2023
a59f98a
Update package.json
piaskowyk Oct 20, 2023
0950115
Screen removal callback
piaskowyk Oct 23, 2023
189bf77
Screen without callback
piaskowyk Oct 24, 2023
a88f3d3
Run Android on UI
piaskowyk Oct 25, 2023
0b658d7
Update gesture detector
piaskowyk Oct 26, 2023
14289cc
Update reaniamted version
piaskowyk Oct 26, 2023
f4c921f
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Nov 2, 2023
8c8cf79
Use animated as a package
piaskowyk Nov 2, 2023
e0fa909
Update types
piaskowyk Nov 2, 2023
a1d668d
Update types v2
piaskowyk Nov 2, 2023
6e12838
Remove console log
piaskowyk Nov 2, 2023
6bf54d1
Run only on UI
piaskowyk Nov 2, 2023
ca98f4d
Change reanimated version
piaskowyk Nov 2, 2023
3377f49
Change reanimated version
piaskowyk Nov 2, 2023
0cbae55
Use context
piaskowyk Nov 3, 2023
07b7348
Fix fabric build
piaskowyk Nov 3, 2023
66ca0f2
Update example app
piaskowyk Nov 3, 2023
5d3a9a2
Clear dependency
piaskowyk Nov 3, 2023
cf10aff
Insert gesture handler to package
piaskowyk Nov 6, 2023
d7f66d5
Module for web
piaskowyk Nov 6, 2023
bb64b41
Add useCommonInterfaceFromReanimated
piaskowyk Nov 6, 2023
93b2fe4
Update types
piaskowyk Nov 6, 2023
3524552
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Nov 10, 2023
d0eee6d
Add twoDimensional gesture
piaskowyk Nov 13, 2023
5cfa097
Update dependencies
piaskowyk Nov 13, 2023
53a93f5
Clean up
piaskowyk Nov 14, 2023
98f51b6
Update type
piaskowyk Nov 14, 2023
4f49202
Lint
piaskowyk Nov 14, 2023
9339529
Fix Gesture Provider types
piaskowyk Nov 14, 2023
d688ee1
update reaniamted
piaskowyk Nov 14, 2023
6c474b8
Remove 'true' assertion
piaskowyk Nov 14, 2023
69ff763
feat: not working Android turbomodule
WoLewicki Dec 4, 2023
3b61aef
Merge with main
piaskowyk Dec 5, 2023
52b11c0
Merge branch '@wolewicki/add-full-screen-swipe' of github.com:softwar…
piaskowyk Dec 5, 2023
843ad14
fix: change to get from getEnforcing for turbomodule
WoLewicki Dec 5, 2023
00b81f8
Improvements after Tymek's review
piaskowyk Dec 5, 2023
fa10b21
chore: bump FabricExample to rn73
WoLewicki Dec 5, 2023
c6e55f3
Improvements after review part 2
piaskowyk Dec 5, 2023
abcde68
It doesn't work yet - keep calm
piaskowyk Dec 8, 2023
d815500
Move Turbo module to common implementation
piaskowyk Dec 11, 2023
2ab5b84
Clean up
piaskowyk Dec 12, 2023
ad3722d
Clean up v2
piaskowyk Dec 12, 2023
edd22d9
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Dec 12, 2023
a7f8864
Format
piaskowyk Dec 12, 2023
01a1763
Cleanup iOS
piaskowyk Dec 12, 2023
3acd198
Configure FabricTestExample
piaskowyk Dec 12, 2023
524a461
restore fabric example
piaskowyk Dec 12, 2023
cf37301
Finish review improvements
piaskowyk Dec 13, 2023
b7e1418
Update types
piaskowyk Dec 13, 2023
fe66b63
Update package.json
piaskowyk Dec 13, 2023
3223172
Update package.json v2
piaskowyk Dec 13, 2023
9fd1043
Update package.json v3
piaskowyk Dec 13, 2023
d35b76f
Use nightly of reaniamted
piaskowyk Dec 13, 2023
13eddee
Fix for TVOS
piaskowyk Dec 14, 2023
a7c3eb3
Fix for TVOS v2
piaskowyk Dec 14, 2023
8be5bf9
Improvements after review part another one
piaskowyk Dec 22, 2023
3084044
Invert vertical finish conditions
piaskowyk Dec 22, 2023
9ec3fe7
Disable swipe back for iOS
piaskowyk Dec 27, 2023
5768477
Refactor Android v1
piaskowyk Dec 27, 2023
c86e551
Fix hot reload
piaskowyk Dec 27, 2023
47d7e40
Review improvements
piaskowyk Dec 27, 2023
b51aa90
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Dec 27, 2023
be598ff
Update package.lock
piaskowyk Dec 27, 2023
a420717
Name parameter
piaskowyk Dec 27, 2023
d014fa8
Refactor
piaskowyk Dec 28, 2023
fb025e5
Restore identation
piaskowyk Dec 28, 2023
ca5267c
Merge branch 'main' into @wolewicki/add-full-screen-swipe
piaskowyk Jan 9, 2024
f4a74d5
Update names after merge
piaskowyk Jan 9, 2024
276f02f
Update reanimated version
piaskowyk Jan 9, 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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'react-native-screens',
'react-native-screens/native-stack',
'react-native-screens/reanimated',
'react-native-screens/gesture-handler',
],
'import/ignore': [
'node_modules/react-native/index\\.js$',
Expand Down
52 changes: 32 additions & 20 deletions Example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import RNRestart from 'react-native-restart';
import { ListItem, SettingsSwitch } from './src/shared';

import SimpleNativeStack from './src/screens/SimpleNativeStack';
import SwipeBackAnimation from './src/screens/SwipeBackAnimation';
import StackPresentation from './src/screens/StackPresentation';
import HeaderOptions from './src/screens/HeaderOptions';
import StatusBarExample from './src/screens/StatusBar';
Expand All @@ -27,6 +28,8 @@ import Events from './src/screens/Events';
import Gestures from './src/screens/Gestures';

import { enableFreeze } from 'react-native-screens';
import { GestureDetectorProvider } from 'react-native-screens/gesture-handler';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

enableFreeze();

Expand All @@ -47,6 +50,11 @@ const SCREENS: Record<
component: SimpleNativeStack,
type: 'example',
},
SwipeBackAnimation: {
title: 'Swipe Back Animation',
component: SwipeBackAnimation,
type: 'example',
},
StackPresentation: {
title: 'Stack Presentation',
component: StackPresentation,
Expand Down Expand Up @@ -150,26 +158,30 @@ const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => (
);

const ExampleApp = (): JSX.Element => (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
<Stack.Screen
name="Main"
options={{ title: '📱 React Native Screens Examples' }}
component={MainScreen}
/>
{Object.keys(SCREENS).map(name => (
<Stack.Screen
key={name}
name={name}
getComponent={() => SCREENS[name].component}
options={{ headerShown: false }}
/>
))}
</Stack.Navigator>
</NavigationContainer>
<GestureHandlerRootView style={{ flex: 1 }}>
<GestureDetectorProvider>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
}}>
<Stack.Screen
name="Main"
options={{ title: '📱 React Native Screens Examples' }}
component={MainScreen}
/>
{Object.keys(SCREENS).map(name => (
<Stack.Screen
key={name}
name={name}
getComponent={() => SCREENS[name].component}
options={{ headerShown: false }}
/>
))}
</Stack.Navigator>
</NavigationContainer>
</GestureDetectorProvider>
</GestureHandlerRootView>
);

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion Example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [],
plugins: ['react-native-reanimated/plugin'],
};
22 changes: 15 additions & 7 deletions Example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,12 @@ PODS:
- React-jsi (= 0.72.4)
- React-logger (= 0.72.4)
- React-perflogger (= 0.72.4)
- RNGestureHandler (2.12.1):
- RNGestureHandler (2.13.1):
- React-Core
- RNReanimated (3.7.0-nightly-20240109-9e2c33716):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- ReactCommon/turbomodule/core
- RNScreens (3.29.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
Expand Down Expand Up @@ -567,6 +571,7 @@ DEPENDENCIES:
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
Expand Down Expand Up @@ -672,6 +677,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNReanimated:
:path: "../node_modules/react-native-reanimated"
RNScreens:
:path: "../node_modules/react-native-screens"
RNVectorIcons:
Expand All @@ -680,9 +687,9 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
boost: a7c83b31436843459a1961bfd74b96033dc77234
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: 5d4a3b7f411219a45a6d952f77d2c0a6c9989da5
FBReactNativeSpec: 3fc2d478e1c4b08276f9dd9128f80ec6d5d85c1f
Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818
Expand All @@ -694,7 +701,7 @@ SPEC CHECKSUMS:
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
glog: 5337263514dd6f09803962437687240c5dc39aa4
hermes-engine: 81191603c4eaa01f5e4ae5737a9efcf64756c7b2
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Expand Down Expand Up @@ -732,13 +739,14 @@ SPEC CHECKSUMS:
React-runtimescheduler: 4941cc1b3cf08b792fbf666342c9fc95f1969035
React-utils: b79f2411931f9d3ea5781404dcbb2fa8a837e13a
ReactCommon: 4b2bdcb50a3543e1c2b2849ad44533686610826d
RNGestureHandler: c0d04458598fcb26052494ae23dda8f8f5162b13
RNScreens: 3c5b9f4a9dcde752466854b6109b79c0e205dad3
RNGestureHandler: 38aa38413896620338948fbb5c90579a7b1c3fde
RNReanimated: 0f8173d46f45c2f690c416dff10206832631571d
RNScreens: 975abd21a20b6ebd26563e5ab86b30250569c182
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 3efc43e0d48686ce2e8c60f99d4e6bd349aff981
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 86e380a4262db238c7a45428750af2d88465585c

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
2 changes: 2 additions & 0 deletions Example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const root = path.resolve(__dirname, '..');
const modules = [
'@react-navigation/native',
'react-native-safe-area-context',
'react-native-gesture-handler',
'react-native-reanimated',
...Object.keys(pack.peerDependencies),
];

Expand Down
5 changes: 3 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"nanoid": "^4.0.2",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-gesture-handler": "^2.12.1",
"react-native-gesture-handler": "^2.13.1",
"react-native-reanimated": "3.7.0-nightly-20240109-9e2c33716",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "^4.8.1",
"react-native-screens": "link:../",
Expand All @@ -36,9 +37,9 @@
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/jest": "^29.2.5",
"@types/react": "^18.0.24",
"@types/react-native": "0.72.2",
"@types/jest": "^29.2.5",
"@types/react-native-restart": "^0.0.0",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.3.1",
Expand Down
74 changes: 74 additions & 0 deletions Example/src/screens/SwipeBackAnimation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import { View, StyleSheet, I18nManager } from 'react-native';
import {
createNativeStackNavigator,
NativeStackNavigationProp,
} from 'react-native-screens/native-stack';
import { Button } from '../shared';

type StackParamList = {
ScreenA: undefined;
ScreenB: undefined;
ScreenC: undefined;
};

interface MainScreenProps {
navigation: NativeStackNavigationProp<StackParamList, 'ScreenA'>;
}

const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => (
<View style={{ ...styles.container, backgroundColor: 'moccasin' }}>
<Button title="Go ScreenB" onPress={() => navigation.navigate('ScreenB')} />
<Button onPress={() => navigation.pop()} title="🔙 Back to Examples" />
</View>
);

interface ScreenBProps {
navigation: NativeStackNavigationProp<StackParamList, 'ScreenB'>;
}

const ScreenB = ({ navigation }: ScreenBProps): JSX.Element => (
<View style={{ ...styles.container, backgroundColor: 'thistle' }}>
<Button title="Go ScreenC" onPress={() => navigation.navigate('ScreenC')} />
<Button title="Go back" onPress={() => navigation.goBack()} />
</View>
);

interface ScreenCProps {
navigation: NativeStackNavigationProp<StackParamList, 'ScreenC'>;
}

const ScreenC = ({ navigation }: ScreenCProps): JSX.Element => (
<View style={{ ...styles.container, backgroundColor: 'blue' }}>
<Button title="Go back" onPress={() => navigation.goBack()} />
</View>
);

const Stack = createNativeStackNavigator<StackParamList>();

const App = (): JSX.Element => (
<Stack.Navigator
screenOptions={{
headerHideBackButton: true,
stackAnimation: 'none',
}}>
<Stack.Screen name="ScreenA" component={MainScreen} />
<Stack.Screen
name="ScreenB"
component={ScreenB}
options={{
goBackGesture: 'twoDimensionalSwipe',
}}
/>
<Stack.Screen name="ScreenC" component={ScreenC} />
</Stack.Navigator>
);

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 10,
},
});

export default App;
Loading
Loading