Skip to content

Commit

Permalink
Merge branch 'main' into @kkafar/native-native-animtions-for-ios-nati…
Browse files Browse the repository at this point in the history
…ve-native
  • Loading branch information
kkafar committed Nov 6, 2024
2 parents 23300c6 + 46c843e commit 0e13917
Show file tree
Hide file tree
Showing 28 changed files with 524 additions and 227 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ Screens are already integrated with the React Native's most popular navigation l

## Supported react-native version

### Support for Paper

Paper is the default rendering system for React Native versions prior to 0.76.

| library version | react-native version |
| --------------- | -------------------- |
| 3.33.0+ | 0.72.0+
| 3.33.0+ | 0.72.0+ |
| 3.32.0+ | 0.71.0+ |
| 3.30.0+ | 0.68.0+ |
| 3.14.0+ | 0.64.0+ |
Expand All @@ -123,6 +127,7 @@ Here's a table with summary of supported `react-native` versions when Fabric is

| library version | react-native version |
| --------------- | -------------------- |
| 3.35.0+ | 0.76.0+ |
| 3.33.0+ | 0.75.0+ |
| 3.32.0+ | 0.74.0+ |
| 3.28.0+ | 0.73.0+ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void setProperty(T view, String propName, @Nullable Object value) {
mViewManager.setFullScreenSwipeEnabled(view, value == null ? false : (boolean) value);
break;
case "fullScreenSwipeShadowEnabled":
mViewManager.setFullScreenSwipeShadowEnabled(view, value == null ? false : (boolean) value);
mViewManager.setFullScreenSwipeShadowEnabled(view, value == null ? true : (boolean) value);
break;
case "homeIndicatorHidden":
mViewManager.setHomeIndicatorHidden(view, value == null ? false : (boolean) value);
Expand Down
43 changes: 32 additions & 11 deletions apps/src/screens/SwipeBackAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from 'react';
import { View, StyleSheet } from 'react-native';
import {
createNativeStackNavigator,
NativeStackNavigationOptions,
NativeStackNavigationProp,
} from '@react-navigation/native-stack';
import { Button } from '../shared';
import { Button, SettingsPicker } from '../shared';

type StackParamList = {
ScreenA: undefined;
Expand All @@ -27,12 +28,36 @@ interface ScreenBProps {
navigation: NativeStackNavigationProp<StackParamList, 'ScreenB'>;
}

const ScreenB = ({ navigation }: ScreenBProps): React.JSX.Element => (
<View style={{ ...styles.container, backgroundColor: 'thistle' }}>
<Button title="Go ScreenC" onPress={() => navigation.navigate('ScreenC')} />
<Button title="Go back" onPress={() => navigation.goBack()} />
</View>
);
const ScreenB = ({ navigation }: ScreenBProps): React.JSX.Element => {
const [gestureType, setGestureType] = React.useState<NonNullable<NativeStackNavigationOptions['gestureType']>>('twoDimensionalSwipe');

React.useEffect(() => {
navigation.setOptions({
gestureType,
});
}, [gestureType]);

return (
<View style={{ ...styles.container, backgroundColor: 'thistle' }}>
<SettingsPicker<NonNullable<NativeStackNavigationOptions['gestureType']>>
label="Stack animation"
value={gestureType}
onValueChange={setGestureType}
items={[
"swipeRight",
"swipeLeft",
"swipeUp",
"swipeDown",
"verticalSwipe",
"horizontalSwipe",
"twoDimensionalSwipe",
]}
/>
<Button title="Go ScreenC" onPress={() => navigation.navigate('ScreenC')} />
<Button title="Go back" onPress={() => navigation.goBack()} />
</View>
);
}

interface ScreenCProps {
navigation: NativeStackNavigationProp<StackParamList, 'ScreenC'>;
Expand All @@ -56,10 +81,6 @@ const App = (): React.JSX.Element => (
<Stack.Screen
name="ScreenB"
component={ScreenB}
options={{
// @ts-ignore: goBackGesture is not implemented yet in react-navigation
goBackGesture: 'twoDimensionalSwipe',
}}
/>
<Stack.Screen name="ScreenC" component={ScreenC} />
</Stack.Navigator>
Expand Down
6 changes: 0 additions & 6 deletions apps/src/tests/Test1649/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ export default function App(): JSX.Element {
contentStyle: {
backgroundColor: 'firebrick',
},
unstable_screenStyle: {
backgroundColor: 'firebrick',
},
// unstable_footerComponent: Footer(),
...sheetOptions,
}}
Expand Down Expand Up @@ -107,9 +104,6 @@ export default function App(): JSX.Element {
headerShown: false,
presentation: 'formSheet',
sheetElevation: 24,
unstable_screenStyle: {
backgroundColor: 'firebrick',
},
...sheetOptions,
sheetAllowedDetents: [0.7],
}}
Expand Down
3 changes: 0 additions & 3 deletions apps/src/tests/Test1649/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ const routes: Record<string, RouteDescriptor> = {
headerShown: false,
presentation: 'formSheet',
sheetElevation: 24,
unstable_screenStyle: {
backgroundColor: 'firebrick',
},
...sheetInitialOptions,
},
},
Expand Down
3 changes: 1 addition & 2 deletions apps/src/tests/TestScreenAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ const App = (): JSX.Element => (
name="ScreenB"
component={ScreenB}
options={{
// @ts-ignore: goBackGesture is not implemented yet in react-navigation
goBackGesture: 'twoDimensionalSwipe',
gestureType: 'twoDimensionalSwipe',
}}
/>
<Stack.Screen name="ScreenC" component={ScreenC} />
Expand Down
87 changes: 87 additions & 0 deletions apps/src/tests/TestScreenAnimationV5.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { View, StyleSheet, Button } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import {
NativeStackNavigationProp,
createNativeStackNavigator,
} from 'react-native-screens/native-stack'
import { GestureDetectorProvider } from 'react-native-screens/gesture-handler';

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 => (
<GestureHandlerRootView style={{ flex: 1 }}>
<NavigationContainer>
<GestureDetectorProvider>
<Stack.Navigator
screenOptions={{
headerBackVisible: false,
animation: 'none',
}}>
<Stack.Screen name="ScreenA" component={MainScreen} />
<Stack.Screen
name="ScreenB"
component={ScreenB}
options={{
goBackGesture: 'twoDimensionalSwipe',
}}
/>
<Stack.Screen name="ScreenC" component={ScreenC} />
</Stack.Navigator>
</GestureDetectorProvider>
</NavigationContainer>
</GestureHandlerRootView>
);

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

export default App;
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export { default as Test2332 } from './Test2332';
export { default as Test2379 } from './Test2379';
export { default as Test2395 } from './Test2395';
export { default as TestScreenAnimation } from './TestScreenAnimation';
export { default as TestScreenAnimationV5 } from './TestScreenAnimationV5';
export { default as TestHeader } from './TestHeader';
export { default as TestPreload } from './TestPreload';
export { default as TestActivityStateProgression } from './TestActivityStateProgression';
Expand Down
4 changes: 2 additions & 2 deletions guides/GUIDE_FOR_LIBRARY_AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Boolean indicating whether the swipe gesture should work on whole screen. Swipin

Boolean indicating whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
default iOS shadow. Defaults to `false`.
default iOS shadow. Defaults to `true`.

### `gestureEnabled` (iOS only)

Expand Down Expand Up @@ -223,7 +223,7 @@ Allows for the customization of how the given screen should appear/disappear whe
- `"fade"` – fades screen in or out
- `fade_from_bottom` – performs a fade from bottom animation
- `"flip"` – flips the screen, requires `stackPresentation: "modal"` (iOS only)
- `"simple_push"` – performs a default animation, but without shadow and native header transition (iOS only)
- `"simple_push"` – performs a default animation, but without native header transition (iOS only)
- `"slide_from_bottom"` - slide in the new screen from bottom to top
- `"slide_from_right"` - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
- `"slide_from_left"` - slide in the new screen from left to right
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSConvert.mm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "RNSConvert.h"

#ifndef RCT_NEW_ARCH_ENABLED
#import <react/RCTAssert.h>
#import <React/RCTAssert.h>
#endif // !RCT_NEW_ARCH_ENABLED

@implementation RNSConvert
Expand Down
1 change: 1 addition & 0 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ - (void)initCommonProps
_hasOrientationSet = NO;
_hasHomeIndicatorHiddenSet = NO;
_activityState = RNSActivityStateUndefined;
_fullScreenSwipeShadowEnabled = YES;
#if !TARGET_OS_TV
_sheetExpandsWhenScrolledToEdge = YES;
#endif // !TARGET_OS_TV
Expand Down
4 changes: 2 additions & 2 deletions native-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Boolean indicating whether the swipe gesture should work on whole screen. Swipin

Boolean indicating whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
default iOS shadow. Defaults to `false`.
default iOS shadow. Defaults to `true`.

#### `gestureEnabled` (iOS only)

Expand Down Expand Up @@ -325,7 +325,7 @@ How the given screen should appear/disappear when pushed or popped at the top of
- `fade` - fades screen in or out.
- `fade_from_bottom` – performs a fade from bottom animation
- `flip` – flips the screen, requires stackPresentation: `modal` (iOS only)
- `simple_push` – performs a default animation, but without shadow and native header transition (iOS only)
- `simple_push` – performs a default animation, but without native header transition (iOS only)
- `slide_from_bottom` – performs a slide from bottom animation
- `slide_from_right` - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
- `slide_from_left` - slide in the new screen from left to right
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-screens",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Native navigation primitives for your React Native app.",
"scripts": {
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn)",
Expand Down
44 changes: 16 additions & 28 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
let supportsCodegenConfig = false;
try {
const rnCliAndroidVersion =
require('@react-native-community/cli-platform-android/package.json').version;
const [major] = rnCliAndroidVersion.split('.');
supportsCodegenConfig = major >= 9;
} catch (e) {
// ignore
}

module.exports = {
dependency: {
platforms: {
android: supportsCodegenConfig
? {
componentDescriptors: [
"RNSFullWindowOverlayComponentDescriptor",
"RNSScreenContainerComponentDescriptor",
"RNSScreenNavigationContainerComponentDescriptor",
"RNSScreenStackHeaderConfigComponentDescriptor",
"RNSScreenStackHeaderSubviewComponentDescriptor",
"RNSScreenStackComponentDescriptor",
"RNSSearchBarComponentDescriptor",
'RNSScreenComponentDescriptor',
"RNSScreenFooterComponentDescriptor",
"RNSScreenContentWrapperComponentDescriptor",
'RNSModalScreenComponentDescriptor'
],
cmakeListsPath: "../android/src/main/jni/CMakeLists.txt"
}
: {},
android: {
componentDescriptors: [
"RNSFullWindowOverlayComponentDescriptor",
"RNSScreenContainerComponentDescriptor",
"RNSScreenNavigationContainerComponentDescriptor",
"RNSScreenStackHeaderConfigComponentDescriptor",
"RNSScreenStackHeaderSubviewComponentDescriptor",
"RNSScreenStackComponentDescriptor",
"RNSSearchBarComponentDescriptor",
'RNSScreenComponentDescriptor',
"RNSScreenFooterComponentDescriptor",
"RNSScreenContentWrapperComponentDescriptor",
'RNSModalScreenComponentDescriptor'
],
cmakeListsPath: "../android/src/main/jni/CMakeLists.txt"
},
},
},
};
4 changes: 2 additions & 2 deletions src/components/DebugContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ type ContainerProps = ViewProps & {
* See https://github.com/software-mansion/react-native-screens/pull/1825
* for detailed explanation.
*/
let DebugContainer: React.ComponentType<ContainerProps> = (props) => {
let DebugContainer: React.ComponentType<ContainerProps> = props => {
return <ScreenContentWrapper {...props} />;
}
};

if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line react/display-name
Expand Down
2 changes: 1 addition & 1 deletion src/components/DebugContainer.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import * as React from 'react';
import { type ViewProps } from 'react-native';
import ScreenContentWrapper from './ScreenContentWrapper';

export default function DebugContainer(props: ViewProps) {
export default function DebugContainer(props: ViewProps) {
return <ScreenContentWrapper {...props} />;
}
Loading

0 comments on commit 0e13917

Please sign in to comment.