Compare commits

...

3 Commits

Author SHA1 Message Date
Satyajit Sahoo
6515fbe2dc chore: publish
- react-navigation-animated-switch@0.6.0
 - react-navigation-drawer@2.5.0
 - react-navigation-material-bottom-tabs@2.3.0
 - @react-navigation/native@3.8.0
 - react-navigation@4.4.0
 - react-navigation-stack@2.8.0
 - react-navigation-tabs@2.9.0
2020-06-25 02:17:38 +02:00
Satyajit Sahoo
454e05b02e feat: sync latest stack and upgrade typescript 2020-06-25 02:15:28 +02:00
Satyajit Sahoo
442ca3e700 fix: improve error message when installing wrong version 2020-06-22 02:25:00 +02:00
56 changed files with 414 additions and 247 deletions

View File

@@ -346,6 +346,7 @@ class MainScreen extends React.Component<any, State> {
if (route.screen || route.path || route.params) {
// @ts-ignore
const { path, params, screen } = route;
// @ts-ignore
const { router } = screen;
const action =
path &&
@@ -386,6 +387,7 @@ class MainScreen extends React.Component<any, State> {
const Navigation = createAppContainer(
createStackNavigator(
// @ts-ignore
{
...ExampleInfo,
Index: {

View File

@@ -91,8 +91,4 @@ const DrawerExample = createDrawerNavigator(
}
);
DrawerExample.navigationOptions = {
headerShown: false,
};
export default DrawerExample;

View File

@@ -42,7 +42,7 @@
"jest": "^25.1.0",
"lerna": "^3.20.2",
"prettier": "^2.0.5",
"typescript": "~3.8.3"
"typescript": "^3.9.5"
},
"resolutions": {
"react": "~16.9.0",

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [0.6.0](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.12...react-navigation-animated-switch@0.6.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/react-navigation/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [0.5.12](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.11...react-navigation-animated-switch@0.5.12) (2020-04-30)
**Note:** Version bump only for package react-navigation-animated-switch

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-animated-switch",
"version": "0.5.12",
"version": "0.6.0",
"description": "Animated switch for React Navigation",
"main": "lib/commonjs/index.js",
"react-native": "lib/module/index.js",
@@ -28,8 +28,8 @@
"react": "~16.9.0",
"react-native": "~0.61.5",
"react-native-reanimated": "~1.7.0",
"react-navigation": "^4.3.9",
"typescript": "~3.8.3"
"react-navigation": "^4.4.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"react": "*",

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.5.0](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.13...react-navigation-drawer@2.5.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/drawer/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [2.4.13](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.12...react-navigation-drawer@2.4.13) (2020-04-30)
**Note:** Version bump only for package react-navigation-drawer

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-drawer",
"version": "2.4.13",
"version": "2.5.0",
"description": "Drawer navigator component for React Navigation",
"main": "lib/commonjs/index.js",
"react-native": "lib/module/index.js",
@@ -49,8 +49,8 @@
"react-native-reanimated": "^1.2.0",
"react-native-screens": "^2.3.0",
"react-native-testing-library": "^1.12.0",
"react-navigation": "^4.3.9",
"typescript": "~3.8.3"
"react-navigation": "^4.4.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"react": "*",

View File

@@ -75,8 +75,11 @@ const DrawerNavigator = (
const drawerRouter = DrawerRouter(routeConfigs, mergedConfig);
// TODO: don't have time to fix it right now
// @ts-ignore
const navigator = createNavigator(DrawerView, drawerRouter, mergedConfig);
const navigator = createNavigator(
DrawerView as any,
drawerRouter,
mergedConfig
);
return navigator;
};

View File

@@ -160,10 +160,6 @@ export default class DrawerView extends React.PureComponent<Props, State> {
drawerOpenProgress={progress}
navigation={this.props.navigation}
descriptors={this.props.descriptors}
contentComponent={this.props.navigationConfig.contentComponent}
contentOptions={this.props.navigationConfig.contentOptions}
drawerPosition={this.props.navigationConfig.drawerPosition}
style={this.props.navigationConfig.style}
{...this.props.navigationConfig}
/>
);

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.3.0](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.12...react-navigation-material-bottom-tabs@2.3.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/react-navigation-material-bottom-tabs/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [2.2.12](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.11...react-navigation-material-bottom-tabs@2.2.12) (2020-04-30)
**Note:** Version bump only for package react-navigation-material-bottom-tabs

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-material-bottom-tabs",
"version": "2.2.12",
"version": "2.3.0",
"description": "Material Bottom Tab Navigation component for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
@@ -48,8 +48,8 @@
"react-native-gesture-handler": "^1.6.0",
"react-native-paper": "^3.1.1",
"react-native-reanimated": "^1.2.0",
"react-navigation": "^4.3.9",
"typescript": "~3.8.3"
"react-navigation": "^4.4.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"react": "*",

View File

@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.8.0](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.13...@react-navigation/native@3.8.0) (2020-06-25)
### Bug Fixes
* improve error message when installing wrong version ([442ca3e](https://github.com/react-navigation/react-navigation-native/commit/442ca3e700c5805cdc5cd02c68f49042887a5054))
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/react-navigation-native/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [3.7.13](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.12...@react-navigation/native@3.7.13) (2020-04-30)
**Note:** Version bump only for package @react-navigation/native

View File

@@ -1,6 +1,6 @@
{
"name": "@react-navigation/native",
"version": "3.7.13",
"version": "3.8.0",
"description": "React Native support for React Navigation",
"main": "lib/commonjs/index.js",
"react-native": "lib/module/index.js",

View File

@@ -43,6 +43,24 @@ module.exports = {
get createNavigationFactory() {
return require('./throwIfWrongVersion').default;
},
get useNavigationBuilder() {
return require('./throwIfWrongVersion').default;
},
get useNavigation() {
return require('./throwIfWrongVersion').default;
},
get useRoute() {
return require('./throwIfWrongVersion').default;
},
get useFocusEffect() {
return require('./throwIfWrongVersion').default;
},
get useIsFocused() {
return require('./throwIfWrongVersion').default;
},
get useNavigationState() {
return require('./throwIfWrongVersion').default;
},
get NavigationContainer() {
return require('./throwIfWrongVersion').default;
},

View File

@@ -1,5 +1,5 @@
export default function () {
throw new Error(
"This version of '@react-navigation/native' is not compatible with React Navigation 5. Make sure you install 5.x version of '@react-navigation/native'."
'Looks like you are trying to use React Navigation 5 APIs, but have React Navigation 4 installed.\n\nMixing React Navigation 4 and 5 is not supported. See the documentation for installation instructions and usage guide for appropriate versions:\n\n- React Navigation 5: https://reactnavigation.org/docs/getting-started\n- React Navigation 4: https://reactnavigation.org/docs/4.x/getting-started'
);
}

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.4.0](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.9...react-navigation@4.4.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/react-navigation/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [4.3.9](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.8...react-navigation@4.3.9) (2020-04-30)

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation",
"version": "4.3.9",
"version": "4.4.0",
"description": "Routing and navigation for your React Native apps",
"main": "src/index.js",
"types": "typescript/react-navigation.d.ts",
@@ -25,7 +25,7 @@
},
"dependencies": {
"@react-navigation/core": "^3.7.6",
"@react-navigation/native": "^3.7.13"
"@react-navigation/native": "^3.8.0"
},
"devDependencies": {
"@types/react": "^16.9.23",
@@ -34,6 +34,6 @@
"react": "~16.9.0",
"react-native": "~0.61.5",
"react-test-renderer": "^16.9.2",
"typescript": "~3.8.3"
"typescript": "^3.9.5"
}
}

View File

@@ -734,7 +734,9 @@ export namespace StackActions {
export const REPLACE: 'Navigation/REPLACE';
export const COMPLETE_TRANSITION: 'Navigation/COMPLETE_TRANSITION';
export function pop(options: NavigationPopActionPayload): NavigationPopAction;
export function pop(
options?: NavigationPopActionPayload
): NavigationPopAction;
export function popToTop(
options?: NavigationPopToTopActionPayload
): NavigationPopToTopAction;
@@ -810,17 +812,15 @@ export interface NavigationDescriptor<
getComponent: () => React.ComponentType;
}
export type NavigationView<
Options,
State,
ScreenProps = unknown
> = React.ComponentType<
{
descriptors: { [key: string]: NavigationDescriptor };
navigationConfig: Options;
screenProps?: ScreenProps;
} & NavigationInjectedProps
>;
export type NavigationView<Options, State, ScreenProps = unknown> =
| React.ComponentType<
{
descriptors: { [key: string]: NavigationDescriptor };
navigationConfig: Options;
screenProps?: ScreenProps;
} & NavigationInjectedProps
>
| React.ComponentType<any>;
export type CreateNavigatorConfig<
NavigatorConfig,

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.8.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.7.0...react-navigation-stack@2.8.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/react-navigation-stack/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
# [2.7.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.6.0...react-navigation-stack@2.7.0) (2020-06-08)

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-stack",
"version": "2.7.0",
"version": "2.8.0",
"description": "Stack navigator component for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
@@ -45,7 +45,7 @@
"devDependencies": {
"@react-native-community/bob": "^0.10.0",
"@react-native-community/masked-view": "^0.1.7",
"@react-navigation/stack": "^5.5.1",
"@react-navigation/stack": "^5.6.0",
"@types/color": "^3.0.1",
"@types/react": "^16.9.23",
"@types/react-native": "^0.61.22",
@@ -56,9 +56,9 @@
"react-native-gesture-handler": "^1.6.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.3.0",
"react-navigation": "^4.3.9",
"react-navigation": "^4.4.0",
"react-test-renderer": "~16.9.0",
"typescript": "~3.8.3"
"typescript": "^3.9.5"
},
"peerDependencies": {
"@react-native-community/masked-view": ">=0.1.0",

View File

@@ -1,6 +1,6 @@
diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/index.tsx
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/index.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/index.tsx 2020-06-24 23:16:17.000000000 +0200
@@ -3,11 +3,6 @@
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
@@ -28,7 +28,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
StackHeaderLeftButtonProps,
StackHeaderTitleProps,
diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx src/vendor/navigators/createStackNavigator.tsx
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-06-08 11:22:56.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
@@ -1,96 +0,0 @@
-import * as React from 'react';
@@ -44,7 +44,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
- StackActions,
-} from '@react-navigation/native';
-import StackView from '../views/Stack/StackView';
-import {
-import type {
- StackNavigationConfig,
- StackNavigationOptions,
- StackNavigationEventMap,
@@ -128,12 +128,12 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
- typeof StackNavigator
->(StackNavigator);
diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/types.tsx
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/types.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/types.tsx 2020-06-24 23:18:40.000000000 +0200
@@ -8,15 +8,28 @@
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import {
import type { EdgeInsets } from 'react-native-safe-area-context';
import type {
+ NavigationRoute,
+ NavigationState,
+ NavigationScreenProp,
@@ -261,28 +261,40 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
};
export type StackNavigationConfig = {
diff -Naur ../../node_modules/@react-navigation/stack/src/utils/PreviousSceneContext.tsx src/vendor/utils/PreviousSceneContext.tsx
--- ../../node_modules/@react-navigation/stack/src/utils/PreviousSceneContext.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/utils/PreviousSceneContext.tsx 2020-06-24 23:26:38.000000000 +0200
@@ -1,6 +1,5 @@
import * as React from 'react';
-import type { Route } from '@react-navigation/native';
-import type { Scene } from '../types';
+import type { Route, Scene } from '../types';
const PreviousSceneContext = React.createContext<
Scene<Route<string>> | undefined
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx src/vendor/views/Header/Header.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/Header.tsx 2020-06-08 11:23:27.000000000 +0200
@@ -1,12 +1,14 @@
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/Header.tsx 2020-06-24 23:33:25.000000000 +0200
@@ -1,12 +1,15 @@
import * as React from 'react';
-import { StackActions } from '@react-navigation/native';
+import { Dimensions } from 'react-native';
+import { StackActions } from 'react-navigation';
+import { getStatusBarHeight } from 'react-native-iphone-x-helper';
+
+import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
-import HeaderSegment from './HeaderSegment';
+import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
import HeaderTitle from './HeaderTitle';
import debounce from '../../utils/debounce';
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
import type { StackHeaderProps, StackHeaderTitleProps } from '../../types';
-export default React.memo(function Header(props: StackHeaderProps) {
+const Header = React.memo(function Header(props: StackHeaderProps) {
const {
scene,
previous,
@@ -22,7 +24,7 @@
@@ -22,7 +25,7 @@
? options.headerTitle
: options.title !== undefined
? options.title
@@ -291,7 +303,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
let leftLabel;
@@ -38,18 +40,13 @@
@@ -38,17 +41,18 @@
? o.headerTitle
: o.title !== undefined
? o.title
@@ -307,12 +319,16 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
- ...StackActions.pop(),
- source: scene.route.key,
- });
- }
+ navigation.dispatch(StackActions.pop({ key: scene.route.key }));
+ if (navigation.isFirstRouteInParent()) {
+ // If we're the first route, we're going back to a parent navigator
+ // So we can't specify a key here
+ navigation.dispatch(StackActions.pop());
+ } else {
+ navigation.dispatch(StackActions.pop({ key: scene.route.key }));
}
}, 50),
[navigation, scene.route.key]
);
@@ -64,7 +61,10 @@
@@ -64,7 +68,10 @@
leftLabel={leftLabel}
headerTitle={
typeof options.headerTitle !== 'function'
@@ -324,7 +340,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
: options.headerTitle
}
onGoBack={previous ? goBack : undefined}
@@ -72,3 +72,18 @@
@@ -72,3 +79,18 @@
/>
);
});
@@ -344,8 +360,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
+
+export default Header;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-06-24 23:21:49.000000000 +0200
@@ -8,9 +8,9 @@
StyleSheet,
LayoutChangeEvent,
@@ -354,12 +370,12 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
import MaskedView from '../MaskedView';
import { TouchableItem } from '../TouchableItem';
+import useTheme from '../../../utils/useTheme';
import { StackHeaderLeftButtonProps } from '../../types';
import type { StackHeaderLeftButtonProps } from '../../types';
type Props = StackHeaderLeftButtonProps;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx src/vendor/views/Header/HeaderBackground.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-06-24 23:16:23.000000000 +0200
@@ -7,7 +7,7 @@
StyleProp,
ViewStyle,
@@ -370,8 +386,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
type Props = ViewProps & {
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx src/vendor/views/Header/HeaderContainer.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-06-24 23:21:29.000000000 +0200
@@ -1,11 +1,6 @@
import * as React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
@@ -382,18 +398,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
- ParamListBase,
-} from '@react-navigation/native';
+import { NavigationContext } from 'react-navigation';
import { EdgeInsets } from 'react-native-safe-area-context';
import type { EdgeInsets } from 'react-native-safe-area-context';
import Header from './Header';
@@ -17,6 +12,7 @@
} from '../../TransitionConfigs/HeaderStyleInterpolators';
import HeaderShownContext from '../../utils/HeaderShownContext';
import {
+ Route,
@@ -19,6 +14,7 @@
import PreviousSceneContext from '../../utils/PreviousSceneContext';
import type {
Layout,
+ Route,
Scene,
StackHeaderStyleInterpolator,
@@ -117,9 +113,7 @@
StackNavigationProp,
@@ -109,9 +105,7 @@
insets,
scene,
previous,
@@ -404,7 +420,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
styleInterpolator:
mode === 'float'
? isHeaderStatic
@@ -138,7 +132,7 @@
@@ -130,7 +124,7 @@
key={scene.route.key}
value={scene.descriptor.navigation}
>
@@ -413,7 +429,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
<View
onLayout={
onContentHeightChange
@@ -164,7 +158,7 @@
@@ -156,7 +150,7 @@
>
{header !== undefined ? header(props) : <Header {...props} />}
</View>
@@ -423,14 +439,14 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
);
})}
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx src/vendor/views/Header/HeaderSegment.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-06-24 23:20:58.000000000 +0200
@@ -8,7 +8,7 @@
ViewStyle,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
-import { Route } from '@react-navigation/native';
+import { NavigationRoute } from 'react-navigation';
import type { EdgeInsets } from 'react-native-safe-area-context';
-import type { Route } from '@react-navigation/native';
+import type { NavigationRoute } from 'react-navigation';
import HeaderBackButton from './HeaderBackButton';
import HeaderBackground from './HeaderBackground';
import memoize from '../../utils/memoize';
@@ -444,8 +460,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSeg
};
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx src/vendor/views/Header/HeaderTitle.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-06-24 23:16:23.000000000 +0200
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Animated, StyleSheet, Platform } from 'react-native';
@@ -455,8 +471,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTit
type Props = Omit<React.ComponentProps<typeof Animated.Text>, 'key'> & {
tintColor?: string;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx src/vendor/views/Stack/Card.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Stack/Card.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Stack/Card.tsx 2020-06-24 23:16:23.000000000 +0200
@@ -146,7 +146,7 @@
private interactionHandle: number | undefined;
@@ -467,45 +483,46 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx s
private animate = ({
closing,
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx src/vendor/views/Stack/CardContainer.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Stack/CardContainer.tsx 2020-06-08 11:23:27.000000000 +0200
@@ -1,11 +1,12 @@
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Stack/CardContainer.tsx 2020-06-24 23:20:38.000000000 +0200
@@ -1,12 +1,13 @@
import * as React from 'react';
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
-import { Route, useTheme } from '@react-navigation/native';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import Card from './Card';
import HeaderHeightContext from '../../utils/HeaderHeightContext';
import HeaderShownContext from '../../utils/HeaderShownContext';
import PreviousSceneContext from '../../utils/PreviousSceneContext';
+import useTheme from '../../../utils/useTheme';
import {
import type {
+ Route,
Scene,
Layout,
StackHeaderMode,
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx src/vendor/views/Stack/CardStack.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Stack/CardStack.tsx 2020-06-08 11:23:27.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Stack/CardStack.tsx 2020-06-24 23:20:16.000000000 +0200
@@ -7,7 +7,7 @@
Platform,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
-import { Route, StackNavigationState } from '@react-navigation/native';
+import { NavigationState as StackNavigationState } from 'react-navigation';
import type { EdgeInsets } from 'react-native-safe-area-context';
-import type { Route, StackNavigationState } from '@react-navigation/native';
+import type { NavigationState as StackNavigationState } from 'react-navigation';
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
@@ -22,6 +22,7 @@
import HeaderShownContext from '../../utils/HeaderShownContext';
import getDistanceForDirection from '../../utils/getDistanceForDirection';
import {
+ Route,
@@ -25,6 +25,7 @@
Layout,
StackHeaderMode,
StackCardMode,
+ Route,
Scene,
StackDescriptorMap,
StackNavigationOptions,
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx src/vendor/views/Stack/StackView.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-06-08 11:22:56.000000000 +0200
+++ src/vendor/views/Stack/StackView.tsx 2020-06-08 11:23:40.000000000 +0200
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-06-24 23:11:52.000000000 +0200
+++ src/vendor/views/Stack/StackView.tsx 2020-06-24 23:19:46.000000000 +0200
@@ -2,11 +2,11 @@
import { View, Platform, StyleSheet } from 'react-native';
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
@@ -525,7 +542,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
@@ -16,6 +16,7 @@
} from '../Header/HeaderContainer';
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
import {
import type {
+ Route,
StackNavigationHelpers,
StackNavigationConfig,
@@ -661,7 +678,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
navigation,
keyboardHandlingEnabled,
mode = 'card',
@@ -425,7 +454,7 @@
@@ -427,7 +456,7 @@
} = this.state;
return (
@@ -670,7 +687,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
<GestureHandlerWrapper style={styles.container}>
<SafeAreaProviderCompat>
<SafeAreaConsumer>
@@ -458,7 +487,7 @@
@@ -460,7 +489,7 @@
</SafeAreaConsumer>
</SafeAreaProviderCompat>
</GestureHandlerWrapper>

View File

@@ -9,7 +9,7 @@ import createAppContainer, {
_TESTING_ONLY_reset_container_count,
// @ts-ignore
} from '../../../../native/src/createAppContainer';
import { StackNavigationProp } from '../../vendor/types';
import type { StackNavigationProp } from '../../vendor/types';
const NavigationTestUtils = {
resetInternalState: _TESTING_ONLY_reset_container_count,

View File

@@ -136,6 +136,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
}
}
>
<View
collapsable={false}
style={
Object {
"opacity": 1,
}
}
/>
<View
accessibilityElementsHidden={false}
closing={false}
@@ -188,7 +196,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
style={
Object {
"flex": 1,
"opacity": 1,
}
}
>
@@ -296,6 +303,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
}
}
>
<View
collapsable={false}
style={
Object {
"opacity": 1,
}
}
/>
<View
accessibilityElementsHidden={false}
closing={false}
@@ -349,7 +364,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
Object {
"flex": 1,
"marginTop": 0,
"opacity": 1,
}
}
>

View File

@@ -153,6 +153,14 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
}
}
>
<View
collapsable={false}
style={
Object {
"opacity": 1,
}
}
/>
<View
accessibilityElementsHidden={false}
closing={false}
@@ -205,7 +213,6 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
style={
Object {
"flex": 1,
"opacity": 1,
}
}
>
@@ -434,6 +441,14 @@ exports[`StackNavigator renders successfully 1`] = `
}
}
>
<View
collapsable={false}
style={
Object {
"opacity": 1,
}
}
/>
<View
accessibilityElementsHidden={false}
closing={false}
@@ -486,7 +501,6 @@ exports[`StackNavigator renders successfully 1`] = `
style={
Object {
"flex": 1,
"opacity": 1,
}
}
>

View File

@@ -7,7 +7,7 @@ import {
CreateNavigatorConfig,
} from 'react-navigation';
import StackView from '../views/StackView';
import {
import type {
StackNavigationConfig,
StackNavigationOptions,
StackNavigationProp,

View File

@@ -1,10 +1,13 @@
import {
import type {
NavigationRoute,
NavigationParams,
NavigationScreenConfig,
SupportedThemes,
} from 'react-navigation';
import { StackNavigationProp, StackNavigationOptions } from './vendor/types';
import type {
StackNavigationProp,
StackNavigationOptions,
} from './vendor/types';
export type NavigationStackScreenProps<
Params = NavigationParams,

View File

@@ -1,5 +1,8 @@
import { StyleProp, ViewStyle } from 'react-native';
import { StackNavigationOptions, StackNavigationConfig } from '../vendor/types';
import type { StyleProp, ViewStyle } from 'react-native';
import type {
StackNavigationOptions,
StackNavigationConfig,
} from '../vendor/types';
type Validation = {
message: string;

View File

@@ -1,5 +1,5 @@
import { EdgeInsets } from 'react-native-safe-area-context';
import { StackNavigationOptions } from '../vendor/types';
import type { EdgeInsets } from 'react-native-safe-area-context';
import type { StackNavigationOptions } from '../vendor/types';
type Validation = {
check: (o: Record<string, any>) => boolean;

View File

@@ -1,7 +1,7 @@
import { Animated } from 'react-native';
import { isIphoneX } from 'react-native-iphone-x-helper';
import conditional from '../utils/conditional';
import {
import type {
StackCardInterpolationProps,
StackCardInterpolatedStyle,
} from '../types';

View File

@@ -1,5 +1,5 @@
import { Animated, I18nManager } from 'react-native';
import {
import type {
StackHeaderInterpolationProps,
StackHeaderInterpolatedStyle,
} from '../types';

View File

@@ -1,3 +1,4 @@
import { Platform } from 'react-native';
import {
forHorizontalIOS,
forVerticalIOS,
@@ -14,8 +15,7 @@ import {
FadeOutToBottomAndroidSpec,
FadeInFromBottomAndroidSpec,
} from './TransitionSpecs';
import { TransitionPreset } from '../types';
import { Platform } from 'react-native';
import type { TransitionPreset } from '../types';
const ANDROID_VERSION_PIE = 28;

View File

@@ -1,5 +1,5 @@
import { Easing } from 'react-native';
import { TransitionSpec } from '../types';
import type { TransitionSpec } from '../types';
/**
* Exact values from UINavigationController's animation configuration.

View File

@@ -1,13 +1,13 @@
import * as React from 'react';
import {
import type * as React from 'react';
import type {
Animated,
StyleProp,
TextStyle,
ViewStyle,
LayoutChangeEvent,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import {
import type { EdgeInsets } from 'react-native-safe-area-context';
import type {
NavigationRoute,
NavigationState,
NavigationScreenProp,

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { StackCardInterpolationProps } from '../types';
import type { StackCardInterpolationProps } from '../types';
export default React.createContext<StackCardInterpolationProps | undefined>(
undefined

View File

@@ -0,0 +1,8 @@
import * as React from 'react';
import type { Route, Scene } from '../types';
const PreviousSceneContext = React.createContext<
Scene<Route<string>> | undefined
>(undefined);
export default PreviousSceneContext;

View File

@@ -1,5 +1,5 @@
import getInvertedMultiplier from './getInvertedMultiplier';
import { GestureDirection, Layout } from '../types';
import type { GestureDirection, Layout } from '../types';
export default function getDistanceForDirection(
layout: Layout,

View File

@@ -1,5 +1,5 @@
import { I18nManager } from 'react-native';
import { GestureDirection } from '../types';
import type { GestureDirection } from '../types';
export default function getInvertedMultiplier(
gestureDirection: GestureDirection

View File

@@ -39,7 +39,7 @@ export default class BorderlessButton extends React.Component<Props> {
const { children, style, enabled, ...rest } = this.props;
return (
// @ts-ignore
// @ts-expect-error: the Animated.createAnimatedComponent types don't work properly
<AnimatedBaseButton
{...rest}
onActiveStateChange={this.handleActiveStateChange}

View File

@@ -4,9 +4,10 @@ import { StackActions } from 'react-navigation';
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
import HeaderTitle from './HeaderTitle';
import debounce from '../../utils/debounce';
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
import type { StackHeaderProps, StackHeaderTitleProps } from '../../types';
const Header = React.memo(function Header(props: StackHeaderProps) {
const {
@@ -46,7 +47,13 @@ const Header = React.memo(function Header(props: StackHeaderProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
const goBack = React.useCallback(
debounce(() => {
navigation.dispatch(StackActions.pop({ key: scene.route.key }));
if (navigation.isFirstRouteInParent()) {
// If we're the first route, we're going back to a parent navigator
// So we can't specify a key here
navigation.dispatch(StackActions.pop());
} else {
navigation.dispatch(StackActions.pop({ key: scene.route.key }));
}
}, 50),
[navigation, scene.route.key]
);

View File

@@ -11,7 +11,7 @@ import {
import MaskedView from '../MaskedView';
import { TouchableItem } from '../TouchableItem';
import useTheme from '../../../utils/useTheme';
import { StackHeaderLeftButtonProps } from '../../types';
import type { StackHeaderLeftButtonProps } from '../../types';
type Props = StackHeaderLeftButtonProps;

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import { NavigationContext } from 'react-navigation';
import { EdgeInsets } from 'react-native-safe-area-context';
import type { EdgeInsets } from 'react-native-safe-area-context';
import Header from './Header';
import {
@@ -11,9 +11,10 @@ import {
forSlideRight,
} from '../../TransitionConfigs/HeaderStyleInterpolators';
import HeaderShownContext from '../../utils/HeaderShownContext';
import {
Route,
import PreviousSceneContext from '../../utils/PreviousSceneContext';
import type {
Layout,
Route,
Scene,
StackHeaderStyleInterpolator,
StackNavigationProp,
@@ -25,9 +26,10 @@ export type Props = {
layout: Layout;
insets: EdgeInsets;
scenes: (Scene<Route<string>> | undefined)[];
getPreviousRoute: (props: {
getPreviousScene: (props: {
route: Route<string>;
}) => Route<string> | undefined;
index: number;
}) => Scene<Route<string>> | undefined;
getFocusedRoute: () => Route<string>;
onContentHeightChange?: (props: {
route: Route<string>;
@@ -43,8 +45,8 @@ export default function HeaderContainer({
scenes,
layout,
insets,
getPreviousScene,
getFocusedRoute,
getPreviousRoute,
onContentHeightChange,
gestureDirection,
styleInterpolator,
@@ -52,6 +54,7 @@ export default function HeaderContainer({
}: Props) {
const focusedRoute = getFocusedRoute();
const isParentHeaderShown = React.useContext(HeaderShownContext);
const parentPreviousScene = React.useContext(PreviousSceneContext);
return (
<View pointerEvents="box-none" style={style}>
@@ -71,22 +74,11 @@ export default function HeaderContainer({
}
const isFocused = focusedRoute.key === scene.route.key;
const previousRoute = getPreviousRoute({ route: scene.route });
let previous;
if (previousRoute) {
// The previous scene will be shortly before the current scene in the array
// So loop back from current index to avoid looping over the full array
for (let j = i - 1; j >= 0; j--) {
const s = self[j];
if (s && s.route.key === previousRoute.key) {
previous = s;
break;
}
}
}
const previous =
getPreviousScene({
route: scene.route,
index: i,
}) ?? parentPreviousScene;
// If the screen is next to a headerless screen, we need to make the header appear static
// This makes the header look like it's moving with the screen

View File

@@ -7,12 +7,12 @@ import {
Platform,
ViewStyle,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import { NavigationRoute } from 'react-navigation';
import type { EdgeInsets } from 'react-native-safe-area-context';
import type { NavigationRoute } from 'react-navigation';
import HeaderBackButton from './HeaderBackButton';
import HeaderBackground from './HeaderBackground';
import memoize from '../../utils/memoize';
import {
import type {
Layout,
StackHeaderStyleInterpolator,
StackHeaderLeftButtonProps,
@@ -62,7 +62,6 @@ export const getDefaultHeaderHeight = (
let headerHeight;
if (Platform.OS === 'ios') {
// @ts-ignore
if (isLandscape && !Platform.isPad) {
headerHeight = 32;
} else {
@@ -208,7 +207,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
borderTopStartRadius,
borderTopWidth,
borderWidth,
// @ts-ignore: web support for shadow
// @ts-expect-error: web support for shadow
boxShadow,
elevation,
shadowColor,
@@ -250,7 +249,6 @@ export default class HeaderSegment extends React.Component<Props, State> {
borderTopStartRadius,
borderTopWidth,
borderWidth,
// @ts-ignore
boxShadow,
elevation,
shadowColor,
@@ -265,9 +263,9 @@ export default class HeaderSegment extends React.Component<Props, State> {
// So we need to filter them out
// Users can use `null` instead
for (const styleProp in safeStyles) {
// @ts-ignore
// @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles
if (safeStyles[styleProp] === undefined) {
// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete safeStyles[styleProp];
}

View File

@@ -35,7 +35,11 @@ export default class KeyboardManager extends React.Component<Props> {
this.clearKeyboardTimeout();
const input = TextInput.State.currentlyFocusedField();
// @ts-expect-error: currentlyFocusedInput is pretty new, so not in the type definitions
const input = TextInput.State.currentlyFocusedInput
? // @ts-expect-error
TextInput.State.currentlyFocusedInput()
: TextInput.State.currentlyFocusedField();
// When a page change begins, blur the currently focused input
TextInput.State.blurTextInput(input);

View File

@@ -16,7 +16,6 @@ try {
}
const isMaskedViewAvailable =
// @ts-ignore
UIManager.getViewManagerConfig('RNCMaskedView') != null;
export default function MaskedView({ children, ...rest }: Props) {

View File

@@ -1,4 +1,4 @@
import * as React from 'react';
import type * as React from 'react';
type Props = {
maskElement: React.ReactElement;

View File

@@ -23,7 +23,7 @@ class WebScreen extends React.Component<
return (
<View
// @ts-ignore
// @ts-expect-error: hidden exists on web, but not in React Native
hidden={!active}
style={[style, { display: active ? 'flex' : 'none' }]}
{...rest}
@@ -54,16 +54,16 @@ export const MaybeScreen = ({
...rest
}: ViewProps & {
enabled: boolean;
active: number | Animated.AnimatedInterpolation;
active: 0 | 1 | Animated.AnimatedInterpolation;
children: React.ReactNode;
}) => {
if (enabled && Platform.OS === 'web') {
// @ts-ignore
// @ts-expect-error: the Animated.createAnimatedComponent types don't work properly
return <AnimatedWebScreen active={active} {...rest} />;
}
if (enabled && Screens && Screens.screensEnabled()) {
// @ts-ignore
// @ts-expect-error: stackPresentation is incorrectly marked as required
return <Screens.Screen active={active} {...rest} />;
}

View File

@@ -9,7 +9,7 @@ import {
Platform,
InteractionManager,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import type { EdgeInsets } from 'react-native-safe-area-context';
import Color from 'color';
import CardSheet from './CardSheet';
@@ -22,7 +22,7 @@ import CardAnimationContext from '../../utils/CardAnimationContext';
import getDistanceForDirection from '../../utils/getDistanceForDirection';
import getInvertedMultiplier from '../../utils/getInvertedMultiplier';
import memoize from '../../utils/memoize';
import {
import type {
TransitionSpec,
StackCardStyleInterpolator,
GestureDirection,
@@ -493,14 +493,19 @@ export default class Card extends React.Component<Props> {
? Color(backgroundColor).alpha() === 0
: false;
// This is a dummy style that doesn't actually change anything visually.
// Animated needs the animated value to be used somewhere, otherwise things don't update properly.
// If we disable animations and hide header, it could end up making the value unused.
// So we have this dummy style that will always be used regardless of what else changed.
const dummyStyle = { opacity: Animated.diffClamp(current, 1, 1) };
return (
<CardAnimationContext.Provider value={animationContext}>
<Animated.View
style={{
// This is a dummy style that doesn't actually change anything visually.
// Animated needs the animated value to be used somewhere, otherwise things don't update properly.
// If we disable animations and hide header, it could end up making the value unused.
// So we have this dummy style that will always be used regardless of what else changed.
opacity: current,
}}
// Make sure that this view isn't removed. If this view is removed, our style with animated value won't apply
collapsable={false}
/>
<View pointerEvents="box-none" {...rest}>
{overlayEnabled ? (
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
@@ -508,12 +513,7 @@ export default class Card extends React.Component<Props> {
</View>
) : null}
<Animated.View
style={[
styles.container,
dummyStyle,
containerStyle,
customContainerStyle,
]}
style={[styles.container, containerStyle, customContainerStyle]}
pointerEvents="box-none"
>
<PanGestureHandler

View File

@@ -1,11 +1,12 @@
import * as React from 'react';
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import Card from './Card';
import HeaderHeightContext from '../../utils/HeaderHeightContext';
import HeaderShownContext from '../../utils/HeaderShownContext';
import PreviousSceneContext from '../../utils/PreviousSceneContext';
import useTheme from '../../../utils/useTheme';
import {
import type {
Route,
Scene,
Layout,
@@ -21,7 +22,6 @@ type Props = TransitionPreset & {
closing: boolean;
layout: Layout;
gesture: Animated.Value;
previousScene?: Scene<Route<string>>;
scene: Scene<Route<string>>;
safeAreaInsetTop: number;
safeAreaInsetRight: number;
@@ -31,9 +31,10 @@ type Props = TransitionPreset & {
cardOverlayEnabled?: boolean;
cardShadowEnabled?: boolean;
cardStyle?: StyleProp<ViewStyle>;
getPreviousRoute: (props: {
getPreviousScene: (props: {
route: Route<string>;
}) => Route<string> | undefined;
index: number;
}) => Scene<Route<string>> | undefined;
getFocusedRoute: () => Route<string>;
renderHeader: (props: HeaderContainerProps) => React.ReactNode;
renderScene: (props: { route: Route<string> }) => React.ReactNode;
@@ -80,7 +81,7 @@ function CardContainer({
gestureEnabled,
gestureResponseDistance,
gestureVelocityImpact,
getPreviousRoute,
getPreviousScene,
getFocusedRoute,
mode,
headerMode,
@@ -98,7 +99,6 @@ function CardContainer({
onPageChangeStart,
onTransitionEnd,
onTransitionStart,
previousScene,
renderHeader,
renderScene,
safeAreaInsetBottom,
@@ -146,8 +146,7 @@ function CardContainer({
);
React.useEffect(() => {
// `addListener` may not exist on web and older versions of React Native
// @ts-ignore
// @ts-expect-error: AnimatedInterpolation optionally has addListener, but the type defs don't think so
const listener = scene.progress.next?.addListener?.(
({ value }: { value: number }) => {
setPointerEvents(value <= EPSILON ? 'box-none' : 'none');
@@ -156,7 +155,7 @@ function CardContainer({
return () => {
if (listener) {
// @ts-ignore
// @ts-expect-error: AnimatedInterpolation optionally has removedListener, but the type defs don't think so
scene.progress.next?.removeListener?.(listener);
}
};
@@ -164,6 +163,7 @@ function CardContainer({
const isParentHeaderShown = React.useContext(HeaderShownContext);
const isCurrentHeaderShown = headerMode !== 'none' && headerShown !== false;
const previousScene = getPreviousScene({ route: scene.route, index });
return (
<Card
@@ -198,13 +198,15 @@ function CardContainer({
>
<View style={styles.container}>
<View style={styles.scene}>
<HeaderShownContext.Provider
value={isParentHeaderShown || isCurrentHeaderShown}
>
<HeaderHeightContext.Provider value={headerHeight}>
{renderScene({ route: scene.route })}
</HeaderHeightContext.Provider>
</HeaderShownContext.Provider>
<PreviousSceneContext.Provider value={previousScene}>
<HeaderShownContext.Provider
value={isParentHeaderShown || isCurrentHeaderShown}
>
<HeaderHeightContext.Provider value={headerHeight}>
{renderScene({ route: scene.route })}
</HeaderHeightContext.Provider>
</HeaderShownContext.Provider>
</PreviousSceneContext.Provider>
</View>
{headerMode === 'screen'
? renderHeader({
@@ -212,7 +214,7 @@ function CardContainer({
layout,
insets,
scenes: [previousScene, scene],
getPreviousRoute,
getPreviousScene,
getFocusedRoute,
gestureDirection,
styleInterpolator: headerStyleInterpolator,

View File

@@ -6,12 +6,12 @@ import {
Dimensions,
Platform,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import { NavigationState as StackNavigationState } from 'react-navigation';
import type { EdgeInsets } from 'react-native-safe-area-context';
import type { NavigationState as StackNavigationState } from 'react-navigation';
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import CardContainer from './CardContainer';
import {
DefaultTransition,
@@ -21,11 +21,11 @@ import { forNoAnimation as forNoAnimationHeader } from '../../TransitionConfigs/
import { forNoAnimation as forNoAnimationCard } from '../../TransitionConfigs/CardStyleInterpolators';
import HeaderShownContext from '../../utils/HeaderShownContext';
import getDistanceForDirection from '../../utils/getDistanceForDirection';
import {
Route,
import type {
Layout,
StackHeaderMode,
StackCardMode,
Route,
Scene,
StackDescriptorMap,
StackNavigationOptions,
@@ -244,7 +244,7 @@ export default class CardStack extends React.Component<Props, State> {
if (
oldScene &&
scene.__memo.every((it, i) => {
// @ts-ignore
// @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
return oldScene.__memo[i] === it;
})
) {
@@ -337,6 +337,33 @@ export default class CardStack extends React.Component<Props, State> {
return state.routes[state.index];
};
private getPreviousScene = ({
route,
index,
}: {
route: Route<string>;
index: number;
}) => {
const previousRoute = this.props.getPreviousRoute({ route });
let previous: Scene<Route<string>> | undefined;
if (previousRoute) {
// The previous scene will be shortly before the current scene in the array
// So loop back from current index to avoid looping over the full array
for (let j = index - 1; j >= 0; j--) {
const s = this.state.scenes[j];
if (s && s.route.key === previousRoute.key) {
previous = s;
break;
}
}
}
return previous;
};
render() {
const {
mode,
@@ -347,7 +374,6 @@ export default class CardStack extends React.Component<Props, State> {
closingRouteKeys,
onOpenRoute,
onCloseRoute,
getPreviousRoute,
getGesturesEnabled,
renderHeader,
renderScene,
@@ -415,7 +441,7 @@ export default class CardStack extends React.Component<Props, State> {
layout,
insets: { top, right, bottom, left },
scenes,
getPreviousRoute,
getPreviousScene: this.getPreviousScene,
getFocusedRoute: this.getFocusedRoute,
onContentHeightChange: this.handleHeaderLayout,
gestureDirection:
@@ -521,25 +547,6 @@ export default class CardStack extends React.Component<Props, State> {
left: safeAreaInsetLeft = insets.left,
} = safeAreaInsets || {};
const previousRoute = getPreviousRoute({
route: scene.route,
});
let previousScene = scenes[index - 1];
if (previousRoute) {
// The previous scene will be shortly before the current scene in the array
// So loop back from current index to avoid looping over the full array
for (let j = index - 1; j >= 0; j--) {
const s = scenes[j];
if (s && s.route.key === previousRoute.key) {
previousScene = s;
break;
}
}
}
const headerHeight =
headerMode !== 'none' && headerShown !== false
? headerHeights[route.key]
@@ -561,7 +568,6 @@ export default class CardStack extends React.Component<Props, State> {
layout={layout}
gesture={gesture}
scene={scene}
previousScene={previousScene}
safeAreaInsetTop={safeAreaInsetTop}
safeAreaInsetRight={safeAreaInsetRight}
safeAreaInsetBottom={safeAreaInsetBottom}
@@ -576,7 +582,7 @@ export default class CardStack extends React.Component<Props, State> {
gestureResponseDistance={gestureResponseDistance}
headerHeight={headerHeight}
onHeaderHeightChange={this.handleHeaderLayout}
getPreviousRoute={getPreviousRoute}
getPreviousScene={this.getPreviousScene}
getFocusedRoute={this.getFocusedRoute}
mode={mode}
headerMode={headerMode}

View File

@@ -15,7 +15,7 @@ import HeaderContainer, {
Props as HeaderContainerProps,
} from '../Header/HeaderContainer';
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
import {
import type {
Route,
StackNavigationHelpers,
StackNavigationConfig,
@@ -443,6 +443,8 @@ export default class StackView extends React.Component<Props, State> {
headerMode = mode === 'card' && Platform.OS === 'ios'
? 'float'
: 'screen',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
descriptors: _,
...rest
} = this.props;

View File

@@ -2,7 +2,7 @@ import * as React from 'react';
import validateDeprecatedOptions from '../utils/validateDeprecatedOptions';
import validateDeprecatedConfig from '../utils/validateDeprecatedConfig';
import StackViewBase from '../vendor/views/Stack/StackView';
import {
import type {
StackNavigationHelpers,
StackNavigationConfig,
StackDescriptorMap,

View File

@@ -1,6 +1,6 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"paths": {}
"paths": {},
}
}

View File

@@ -4,6 +4,7 @@
{ "path": "../react-navigation" }
],
"compilerOptions": {
"outDir": "./lib/typescript"
"outDir": "./lib/typescript",
"importsNotUsedAsValues": "error",
}
}

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.9.0](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.13...react-navigation-tabs@2.9.0) (2020-06-25)
### Features
* sync latest stack and upgrade typescript ([454e05b](https://github.com/react-navigation/tabs/commit/454e05b02ec97f053b381fdc801df899d8c93cb6))
## [2.8.13](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.12...react-navigation-tabs@2.8.13) (2020-04-30)
**Note:** Version bump only for package react-navigation-tabs

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-tabs",
"version": "2.8.13",
"version": "2.9.0",
"description": "Tab Navigation components for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
@@ -56,8 +56,8 @@
"react-native-gesture-handler": "^1.6.0",
"react-native-reanimated": "^1.2.0",
"react-native-tab-view": "^2.13.0",
"react-navigation": "^4.3.9",
"typescript": "~3.8.3"
"react-navigation": "^4.4.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"react": "*",

View File

@@ -3202,10 +3202,10 @@
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.7.tgz#a65ce0702f55cb67fd777995de6fc7b3e5781903"
integrity sha512-9KbP7LTLFz9dx1heURJbO6nuVMdSjDez8znlrUzaB1nUwKVsTTwlKRuHxGUYIIkReLWrJQeCv9tidy+84z2eCw==
"@react-navigation/stack@^5.5.1":
version "5.5.1"
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.5.1.tgz#95efa28edbfd1323e5ad9f01f539d43ffad8decc"
integrity sha512-oU2FEm+Ba6jMd5VA2WnuNfCO2HlZmGhrEX9yjBCyFj7fFCG1SB7WJdKLhZShtx3KxG/qWKphICeTLlYvkHdSpQ==
"@react-navigation/stack@^5.6.0":
version "5.6.0"
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.6.0.tgz#c307559ab6ba380f977f7f74efbe861bcbbdcf4b"
integrity sha512-e5uU37qgi9cXqOac8P2oFAj+4ZY7dI2kt04jg5+psAYN0Coawk6oyowBpBy6FsMBHMQv/p8J97Hc6eUnTwgzQw==
dependencies:
color "^3.1.2"
react-native-iphone-x-helper "^1.2.1"
@@ -16708,10 +16708,10 @@ typescript@3.7.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.3.tgz#b36840668a16458a7025b9eabfad11b66ab85c69"
integrity sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==
typescript@~3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
typescript@^3.9.5:
version "3.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==
ua-parser-js@^0.7.18, ua-parser-js@^0.7.19:
version "0.7.21"