mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-17 17:42:46 +08:00
Compare commits
8 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f015130df | ||
|
|
7580efce89 | ||
|
|
1179d56c50 | ||
|
|
a6e498170f | ||
|
|
4af9d10298 | ||
|
|
08e74af545 | ||
|
|
1e05895b24 | ||
|
|
929c3e3a3b |
@@ -5,7 +5,6 @@ import type { ParamListBase } from '@react-navigation/native';
|
|||||||
import {
|
import {
|
||||||
createStackNavigator,
|
createStackNavigator,
|
||||||
StackScreenProps,
|
StackScreenProps,
|
||||||
TransitionPresets,
|
|
||||||
} from '@react-navigation/stack';
|
} from '@react-navigation/stack';
|
||||||
import Article from '../Shared/Article';
|
import Article from '../Shared/Article';
|
||||||
import Albums from '../Shared/Albums';
|
import Albums from '../Shared/Albums';
|
||||||
@@ -119,7 +118,7 @@ export default function MixedStackScreen({ navigation }: Props) {
|
|||||||
component={AlbumsScreen}
|
component={AlbumsScreen}
|
||||||
options={{
|
options={{
|
||||||
title: 'Albums',
|
title: 'Albums',
|
||||||
...TransitionPresets.ModalPresentationIOS,
|
presentation: 'modal',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</MixedStack.Navigator>
|
</MixedStack.Navigator>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export default function ModalStackScreen({ navigation }: Props) {
|
|||||||
}, [navigation]);
|
}, [navigation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalStack.Navigator screenOptions={{ animationPresentation: 'modal' }}>
|
<ModalStack.Navigator screenOptions={{ presentation: 'modal' }}>
|
||||||
<ModalStack.Screen
|
<ModalStack.Screen
|
||||||
name="Article"
|
name="Article"
|
||||||
component={ArticleScreen}
|
component={ArticleScreen}
|
||||||
|
|||||||
@@ -84,9 +84,7 @@ export default function TransparentStackScreen({ navigation }: Props) {
|
|||||||
}, [navigation]);
|
}, [navigation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransparentStack.Navigator
|
<TransparentStack.Navigator screenOptions={{ presentation: 'modal' }}>
|
||||||
screenOptions={{ animationPresentation: 'modal' }}
|
|
||||||
>
|
|
||||||
<TransparentStack.Screen
|
<TransparentStack.Screen
|
||||||
name="Article"
|
name="Article"
|
||||||
component={ArticleScreen}
|
component={ArticleScreen}
|
||||||
|
|||||||
@@ -3,6 +3,30 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.9...@react-navigation/bottom-tabs@6.0.0-next.10) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add a deprecation warning for mode prop in stack ([a6e4981](https://github.com/react-navigation/react-navigation/commit/a6e498170f59648190fa5513e273ca523e56c5d5))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.8...@react-navigation/bottom-tabs@6.0.0-next.9) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.7...@react-navigation/bottom-tabs@6.0.0-next.8) (2021-05-09)
|
# [6.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.7...@react-navigation/bottom-tabs@6.0.0-next.8) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/bottom-tabs",
|
"name": "@react-navigation/bottom-tabs",
|
||||||
"description": "Bottom tab navigator following iOS design guidelines",
|
"description": "Bottom tab navigator following iOS design guidelines",
|
||||||
"version": "6.0.0-next.8",
|
"version": "6.0.0-next.10",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/elements": "^1.0.0-next.7",
|
"@react-navigation/elements": "^1.0.0-next.9",
|
||||||
"color": "^3.1.3",
|
"color": "^3.1.3",
|
||||||
"warn-once": "^0.0.1"
|
"warn-once": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
|
|||||||
@@ -70,7 +70,12 @@ function BottomTabNavigator({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { state, descriptors, navigation } = useNavigationBuilder<
|
const {
|
||||||
|
state,
|
||||||
|
descriptors,
|
||||||
|
navigation,
|
||||||
|
NavigationContent,
|
||||||
|
} = useNavigationBuilder<
|
||||||
TabNavigationState<ParamListBase>,
|
TabNavigationState<ParamListBase>,
|
||||||
TabRouterOptions,
|
TabRouterOptions,
|
||||||
TabActionHelpers<ParamListBase>,
|
TabActionHelpers<ParamListBase>,
|
||||||
@@ -85,13 +90,15 @@ function BottomTabNavigator({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BottomTabView
|
<NavigationContent>
|
||||||
{...rest}
|
<BottomTabView
|
||||||
state={state}
|
{...rest}
|
||||||
navigation={navigation}
|
state={state}
|
||||||
descriptors={descriptors}
|
navigation={navigation}
|
||||||
sceneContainerStyle={sceneContainerStyle}
|
descriptors={descriptors}
|
||||||
/>
|
sceneContainerStyle={sceneContainerStyle}
|
||||||
|
/>
|
||||||
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { StyleSheet, Platform } from 'react-native';
|
import { StyleSheet, Platform } from 'react-native';
|
||||||
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
||||||
import {
|
import type {
|
||||||
NavigationHelpersContext,
|
|
||||||
ParamListBase,
|
ParamListBase,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
@@ -89,72 +88,70 @@ export default function BottomTabView(props: Props) {
|
|||||||
const { routes } = state;
|
const { routes } = state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<SafeAreaProviderCompat>
|
||||||
<SafeAreaProviderCompat>
|
<MaybeScreenContainer
|
||||||
<MaybeScreenContainer
|
enabled={detachInactiveScreens}
|
||||||
enabled={detachInactiveScreens}
|
style={styles.container}
|
||||||
style={styles.container}
|
>
|
||||||
>
|
{routes.map((route, index) => {
|
||||||
{routes.map((route, index) => {
|
const descriptor = descriptors[route.key];
|
||||||
const descriptor = descriptors[route.key];
|
const { lazy = true, unmountOnBlur } = descriptor.options;
|
||||||
const { lazy = true, unmountOnBlur } = descriptor.options;
|
const isFocused = state.index === index;
|
||||||
const isFocused = state.index === index;
|
|
||||||
|
|
||||||
if (unmountOnBlur && !isFocused) {
|
if (unmountOnBlur && !isFocused) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lazy && !loaded.includes(route.key) && !isFocused) {
|
if (lazy && !loaded.includes(route.key) && !isFocused) {
|
||||||
// Don't render a lazy screen if we've never navigated to it
|
// Don't render a lazy screen if we've never navigated to it
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
header = ({ layout, options }: BottomTabHeaderProps) => (
|
header = ({ layout, options }: BottomTabHeaderProps) => (
|
||||||
<Header
|
<Header
|
||||||
{...options}
|
{...options}
|
||||||
layout={layout}
|
layout={layout}
|
||||||
title={getHeaderTitle(options, route.name)}
|
title={getHeaderTitle(options, route.name)}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
} = descriptor.options;
|
} = descriptor.options;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MaybeScreen
|
<MaybeScreen
|
||||||
key={route.key}
|
key={route.key}
|
||||||
style={StyleSheet.absoluteFill}
|
style={StyleSheet.absoluteFill}
|
||||||
visible={isFocused}
|
visible={isFocused}
|
||||||
enabled={detachInactiveScreens}
|
enabled={detachInactiveScreens}
|
||||||
>
|
>
|
||||||
<BottomTabBarHeightContext.Provider value={tabBarHeight}>
|
<BottomTabBarHeightContext.Provider value={tabBarHeight}>
|
||||||
<Screen
|
<Screen
|
||||||
focused={isFocused}
|
focused={isFocused}
|
||||||
route={descriptor.route}
|
route={descriptor.route}
|
||||||
navigation={descriptor.navigation}
|
navigation={descriptor.navigation}
|
||||||
headerShown={descriptor.options.headerShown}
|
headerShown={descriptor.options.headerShown}
|
||||||
headerStatusBarHeight={
|
headerStatusBarHeight={
|
||||||
descriptor.options.headerStatusBarHeight
|
descriptor.options.headerStatusBarHeight
|
||||||
}
|
}
|
||||||
header={header({
|
header={header({
|
||||||
layout: dimensions,
|
layout: dimensions,
|
||||||
route: descriptor.route,
|
route: descriptor.route,
|
||||||
navigation: descriptor.navigation as BottomTabNavigationProp<ParamListBase>,
|
navigation: descriptor.navigation as BottomTabNavigationProp<ParamListBase>,
|
||||||
options: descriptor.options,
|
options: descriptor.options,
|
||||||
})}
|
})}
|
||||||
style={sceneContainerStyle}
|
style={sceneContainerStyle}
|
||||||
>
|
>
|
||||||
{descriptor.render()}
|
{descriptor.render()}
|
||||||
</Screen>
|
</Screen>
|
||||||
</BottomTabBarHeightContext.Provider>
|
</BottomTabBarHeightContext.Provider>
|
||||||
</MaybeScreen>
|
</MaybeScreen>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</MaybeScreenContainer>
|
</MaybeScreenContainer>
|
||||||
<BottomTabBarHeightCallbackContext.Provider value={setTabBarHeight}>
|
<BottomTabBarHeightCallbackContext.Provider value={setTabBarHeight}>
|
||||||
{renderTabBar()}
|
{renderTabBar()}
|
||||||
</BottomTabBarHeightCallbackContext.Provider>
|
</BottomTabBarHeightCallbackContext.Provider>
|
||||||
</SafeAreaProviderCompat>
|
</SafeAreaProviderCompat>
|
||||||
</NavigationHelpersContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,28 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.6...@react-navigation/core@6.0.0-next.7) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.5...@react-navigation/core@6.0.0-next.6) (2021-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix type annotations for useNavigation (again) ([929c3e3](https://github.com/react-navigation/react-navigation/commit/929c3e3a3b3eb32d197ef1f887dc4cbdce48eaff))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.4...@react-navigation/core@6.0.0-next.5) (2021-05-09)
|
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.4...@react-navigation/core@6.0.0-next.5) (2021-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/core",
|
"name": "@react-navigation/core",
|
||||||
"description": "Core utilities for building navigators",
|
"description": "Core utilities for building navigators",
|
||||||
"version": "6.0.0-next.5",
|
"version": "6.0.0-next.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
|
|||||||
30
packages/core/src/useComponent.tsx
Normal file
30
packages/core/src/useComponent.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
export default function useComponent<
|
||||||
|
T extends React.ComponentType<any>,
|
||||||
|
P extends {}
|
||||||
|
>(Component: T, props: P) {
|
||||||
|
const propsRef = React.useRef<P | null>(props);
|
||||||
|
|
||||||
|
// Normally refs shouldn't be mutated in render
|
||||||
|
// But we return a component which will be rendered
|
||||||
|
// So it's just for immediate consumption
|
||||||
|
propsRef.current = props;
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
propsRef.current = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
return React.useRef((rest: Omit<React.ComponentProps<T>, keyof P>) => {
|
||||||
|
const props = propsRef.current;
|
||||||
|
|
||||||
|
if (props === null) {
|
||||||
|
throw new Error(
|
||||||
|
'The returned component must be rendered in the same render phase as the hook.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error: the props should be fine here
|
||||||
|
return <Component {...props} {...rest} />;
|
||||||
|
}).current;
|
||||||
|
}
|
||||||
@@ -8,9 +8,7 @@ import type { NavigationProp } from './types';
|
|||||||
* @returns Navigation prop of the parent screen.
|
* @returns Navigation prop of the parent screen.
|
||||||
*/
|
*/
|
||||||
export default function useNavigation<
|
export default function useNavigation<
|
||||||
T extends
|
T = NavigationProp<ReactNavigation.RootParamList>
|
||||||
| NavigationProp<{}>
|
|
||||||
| NavigationProp<any> = NavigationProp<ReactNavigation.RootParamList>
|
|
||||||
>(): T {
|
>(): T {
|
||||||
const navigation = React.useContext(NavigationContext);
|
const navigation = React.useContext(NavigationContext);
|
||||||
|
|
||||||
@@ -20,5 +18,6 @@ export default function useNavigation<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return navigation as T;
|
// FIXME: Figure out a better way to do this
|
||||||
|
return (navigation as unknown) as T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from '@react-navigation/routers';
|
} from '@react-navigation/routers';
|
||||||
import NavigationStateContext from './NavigationStateContext';
|
import NavigationStateContext from './NavigationStateContext';
|
||||||
import NavigationRouteContext from './NavigationRouteContext';
|
import NavigationRouteContext from './NavigationRouteContext';
|
||||||
|
import NavigationHelpersContext from './NavigationHelpersContext';
|
||||||
import Group from './Group';
|
import Group from './Group';
|
||||||
import Screen from './Screen';
|
import Screen from './Screen';
|
||||||
import useEventEmitter from './useEventEmitter';
|
import useEventEmitter from './useEventEmitter';
|
||||||
@@ -29,6 +30,7 @@ import useKeyedChildListeners from './useKeyedChildListeners';
|
|||||||
import useOnGetState from './useOnGetState';
|
import useOnGetState from './useOnGetState';
|
||||||
import useScheduleUpdate from './useScheduleUpdate';
|
import useScheduleUpdate from './useScheduleUpdate';
|
||||||
import useCurrentRender from './useCurrentRender';
|
import useCurrentRender from './useCurrentRender';
|
||||||
|
import useComponent from './useComponent';
|
||||||
import isArrayEqual from './isArrayEqual';
|
import isArrayEqual from './isArrayEqual';
|
||||||
import {
|
import {
|
||||||
DefaultNavigatorOptions,
|
DefaultNavigatorOptions,
|
||||||
@@ -586,9 +588,14 @@ export default function useNavigationBuilder<
|
|||||||
descriptors,
|
descriptors,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const NavigationContent = useComponent(NavigationHelpersContext.Provider, {
|
||||||
|
value: navigation,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
navigation,
|
navigation,
|
||||||
descriptors,
|
descriptors,
|
||||||
|
NavigationContent,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.6...@react-navigation/devtools@6.0.0-next.7) (2021-05-10)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/devtools
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.5...@react-navigation/devtools@6.0.0-next.6) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/devtools
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.4...@react-navigation/devtools@6.0.0-next.5) (2021-05-09)
|
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.4...@react-navigation/devtools@6.0.0-next.5) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/devtools
|
**Note:** Version bump only for package @react-navigation/devtools
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/devtools",
|
"name": "@react-navigation/devtools",
|
||||||
"description": "Developer tools for React Navigation",
|
"description": "Developer tools for React Navigation",
|
||||||
"version": "6.0.0-next.5",
|
"version": "6.0.0-next.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/core": "^6.0.0-next.5",
|
"@react-navigation/core": "^6.0.0-next.7",
|
||||||
"deep-equal": "^2.0.5"
|
"deep-equal": "^2.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -3,6 +3,30 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.8...@react-navigation/drawer@6.0.0-next.9) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add a deprecation warning for mode prop in stack ([a6e4981](https://github.com/react-navigation/react-navigation/commit/a6e498170f59648190fa5513e273ca523e56c5d5))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.7...@react-navigation/drawer@6.0.0-next.8) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.6...@react-navigation/drawer@6.0.0-next.7) (2021-05-09)
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.6...@react-navigation/drawer@6.0.0-next.7) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/drawer
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/drawer",
|
"name": "@react-navigation/drawer",
|
||||||
"description": "Drawer navigator component with animated transitions and gesturess",
|
"description": "Drawer navigator component with animated transitions and gesturess",
|
||||||
"version": "6.0.0-next.7",
|
"version": "6.0.0-next.9",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -41,12 +41,12 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/elements": "^1.0.0-next.7",
|
"@react-navigation/elements": "^1.0.0-next.9",
|
||||||
"color": "^3.1.3",
|
"color": "^3.1.3",
|
||||||
"warn-once": "^0.0.1"
|
"warn-once": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
"@types/react-native": "~0.64.4",
|
"@types/react-native": "~0.64.4",
|
||||||
|
|||||||
@@ -67,7 +67,12 @@ function DrawerNavigator({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { state, descriptors, navigation } = useNavigationBuilder<
|
const {
|
||||||
|
state,
|
||||||
|
descriptors,
|
||||||
|
navigation,
|
||||||
|
NavigationContent,
|
||||||
|
} = useNavigationBuilder<
|
||||||
DrawerNavigationState<ParamListBase>,
|
DrawerNavigationState<ParamListBase>,
|
||||||
DrawerRouterOptions,
|
DrawerRouterOptions,
|
||||||
DrawerActionHelpers<ParamListBase>,
|
DrawerActionHelpers<ParamListBase>,
|
||||||
@@ -83,12 +88,14 @@ function DrawerNavigator({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerView
|
<NavigationContent>
|
||||||
{...rest}
|
<DrawerView
|
||||||
state={state}
|
{...rest}
|
||||||
descriptors={descriptors}
|
state={state}
|
||||||
navigation={navigation}
|
descriptors={descriptors}
|
||||||
/>
|
navigation={navigation}
|
||||||
|
/>
|
||||||
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
import { useSafeAreaFrame } from 'react-native-safe-area-context';
|
import { useSafeAreaFrame } from 'react-native-safe-area-context';
|
||||||
import Animated from 'react-native-reanimated';
|
import Animated from 'react-native-reanimated';
|
||||||
import {
|
import {
|
||||||
NavigationHelpersContext,
|
|
||||||
DrawerNavigationState,
|
DrawerNavigationState,
|
||||||
DrawerActions,
|
DrawerActions,
|
||||||
useTheme,
|
useTheme,
|
||||||
@@ -296,13 +295,11 @@ function DrawerViewBase({
|
|||||||
|
|
||||||
export default function DrawerView({ navigation, ...rest }: Props) {
|
export default function DrawerView({ navigation, ...rest }: Props) {
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<SafeAreaProviderCompat>
|
||||||
<SafeAreaProviderCompat>
|
<GestureHandlerWrapper style={styles.content}>
|
||||||
<GestureHandlerWrapper style={styles.content}>
|
<DrawerViewBase navigation={navigation} {...rest} />
|
||||||
<DrawerViewBase navigation={navigation} {...rest} />
|
</GestureHandlerWrapper>
|
||||||
</GestureHandlerWrapper>
|
</SafeAreaProviderCompat>
|
||||||
</SafeAreaProviderCompat>
|
|
||||||
</NavigationHelpersContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [1.0.0-next.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.8...@react-navigation/elements@1.0.0-next.9) (2021-05-10)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/elements
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [1.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.7...@react-navigation/elements@1.0.0-next.8) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/elements
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [1.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.6...@react-navigation/elements@1.0.0-next.7) (2021-05-09)
|
# [1.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.6...@react-navigation/elements@1.0.0-next.7) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/elements
|
**Note:** Version bump only for package @react-navigation/elements
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/elements",
|
"name": "@react-navigation/elements",
|
||||||
"description": "UI Components for React Navigation",
|
"description": "UI Components for React Navigation",
|
||||||
"version": "1.0.0-next.7",
|
"version": "1.0.0-next.9",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation",
|
"react-navigation",
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-masked-view/masked-view": "^0.2.3",
|
"@react-native-masked-view/masked-view": "^0.2.3",
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
"@types/react-native": "~0.64.4",
|
"@types/react-native": "~0.64.4",
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.6...@react-navigation/material-bottom-tabs@6.0.0-next.7) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.5...@react-navigation/material-bottom-tabs@6.0.0-next.6) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.4...@react-navigation/material-bottom-tabs@6.0.0-next.5) (2021-05-09)
|
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.4...@react-navigation/material-bottom-tabs@6.0.0-next.5) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-bottom-tabs",
|
"name": "@react-navigation/material-bottom-tabs",
|
||||||
"description": "Integration for bottom navigation component from react-native-paper",
|
"description": "Integration for bottom navigation component from react-native-paper",
|
||||||
"version": "6.0.0-next.5",
|
"version": "6.0.0-next.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
"@types/react-native": "~0.64.4",
|
"@types/react-native": "~0.64.4",
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ function MaterialBottomTabNavigator({
|
|||||||
screenOptions,
|
screenOptions,
|
||||||
...rest
|
...rest
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { state, descriptors, navigation } = useNavigationBuilder<
|
const {
|
||||||
|
state,
|
||||||
|
descriptors,
|
||||||
|
navigation,
|
||||||
|
NavigationContent,
|
||||||
|
} = useNavigationBuilder<
|
||||||
TabNavigationState<ParamListBase>,
|
TabNavigationState<ParamListBase>,
|
||||||
TabRouterOptions,
|
TabRouterOptions,
|
||||||
TabActionHelpers<ParamListBase>,
|
TabActionHelpers<ParamListBase>,
|
||||||
@@ -42,12 +47,14 @@ function MaterialBottomTabNavigator({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MaterialBottomTabView
|
<NavigationContent>
|
||||||
{...rest}
|
<MaterialBottomTabView
|
||||||
state={state}
|
{...rest}
|
||||||
navigation={navigation}
|
state={state}
|
||||||
descriptors={descriptors}
|
navigation={navigation}
|
||||||
/>
|
descriptors={descriptors}
|
||||||
|
/>
|
||||||
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|||||||
import { Text, StyleSheet, Platform } from 'react-native';
|
import { Text, StyleSheet, Platform } from 'react-native';
|
||||||
import { BottomNavigation, DefaultTheme, DarkTheme } from 'react-native-paper';
|
import { BottomNavigation, DefaultTheme, DarkTheme } from 'react-native-paper';
|
||||||
import {
|
import {
|
||||||
NavigationHelpersContext,
|
|
||||||
Route,
|
Route,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
TabActions,
|
TabActions,
|
||||||
@@ -75,7 +74,7 @@ try {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function MaterialBottomTabViewInner({
|
export default function MaterialBottomTabView({
|
||||||
state,
|
state,
|
||||||
navigation,
|
navigation,
|
||||||
descriptors,
|
descriptors,
|
||||||
@@ -192,14 +191,6 @@ function MaterialBottomTabViewInner({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MaterialBottomTabView(props: Props) {
|
|
||||||
return (
|
|
||||||
<NavigationHelpersContext.Provider value={props.navigation}>
|
|
||||||
<MaterialBottomTabViewInner {...props} />
|
|
||||||
</NavigationHelpersContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
icon: {
|
icon: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
|
|||||||
@@ -3,6 +3,30 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.7...@react-navigation/material-top-tabs@6.0.0-next.8) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add a deprecation warning for mode prop in stack ([a6e4981](https://github.com/react-navigation/react-navigation/commit/a6e498170f59648190fa5513e273ca523e56c5d5))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.6...@react-navigation/material-top-tabs@6.0.0-next.7) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.5...@react-navigation/material-top-tabs@6.0.0-next.6) (2021-05-09)
|
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.5...@react-navigation/material-top-tabs@6.0.0-next.6) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-top-tabs",
|
"name": "@react-navigation/material-top-tabs",
|
||||||
"description": "Integration for the animated tab view component from react-native-tab-view",
|
"description": "Integration for the animated tab view component from react-native-tab-view",
|
||||||
"version": "6.0.0-next.6",
|
"version": "6.0.0-next.8",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -42,10 +42,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"color": "^3.1.3",
|
"color": "^3.1.3",
|
||||||
"warn-once": "^0.0.1"
|
"warn-once": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
"@types/react-native": "~0.64.4",
|
"@types/react-native": "~0.64.4",
|
||||||
|
|||||||
@@ -71,7 +71,12 @@ function MaterialTopTabNavigator({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { state, descriptors, navigation } = useNavigationBuilder<
|
const {
|
||||||
|
state,
|
||||||
|
descriptors,
|
||||||
|
navigation,
|
||||||
|
NavigationContent,
|
||||||
|
} = useNavigationBuilder<
|
||||||
TabNavigationState<ParamListBase>,
|
TabNavigationState<ParamListBase>,
|
||||||
TabRouterOptions,
|
TabRouterOptions,
|
||||||
TabActionHelpers<ParamListBase>,
|
TabActionHelpers<ParamListBase>,
|
||||||
@@ -85,12 +90,14 @@ function MaterialTopTabNavigator({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MaterialTopTabView
|
<NavigationContent>
|
||||||
{...rest}
|
<MaterialTopTabView
|
||||||
state={state}
|
{...rest}
|
||||||
navigation={navigation}
|
state={state}
|
||||||
descriptors={descriptors}
|
navigation={navigation}
|
||||||
/>
|
descriptors={descriptors}
|
||||||
|
/>
|
||||||
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { TabView, SceneRendererProps } from 'react-native-tab-view';
|
import { TabView, SceneRendererProps } from 'react-native-tab-view';
|
||||||
import {
|
import {
|
||||||
NavigationHelpersContext,
|
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
TabActions,
|
TabActions,
|
||||||
ParamListBase,
|
ParamListBase,
|
||||||
@@ -43,29 +42,27 @@ export default function MaterialTopTabView({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<TabView<Route<string>>
|
||||||
<TabView<Route<string>>
|
{...rest}
|
||||||
{...rest}
|
onIndexChange={(index) =>
|
||||||
onIndexChange={(index) =>
|
navigation.dispatch({
|
||||||
navigation.dispatch({
|
...TabActions.jumpTo(state.routes[index].name),
|
||||||
...TabActions.jumpTo(state.routes[index].name),
|
target: state.key,
|
||||||
target: state.key,
|
})
|
||||||
})
|
}
|
||||||
}
|
renderScene={({ route }) => descriptors[route.key].render()}
|
||||||
renderScene={({ route }) => descriptors[route.key].render()}
|
navigationState={state}
|
||||||
navigationState={state}
|
renderTabBar={renderTabBar}
|
||||||
renderTabBar={renderTabBar}
|
renderLazyPlaceholder={({ route }) =>
|
||||||
renderLazyPlaceholder={({ route }) =>
|
descriptors[route.key].options.lazyPlaceholder?.() ?? null
|
||||||
descriptors[route.key].options.lazyPlaceholder?.() ?? null
|
}
|
||||||
}
|
lazy={({ route }) => descriptors[route.key].options.lazy === true}
|
||||||
lazy={({ route }) => descriptors[route.key].options.lazy === true}
|
onSwipeStart={() => navigation.emit({ type: 'swipeStart' })}
|
||||||
onSwipeStart={() => navigation.emit({ type: 'swipeStart' })}
|
onSwipeEnd={() => navigation.emit({ type: 'swipeEnd' })}
|
||||||
onSwipeEnd={() => navigation.emit({ type: 'swipeEnd' })}
|
sceneContainerStyle={[
|
||||||
sceneContainerStyle={[
|
{ backgroundColor: colors.background },
|
||||||
{ backgroundColor: colors.background },
|
sceneContainerStyle,
|
||||||
sceneContainerStyle,
|
]}
|
||||||
]}
|
/>
|
||||||
/>
|
|
||||||
</NavigationHelpersContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.6...@react-navigation/native@6.0.0-next.7) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.5...@react-navigation/native@6.0.0-next.6) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.4...@react-navigation/native@6.0.0-next.5) (2021-05-09)
|
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.4...@react-navigation/native@6.0.0-next.5) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/native
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/native",
|
"name": "@react-navigation/native",
|
||||||
"description": "React Native integration for React Navigation",
|
"description": "React Native integration for React Navigation",
|
||||||
"version": "6.0.0-next.5",
|
"version": "6.0.0-next.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation",
|
"react-navigation",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/core": "^6.0.0-next.5",
|
"@react-navigation/core": "^6.0.0-next.7",
|
||||||
"escape-string-regexp": "^4.0.0",
|
"escape-string-regexp": "^4.0.0",
|
||||||
"nanoid": "^3.1.22"
|
"nanoid": "^3.1.22"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
createNavigatorFactory,
|
createNavigatorFactory,
|
||||||
StackRouter,
|
StackRouter,
|
||||||
TabRouter,
|
TabRouter,
|
||||||
NavigationHelpersContext,
|
|
||||||
createNavigationContainerRef,
|
createNavigationContainerRef,
|
||||||
ParamListBase,
|
ParamListBase,
|
||||||
} from '@react-navigation/core';
|
} from '@react-navigation/core';
|
||||||
@@ -22,36 +21,36 @@ it('integrates with the history API', () => {
|
|||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
const createStackNavigator = createNavigatorFactory((props: any) => {
|
const createStackNavigator = createNavigatorFactory((props: any) => {
|
||||||
const { navigation, state, descriptors } = useNavigationBuilder(
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
||||||
StackRouter,
|
StackRouter,
|
||||||
props
|
props
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<NavigationContent>
|
||||||
{state.routes.map((route, i) => (
|
{state.routes.map((route, i) => (
|
||||||
<div key={route.key} aria-current={state.index === i || undefined}>
|
<div key={route.key} aria-current={state.index === i || undefined}>
|
||||||
{descriptors[route.key].render()}
|
{descriptors[route.key].render()}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</NavigationHelpersContext.Provider>
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const createTabNavigator = createNavigatorFactory((props: any) => {
|
const createTabNavigator = createNavigatorFactory((props: any) => {
|
||||||
const { navigation, state, descriptors } = useNavigationBuilder(
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
||||||
TabRouter,
|
TabRouter,
|
||||||
props
|
props
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<NavigationContent>
|
||||||
{state.routes.map((route, i) => (
|
{state.routes.map((route, i) => (
|
||||||
<div key={route.key} aria-current={state.index === i || undefined}>
|
<div key={route.key} aria-current={state.index === i || undefined}>
|
||||||
{descriptors[route.key].render()}
|
{descriptors[route.key].render()}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</NavigationHelpersContext.Provider>
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
createNavigatorFactory,
|
createNavigatorFactory,
|
||||||
StackRouter,
|
StackRouter,
|
||||||
TabRouter,
|
TabRouter,
|
||||||
NavigationHelpersContext,
|
|
||||||
NavigatorScreenParams,
|
NavigatorScreenParams,
|
||||||
} from '@react-navigation/core';
|
} from '@react-navigation/core';
|
||||||
import { renderToString } from 'react-dom/server';
|
import { renderToString } from 'react-dom/server';
|
||||||
@@ -23,17 +22,17 @@ jest.mock('../useLinking', () => require('../useLinking.tsx').default);
|
|||||||
|
|
||||||
it('renders correct state with location', () => {
|
it('renders correct state with location', () => {
|
||||||
const createStackNavigator = createNavigatorFactory((props: any) => {
|
const createStackNavigator = createNavigatorFactory((props: any) => {
|
||||||
const { navigation, state, descriptors } = useNavigationBuilder(
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
||||||
StackRouter,
|
StackRouter,
|
||||||
props
|
props
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<NavigationContent>
|
||||||
{state.routes.map((route) => (
|
{state.routes.map((route) => (
|
||||||
<div key={route.key}>{descriptors[route.key].render()}</div>
|
<div key={route.key}>{descriptors[route.key].render()}</div>
|
||||||
))}
|
))}
|
||||||
</NavigationHelpersContext.Provider>
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,17 +115,17 @@ it('renders correct state with location', () => {
|
|||||||
|
|
||||||
it('gets the current options', () => {
|
it('gets the current options', () => {
|
||||||
const createTabNavigator = createNavigatorFactory((props: any) => {
|
const createTabNavigator = createNavigatorFactory((props: any) => {
|
||||||
const { navigation, state, descriptors } = useNavigationBuilder(
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
||||||
TabRouter,
|
TabRouter,
|
||||||
props
|
props
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<NavigationContent>
|
||||||
{state.routes.map((route) => (
|
{state.routes.map((route) => (
|
||||||
<div key={route.key}>{descriptors[route.key].render()}</div>
|
<div key={route.key}>{descriptors[route.key].render()}</div>
|
||||||
))}
|
))}
|
||||||
</NavigationHelpersContext.Provider>
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,41 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.14...@react-navigation/stack@6.0.0-next.15) (2021-05-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add a deprecation warning for mode prop in stack ([a6e4981](https://github.com/react-navigation/react-navigation/commit/a6e498170f59648190fa5513e273ca523e56c5d5))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* return a NavigationContent component from useNavigationBuilder ([1179d56](https://github.com/react-navigation/react-navigation/commit/1179d56c5008270753feef41acdc1dbd2191efcf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.14](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.13...@react-navigation/stack@6.0.0-next.14) (2021-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix modal animation not being set properly ([08e74af](https://github.com/react-navigation/react-navigation/commit/08e74af54529582dcbc8d91e77bfed70f006f00d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [6.0.0-next.13](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.12...@react-navigation/stack@6.0.0-next.13) (2021-05-09)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/stack
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [6.0.0-next.12](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.11...@react-navigation/stack@6.0.0-next.12) (2021-05-09)
|
# [6.0.0-next.12](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.11...@react-navigation/stack@6.0.0-next.12) (2021-05-09)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/stack
|
**Note:** Version bump only for package @react-navigation/stack
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/stack",
|
"name": "@react-navigation/stack",
|
||||||
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
||||||
"version": "6.0.0-next.12",
|
"version": "6.0.0-next.15",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -40,13 +40,13 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/elements": "^1.0.0-next.7",
|
"@react-navigation/elements": "^1.0.0-next.9",
|
||||||
"color": "^3.1.3",
|
"color": "^3.1.3",
|
||||||
"react-native-iphone-x-helper": "^1.3.0",
|
"react-native-iphone-x-helper": "^1.3.0",
|
||||||
"warn-once": "^0.0.1"
|
"warn-once": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-navigation/native": "^6.0.0-next.5",
|
"@react-navigation/native": "^6.0.0-next.7",
|
||||||
"@testing-library/react-native": "^7.2.0",
|
"@testing-library/react-native": "^7.2.0",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.53",
|
"@types/react": "^16.9.53",
|
||||||
|
|||||||
@@ -30,20 +30,33 @@ function StackNavigator({
|
|||||||
screenOptions,
|
screenOptions,
|
||||||
...rest
|
...rest
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
// @ts-expect-error: mode is deprecated
|
||||||
|
const mode = rest.mode as 'card' | 'modal' | undefined;
|
||||||
|
|
||||||
// @ts-expect-error: headerMode='none' is deprecated
|
// @ts-expect-error: headerMode='none' is deprecated
|
||||||
const headerMode = rest.headerMode as StackHeaderMode | 'none' | undefined;
|
const headerMode = rest.headerMode as StackHeaderMode | 'none' | undefined;
|
||||||
|
|
||||||
|
warnOnce(
|
||||||
|
mode != null,
|
||||||
|
`Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.`
|
||||||
|
);
|
||||||
|
|
||||||
warnOnce(
|
warnOnce(
|
||||||
headerMode === 'none',
|
headerMode === 'none',
|
||||||
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.`
|
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.`
|
||||||
);
|
);
|
||||||
|
|
||||||
warnOnce(
|
warnOnce(
|
||||||
headerMode && headerMode !== 'none',
|
headerMode != null && headerMode !== 'none',
|
||||||
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.`
|
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.`
|
||||||
);
|
);
|
||||||
|
|
||||||
const { state, descriptors, navigation } = useNavigationBuilder<
|
const {
|
||||||
|
state,
|
||||||
|
descriptors,
|
||||||
|
navigation,
|
||||||
|
NavigationContent,
|
||||||
|
} = useNavigationBuilder<
|
||||||
StackNavigationState<ParamListBase>,
|
StackNavigationState<ParamListBase>,
|
||||||
StackRouterOptions,
|
StackRouterOptions,
|
||||||
StackActionHelpers<ParamListBase>,
|
StackActionHelpers<ParamListBase>,
|
||||||
@@ -54,6 +67,7 @@ function StackNavigator({
|
|||||||
children,
|
children,
|
||||||
screenOptions,
|
screenOptions,
|
||||||
defaultScreenOptions: () => ({
|
defaultScreenOptions: () => ({
|
||||||
|
presentation: mode,
|
||||||
headerShown: headerMode ? headerMode !== 'none' : true,
|
headerShown: headerMode ? headerMode !== 'none' : true,
|
||||||
headerMode: headerMode && headerMode !== 'none' ? headerMode : undefined,
|
headerMode: headerMode && headerMode !== 'none' ? headerMode : undefined,
|
||||||
}),
|
}),
|
||||||
@@ -85,12 +99,14 @@ function StackNavigator({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StackView
|
<NavigationContent>
|
||||||
{...rest}
|
<StackView
|
||||||
state={state}
|
{...rest}
|
||||||
descriptors={descriptors}
|
state={state}
|
||||||
navigation={navigation}
|
descriptors={descriptors}
|
||||||
/>
|
navigation={navigation}
|
||||||
|
/>
|
||||||
|
</NavigationContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -246,22 +246,25 @@ export type StackNavigationOptions = StackHeaderOptions &
|
|||||||
* so that the previous screen isn't transformed or invisible.
|
* so that the previous screen isn't transformed or invisible.
|
||||||
*/
|
*/
|
||||||
cardStyle?: StyleProp<ViewStyle>;
|
cardStyle?: StyleProp<ViewStyle>;
|
||||||
|
/**
|
||||||
|
* Whether this screen should be presented as a modal or a regular card.
|
||||||
|
*
|
||||||
|
* Specifying this will configure several options:
|
||||||
|
* - `card`: Use the default OS animations for iOS and Android screen transitions.
|
||||||
|
* - `modal`: Use Modal animations. This changes a few things:
|
||||||
|
* - Sets `headerMode` to `screen` for the screen unless specified otherwise.
|
||||||
|
* - Changes the screen animation to match the platform behavior for modals.
|
||||||
|
* - Adjusts the `detachPreviousScreen` option so that the previous screen stays rendered.
|
||||||
|
*
|
||||||
|
* Defaults to 'card'.
|
||||||
|
*/
|
||||||
|
presentation?: 'card' | 'modal';
|
||||||
/**
|
/**
|
||||||
* Whether transition animation should be enabled the screen.
|
* Whether transition animation should be enabled the screen.
|
||||||
* If you set it to `false`, the screen won't animate when pushing or popping.
|
* If you set it to `false`, the screen won't animate when pushing or popping.
|
||||||
* Defaults to `true` on Android and iOS, `false` on Web.
|
* Defaults to `true` on Android and iOS, `false` on Web.
|
||||||
*/
|
*/
|
||||||
animationEnabled?: boolean;
|
animationEnabled?: boolean;
|
||||||
/**
|
|
||||||
* Whether this screen should be presented as a modal or a regular card.
|
|
||||||
*
|
|
||||||
* If you haven't customized the animations separately, the animation will change based on the value:
|
|
||||||
* - 'modal' - modal animation on iOS and Android. It'll also default `headerMode` to `screen`.
|
|
||||||
* - 'card' - horizontal slide animation on iOS, OS-default animation on Android.
|
|
||||||
*
|
|
||||||
* Defaults to 'card'.
|
|
||||||
*/
|
|
||||||
animationPresentation?: 'card' | 'modal';
|
|
||||||
/**
|
/**
|
||||||
* The type of animation to use when this screen replaces another screen. Defaults to `push`.
|
* The type of animation to use when this screen replaces another screen. Defaults to `push`.
|
||||||
* When `pop` is used, the `pop` animation is applied to the screen being replaced.
|
* When `pop` is used, the `pop` animation is applied to the screen being replaced.
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ function CardContainer({
|
|||||||
}, [pointerEvents, scene.progress.next]);
|
}, [pointerEvents, scene.progress.next]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
animationPresentation,
|
presentation,
|
||||||
cardOverlay,
|
cardOverlay,
|
||||||
cardOverlayEnabled,
|
cardOverlayEnabled,
|
||||||
cardShadowEnabled,
|
cardShadowEnabled,
|
||||||
@@ -228,9 +228,7 @@ function CardContainer({
|
|||||||
accessibilityElementsHidden={!focused}
|
accessibilityElementsHidden={!focused}
|
||||||
importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
|
importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
|
||||||
pointerEvents={active ? 'box-none' : pointerEvents}
|
pointerEvents={active ? 'box-none' : pointerEvents}
|
||||||
pageOverflowEnabled={
|
pageOverflowEnabled={headerMode !== 'float' && presentation !== 'modal'}
|
||||||
headerMode !== 'float' && animationPresentation !== 'modal'
|
|
||||||
}
|
|
||||||
headerDarkContent={headerDarkContent}
|
headerDarkContent={headerDarkContent}
|
||||||
containerStyle={
|
containerStyle={
|
||||||
hasAbsoluteFloatHeader && headerMode !== 'screen'
|
hasAbsoluteFloatHeader && headerMode !== 'screen'
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ const getDistanceFromOptions = (
|
|||||||
descriptor?: StackDescriptor
|
descriptor?: StackDescriptor
|
||||||
) => {
|
) => {
|
||||||
const {
|
const {
|
||||||
animationPresentation,
|
presentation,
|
||||||
gestureDirection = animationPresentation === 'modal'
|
gestureDirection = presentation === 'modal'
|
||||||
? ModalTransition.gestureDirection
|
? ModalTransition.gestureDirection
|
||||||
: DefaultTransition.gestureDirection,
|
: DefaultTransition.gestureDirection,
|
||||||
} = (descriptor?.options || {}) as StackNavigationOptions;
|
} = (descriptor?.options || {}) as StackNavigationOptions;
|
||||||
@@ -214,10 +214,19 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
props.descriptors[previousRoute?.key] ||
|
props.descriptors[previousRoute?.key] ||
|
||||||
state.descriptors[previousRoute?.key];
|
state.descriptors[previousRoute?.key];
|
||||||
|
|
||||||
const { options } = descriptor;
|
// When a screen is not the last, it should use next screen's transition config
|
||||||
|
// Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
|
||||||
|
// For example combining a slide and a modal transition would look wrong otherwise
|
||||||
|
// With this approach, combining different transition styles in the same navigator mostly looks right
|
||||||
|
// This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
|
||||||
|
// but majority of the transitions look alright
|
||||||
|
const optionsForTransitionConfig =
|
||||||
|
index !== self.length - 1 && nextDescriptor
|
||||||
|
? nextDescriptor.options
|
||||||
|
: descriptor.options;
|
||||||
|
|
||||||
let defaultTransitionPreset =
|
let defaultTransitionPreset =
|
||||||
options.animationPresentation === 'modal'
|
optionsForTransitionConfig.presentation === 'modal'
|
||||||
? ModalTransition
|
? ModalTransition
|
||||||
: DefaultTransition;
|
: DefaultTransition;
|
||||||
|
|
||||||
@@ -225,9 +234,7 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
animationEnabled = Platform.OS !== 'web' &&
|
animationEnabled = Platform.OS !== 'web' &&
|
||||||
Platform.OS !== 'windows' &&
|
Platform.OS !== 'windows' &&
|
||||||
Platform.OS !== 'macos',
|
Platform.OS !== 'macos',
|
||||||
gestureEnabled = Platform.OS === 'ios' &&
|
gestureEnabled = Platform.OS === 'ios' && animationEnabled,
|
||||||
animationEnabled &&
|
|
||||||
index !== 0,
|
|
||||||
gestureDirection = defaultTransitionPreset.gestureDirection,
|
gestureDirection = defaultTransitionPreset.gestureDirection,
|
||||||
transitionSpec = defaultTransitionPreset.transitionSpec,
|
transitionSpec = defaultTransitionPreset.transitionSpec,
|
||||||
cardStyleInterpolator = animationEnabled === false
|
cardStyleInterpolator = animationEnabled === false
|
||||||
@@ -236,52 +243,16 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
headerStyleInterpolator = defaultTransitionPreset.headerStyleInterpolator,
|
headerStyleInterpolator = defaultTransitionPreset.headerStyleInterpolator,
|
||||||
cardOverlayEnabled = Platform.OS !== 'ios' ||
|
cardOverlayEnabled = Platform.OS !== 'ios' ||
|
||||||
cardStyleInterpolator === forModalPresentationIOS,
|
cardStyleInterpolator === forModalPresentationIOS,
|
||||||
} = options;
|
} = optionsForTransitionConfig;
|
||||||
|
|
||||||
let transitionConfig = {
|
|
||||||
gestureDirection,
|
|
||||||
transitionSpec,
|
|
||||||
cardStyleInterpolator,
|
|
||||||
headerStyleInterpolator,
|
|
||||||
cardOverlayEnabled,
|
|
||||||
};
|
|
||||||
|
|
||||||
// When a screen is not the last, it should use next screen's transition config
|
|
||||||
// Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
|
|
||||||
// For example combining a slide and a modal transition would look wrong otherwise
|
|
||||||
// With this approach, combining different transition styles in the same navigator mostly looks right
|
|
||||||
// This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
|
|
||||||
// but majority of the transitions look alright
|
|
||||||
if (index !== self.length - 1) {
|
|
||||||
if (nextDescriptor) {
|
|
||||||
const {
|
|
||||||
animationEnabled,
|
|
||||||
gestureDirection = defaultTransitionPreset.gestureDirection,
|
|
||||||
transitionSpec = defaultTransitionPreset.transitionSpec,
|
|
||||||
cardStyleInterpolator = animationEnabled === false
|
|
||||||
? forNoAnimationCard
|
|
||||||
: defaultTransitionPreset.cardStyleInterpolator,
|
|
||||||
headerStyleInterpolator = defaultTransitionPreset.headerStyleInterpolator,
|
|
||||||
cardOverlayEnabled = descriptor.options.cardOverlayEnabled ??
|
|
||||||
cardStyleInterpolator === forModalPresentationIOS,
|
|
||||||
} = nextDescriptor.options;
|
|
||||||
|
|
||||||
transitionConfig = {
|
|
||||||
gestureDirection,
|
|
||||||
transitionSpec,
|
|
||||||
cardStyleInterpolator,
|
|
||||||
headerStyleInterpolator,
|
|
||||||
cardOverlayEnabled,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const headerMode: StackHeaderMode =
|
const headerMode: StackHeaderMode =
|
||||||
options.headerMode ??
|
descriptor.options.headerMode ??
|
||||||
(options.animationPresentation !== 'modal' &&
|
(!(
|
||||||
transitionConfig.cardStyleInterpolator !== forModalPresentationIOS &&
|
optionsForTransitionConfig.presentation === 'modal' ||
|
||||||
|
cardStyleInterpolator === forModalPresentationIOS
|
||||||
|
) &&
|
||||||
Platform.OS === 'ios' &&
|
Platform.OS === 'ios' &&
|
||||||
options.header === undefined
|
descriptor.options.header === undefined
|
||||||
? 'float'
|
? 'float'
|
||||||
: 'screen');
|
: 'screen');
|
||||||
|
|
||||||
@@ -290,10 +261,14 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
descriptor: {
|
descriptor: {
|
||||||
...descriptor,
|
...descriptor,
|
||||||
options: {
|
options: {
|
||||||
...options,
|
...descriptor.options,
|
||||||
...transitionConfig,
|
|
||||||
animationEnabled,
|
animationEnabled,
|
||||||
|
cardOverlayEnabled,
|
||||||
|
cardStyleInterpolator,
|
||||||
|
gestureDirection,
|
||||||
gestureEnabled,
|
gestureEnabled,
|
||||||
|
headerStyleInterpolator,
|
||||||
|
transitionSpec,
|
||||||
headerMode,
|
headerMode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -492,7 +467,7 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
const { options } = scenes[i].descriptor;
|
const { options } = scenes[i].descriptor;
|
||||||
const {
|
const {
|
||||||
// By default, we don't want to detach the previous screen of the active one for modals
|
// By default, we don't want to detach the previous screen of the active one for modals
|
||||||
detachPreviousScreen = options.animationPresentation === 'modal' ||
|
detachPreviousScreen = options.presentation === 'modal' ||
|
||||||
options.cardStyleInterpolator === forModalPresentationIOS
|
options.cardStyleInterpolator === forModalPresentationIOS
|
||||||
? i !== scenes.length - 1
|
? i !== scenes.length - 1
|
||||||
: true,
|
: true,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
EdgeInsets,
|
EdgeInsets,
|
||||||
} from 'react-native-safe-area-context';
|
} from 'react-native-safe-area-context';
|
||||||
import {
|
import {
|
||||||
NavigationHelpersContext,
|
|
||||||
StackActions,
|
StackActions,
|
||||||
StackNavigationState,
|
StackNavigationState,
|
||||||
Route,
|
Route,
|
||||||
@@ -418,7 +417,6 @@ export default class StackView extends React.Component<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
state,
|
state,
|
||||||
navigation,
|
|
||||||
keyboardHandlingEnabled,
|
keyboardHandlingEnabled,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
descriptors: _,
|
descriptors: _,
|
||||||
@@ -433,45 +431,43 @@ export default class StackView extends React.Component<Props, State> {
|
|||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationHelpersContext.Provider value={navigation}>
|
<GestureHandlerWrapper style={styles.container}>
|
||||||
<GestureHandlerWrapper style={styles.container}>
|
<SafeAreaProviderCompat>
|
||||||
<SafeAreaProviderCompat>
|
<SafeAreaInsetsContext.Consumer>
|
||||||
<SafeAreaInsetsContext.Consumer>
|
{(insets) => (
|
||||||
{(insets) => (
|
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
|
||||||
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
|
{(props) => (
|
||||||
{(props) => (
|
<HeaderShownContext.Consumer>
|
||||||
<HeaderShownContext.Consumer>
|
{(isParentHeaderShown) => (
|
||||||
{(isParentHeaderShown) => (
|
<CardStack
|
||||||
<CardStack
|
insets={insets as EdgeInsets}
|
||||||
insets={insets as EdgeInsets}
|
isParentHeaderShown={isParentHeaderShown}
|
||||||
isParentHeaderShown={isParentHeaderShown}
|
getPreviousRoute={this.getPreviousRoute}
|
||||||
getPreviousRoute={this.getPreviousRoute}
|
routes={routes}
|
||||||
routes={routes}
|
openingRouteKeys={openingRouteKeys}
|
||||||
openingRouteKeys={openingRouteKeys}
|
closingRouteKeys={closingRouteKeys}
|
||||||
closingRouteKeys={closingRouteKeys}
|
onOpenRoute={this.handleOpenRoute}
|
||||||
onOpenRoute={this.handleOpenRoute}
|
onCloseRoute={this.handleCloseRoute}
|
||||||
onCloseRoute={this.handleCloseRoute}
|
onTransitionStart={this.handleTransitionStart}
|
||||||
onTransitionStart={this.handleTransitionStart}
|
onTransitionEnd={this.handleTransitionEnd}
|
||||||
onTransitionEnd={this.handleTransitionEnd}
|
renderHeader={this.renderHeader}
|
||||||
renderHeader={this.renderHeader}
|
renderScene={this.renderScene}
|
||||||
renderScene={this.renderScene}
|
state={state}
|
||||||
state={state}
|
descriptors={descriptors}
|
||||||
descriptors={descriptors}
|
onGestureStart={this.handleGestureStart}
|
||||||
onGestureStart={this.handleGestureStart}
|
onGestureEnd={this.handleGestureEnd}
|
||||||
onGestureEnd={this.handleGestureEnd}
|
onGestureCancel={this.handleGestureCancel}
|
||||||
onGestureCancel={this.handleGestureCancel}
|
{...rest}
|
||||||
{...rest}
|
{...props}
|
||||||
{...props}
|
/>
|
||||||
/>
|
)}
|
||||||
)}
|
</HeaderShownContext.Consumer>
|
||||||
</HeaderShownContext.Consumer>
|
)}
|
||||||
)}
|
</KeyboardManager>
|
||||||
</KeyboardManager>
|
)}
|
||||||
)}
|
</SafeAreaInsetsContext.Consumer>
|
||||||
</SafeAreaInsetsContext.Consumer>
|
</SafeAreaProviderCompat>
|
||||||
</SafeAreaProviderCompat>
|
</GestureHandlerWrapper>
|
||||||
</GestureHandlerWrapper>
|
|
||||||
</NavigationHelpersContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18225,10 +18225,10 @@ walker@^1.0.7, walker@~1.0.5:
|
|||||||
dependencies:
|
dependencies:
|
||||||
makeerror "1.0.x"
|
makeerror "1.0.x"
|
||||||
|
|
||||||
warn-once@^0.0.1:
|
warn-once@^0.1.0:
|
||||||
version "0.0.1"
|
version "0.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/warn-once/-/warn-once-0.0.1.tgz#71eda54c88f240c4461e5c7a84cac2263caf3a4e"
|
resolved "https://registry.yarnpkg.com/warn-once/-/warn-once-0.1.0.tgz#4f58d89b84f968d0389176aa99e0cf0f14ffd4c8"
|
||||||
integrity sha512-Sh/kR0dQ9Tlr70E2zuR8mZ0yxmN9kGMNfvlwWWRi7frSox2uRC7U659Le8jBIqvjykSbvo9JX9ttsqw4vZPLmA==
|
integrity sha512-recZTSvuaH/On5ZU5ywq66y99lImWqzP93+AiUo9LUwG8gXHW+LJjhOd6REJHm7qb0niYqrEQJvbHSQfuJtTqA==
|
||||||
|
|
||||||
watchpack-chokidar2@^2.0.1:
|
watchpack-chokidar2@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user