mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-13 09:30:30 +08:00
Compare commits
41 Commits
@react-nav
...
react-navi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b55493e76 | ||
|
|
ebe70f51fb | ||
|
|
256e5aec2a | ||
|
|
707bea3cba | ||
|
|
6bdc1e9e5f | ||
|
|
b3db099a00 | ||
|
|
1f5000e86b | ||
|
|
6390aacd07 | ||
|
|
20e2625f35 | ||
|
|
162e225fa4 | ||
|
|
ce9991ffff | ||
|
|
3bb21e256f | ||
|
|
f1a06e2f92 | ||
|
|
c0763fca16 | ||
|
|
62da341b67 | ||
|
|
09a10faa44 | ||
|
|
b9ecbd222d | ||
|
|
a57e47786c | ||
|
|
424923019a | ||
|
|
06a69f1bfd | ||
|
|
1fa2edd9f2 | ||
|
|
fcd7d83c4c | ||
|
|
4f7983134b | ||
|
|
46b797dd29 | ||
|
|
1a6f4a581f | ||
|
|
2e7f4a6d10 | ||
|
|
6515fbe2dc | ||
|
|
454e05b02e | ||
|
|
442ca3e700 | ||
|
|
e00c63e32b | ||
|
|
ba6d7dcbed | ||
|
|
2ca8c34b2d | ||
|
|
03f9f8cd8e | ||
|
|
1ee8c76df3 | ||
|
|
bc1313b61d | ||
|
|
28982ffca0 | ||
|
|
bb82d5000f | ||
|
|
1f30227049 | ||
|
|
f34ec46111 | ||
|
|
8b79e9bee6 | ||
|
|
e09906a423 |
@@ -14,5 +14,8 @@
|
||||
"react-native-screens"
|
||||
]
|
||||
},
|
||||
"env": { "browser": true, "node": true }
|
||||
"env": { "browser": true, "node": true },
|
||||
"rules": {
|
||||
"import/named": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { registerRootComponent } from 'expo';
|
||||
import {
|
||||
Animated,
|
||||
@@ -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: {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"slug": "react-navigation-4-example",
|
||||
"description": "Demo app to showcase various functionality of React Navigation",
|
||||
"privacy": "public",
|
||||
"sdkVersion": "36.0.0",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android",
|
||||
|
||||
@@ -8,29 +8,29 @@
|
||||
"ios": "expo start --ios"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@expo/vector-icons": "^10.0.6",
|
||||
"@react-native-community/masked-view": "0.1.7",
|
||||
"expo": "^36.0.0",
|
||||
"expo-asset": "~8.0.0",
|
||||
"expo-barcode-scanner": "^8.0.0",
|
||||
"expo-blur": "~8.0.0",
|
||||
"expo-constants": "~8.0.0",
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@expo/vector-icons": "^10.0.0",
|
||||
"@react-native-community/masked-view": "0.1.10",
|
||||
"expo": "^39.0.0",
|
||||
"expo-asset": "~8.2.0",
|
||||
"expo-barcode-scanner": "~9.0.0",
|
||||
"expo-blur": "~8.2.0",
|
||||
"expo-constants": "~9.2.0",
|
||||
"hoist-non-react-statics": "^3.3.1",
|
||||
"react": "16.9.0",
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
|
||||
"react-native-gesture-handler": "~1.6.0",
|
||||
"react-native-iphone-x-helper": "^1.2.1",
|
||||
"react-native-maps": "0.27.0",
|
||||
"react-native-paper": "^3.4.0",
|
||||
"react-native-reanimated": "~1.7.0",
|
||||
"react-native-safe-area-context": "0.7.3",
|
||||
"react-native-screens": "2.3.0",
|
||||
"react-native-webview": "8.1.2",
|
||||
"react-navigation-header-buttons": "^3.0.5"
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-gesture-handler": "~1.7.0",
|
||||
"react-native-iphone-x-helper": "^1.3.0",
|
||||
"react-native-maps": "0.27.1",
|
||||
"react-native-paper": "^4.0.1",
|
||||
"react-native-reanimated": "~1.13.0",
|
||||
"react-native-safe-area-context": "3.1.4",
|
||||
"react-native-screens": "~2.10.1",
|
||||
"react-native-webview": "10.7.0",
|
||||
"react-navigation-header-buttons": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-module-resolver": "^4.0.0",
|
||||
"expo-cli": "^3.13.8"
|
||||
"expo-cli": "^3.28.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Alert,
|
||||
TouchableOpacity,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { ScrollView, StyleSheet } from 'react-native';
|
||||
import { BorderlessButton } from 'react-native-gesture-handler';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { View, Text, StyleSheet, Dimensions } from 'react-native';
|
||||
import { NavigationStackScreenComponent } from 'react-navigation-stack';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { ScrollView, StyleProp, TextStyle } from 'react-native';
|
||||
import { MaterialIcons } from '@expo/vector-icons';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView, View, Text } from 'react-native';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Dimensions,
|
||||
@@ -114,7 +114,7 @@ const MyNavScreen = ({
|
||||
title="Set unlocked"
|
||||
/>
|
||||
),
|
||||
unlocked: (
|
||||
'unlocked': (
|
||||
<Button
|
||||
onPress={() =>
|
||||
navigation.setParams({ drawerLockMode: 'locked-open' })
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
AccessibilityStates,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
@@ -88,11 +87,9 @@ export default class Button extends React.Component<ButtonProps> {
|
||||
buttonStyles.push({ backgroundColor: color });
|
||||
}
|
||||
}
|
||||
const accessibilityStates: AccessibilityStates[] = [];
|
||||
if (disabled) {
|
||||
buttonStyles.push(styles.buttonDisabled);
|
||||
textStyles.push(styles.textDisabled);
|
||||
accessibilityStates.push('disabled');
|
||||
}
|
||||
const formattedTitle =
|
||||
Platform.OS === 'android' ? title.toUpperCase() : title;
|
||||
@@ -100,7 +97,7 @@ export default class Button extends React.Component<ButtonProps> {
|
||||
<TouchableOpacity
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
accessibilityRole="button"
|
||||
accessibilityStates={accessibilityStates}
|
||||
accessibilityState={{ disabled }}
|
||||
testID={testID}
|
||||
disabled={disabled}
|
||||
onPress={onPress}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Platform, StyleSheet, View } from 'react-native';
|
||||
import BaseButton, { ButtonProps } from './Button';
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ class NavigationAwareScrollViewBase extends React.Component<{
|
||||
componentDidMount() {
|
||||
this.subscription = this.props.navigation.addListener('refocus', () => {
|
||||
if (this.props.navigation.isFocused()) {
|
||||
this.root.current && this.root.current.scrollTo({ x: 0, y: 0 });
|
||||
this.root.current?.scrollTo({ x: 0, y: 0 });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscription && this.subscription.remove();
|
||||
this.subscription?.remove();
|
||||
}
|
||||
|
||||
setNativeProps(props: ScrollViewProperties) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView, StyleSheet, View } from 'react-native';
|
||||
import {
|
||||
ThemeColors,
|
||||
@@ -106,7 +106,7 @@ const MyNavScreen = ({
|
||||
title="Set unlocked"
|
||||
/>
|
||||
),
|
||||
unlocked: (
|
||||
'unlocked': (
|
||||
<Button
|
||||
onPress={() =>
|
||||
navigation.setParams({ drawerLockMode: 'locked-open' })
|
||||
|
||||
@@ -64,7 +64,7 @@ class ListScreen extends React.Component {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
backgroundColor: '#fff',
|
||||
// backgroundColor: '#fff',
|
||||
}}
|
||||
>
|
||||
<Text>List Screen</Text>
|
||||
@@ -96,7 +96,7 @@ class DetailsScreen extends React.Component<NavigationStackScreenProps> {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
backgroundColor: '#fff',
|
||||
// backgroundColor: '#fff',
|
||||
}}
|
||||
>
|
||||
<Text>Details Screen</Text>
|
||||
@@ -119,7 +119,7 @@ class HeaderlessScreen extends React.Component {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
backgroundColor: '#fff',
|
||||
// backgroundColor: '#fff',
|
||||
}}
|
||||
>
|
||||
<Text>Headerless Screen</Text>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import { Themed } from 'react-navigation';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Text } from 'react-native';
|
||||
import {
|
||||
Themed,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { ScrollView, StatusBar } from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ScrollView,
|
||||
StatusBar,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView } from 'react-native';
|
||||
import { Themed, SafeAreaView } from 'react-navigation';
|
||||
import {
|
||||
@@ -91,8 +91,4 @@ const DrawerExample = createDrawerNavigator(
|
||||
}
|
||||
);
|
||||
|
||||
DrawerExample.navigationOptions = {
|
||||
headerShown: false,
|
||||
};
|
||||
|
||||
export default DrawerExample;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { MaterialIcons } from '@expo/vector-icons';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import SimpleTabs from './SimpleTabs';
|
||||
|
||||
40
package.json
40
package.json
@@ -25,28 +25,28 @@
|
||||
"example": "yarn --cwd example"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.7",
|
||||
"@babel/preset-react": "^7.8.3",
|
||||
"@babel/preset-typescript": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@commitlint/config-conventional": "^8.3.4",
|
||||
"@types/jest": "^25.1.4",
|
||||
"babel-jest": "^25.2.3",
|
||||
"commitlint": "^8.3.5",
|
||||
"core-js": "^3.6.4",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-satya164": "^3.1.5",
|
||||
"husky": "^4.2.1",
|
||||
"jest": "^25.1.0",
|
||||
"lerna": "^3.20.2",
|
||||
"prettier": "^2.0.1",
|
||||
"typescript": "~3.8.3"
|
||||
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
|
||||
"@babel/preset-env": "^7.12.1",
|
||||
"@babel/preset-react": "^7.12.1",
|
||||
"@babel/preset-typescript": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@commitlint/config-conventional": "^11.0.0",
|
||||
"@types/jest": "^26.0.15",
|
||||
"babel-jest": "^26.6.1",
|
||||
"commitlint": "^11.0.0",
|
||||
"core-js": "^3.6.5",
|
||||
"eslint": "^7.12.0",
|
||||
"eslint-config-satya164": "^3.1.8",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.6.1",
|
||||
"lerna": "^3.22.1",
|
||||
"prettier": "^2.1.2",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"resolutions": {
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5"
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
||||
@@ -3,6 +3,49 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.6.3](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.6.2...react-navigation-animated-switch@0.6.3) (2020-10-26)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.6.2](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.6.1...react-navigation-animated-switch@0.6.2) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.6.1](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.6.0...react-navigation-animated-switch@0.6.1) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.5.11](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.10...react-navigation-animated-switch@0.5.11) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-animated-switch",
|
||||
"version": "0.5.11",
|
||||
"version": "0.6.3",
|
||||
"description": "Animated switch for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -21,15 +21,15 @@
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "0.10.0",
|
||||
"@types/react": "16.9.23",
|
||||
"@types/react-native": "0.61.22",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-reanimated": "~1.7.0",
|
||||
"react-navigation": "^4.3.8",
|
||||
"typescript": "~3.8.3"
|
||||
"@react-native-community/bob": "0.16.2",
|
||||
"@types/react": "16.9.53",
|
||||
"@types/react-native": "0.63.30",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-reanimated": "~1.13.0",
|
||||
"react-navigation": "^4.4.3",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
|
||||
@@ -3,6 +3,44 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.7.9](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.8...@react-navigation/core@3.7.9) (2020-10-26)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.8](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.7...@react-navigation/core@3.7.8) (2020-10-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* NavigationEvents subscribe events on new nav state ([#8920](https://github.com/react-navigation/react-navigation-core/issues/8920)) ([6390aac](https://github.com/react-navigation/react-navigation-core/commit/6390aacd07fd647d925dfec842a766c8aad5272f))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.7](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.6...@react-navigation/core@3.7.7) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.6](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.5...@react-navigation/core@3.7.6) (2020-04-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* change old docUrl to new docUrl due v5 ([e09906a](https://github.com/react-navigation/react-navigation-core/commit/e09906a4235a0fca09140923ebe7af34b50b491a))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.5](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.4...@react-navigation/core@3.7.5) (2020-04-02)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@react-navigation/core",
|
||||
"version": "3.7.5",
|
||||
"version": "3.7.9",
|
||||
"description": "Core utilities for the react-navigation framework",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -37,16 +37,16 @@
|
||||
"dependencies": {
|
||||
"hoist-non-react-statics": "^3.3.2",
|
||||
"path-to-regexp": "^1.8.0",
|
||||
"query-string": "^6.11.1",
|
||||
"query-string": "^6.13.6",
|
||||
"react-is": "^16.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-testing-library": "^1.12.0",
|
||||
"react-test-renderer": "^16.9.2"
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-testing-library": "^6.0.0",
|
||||
"react-test-renderer": "~16.13.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*"
|
||||
|
||||
@@ -93,6 +93,7 @@ const StateUtils = {
|
||||
*/
|
||||
jumpTo(state, key) {
|
||||
const index = StateUtils.indexOf(state, key);
|
||||
invariant(index !== -1, 'attempt to jump to unknown key "%s"', key);
|
||||
return StateUtils.jumpToIndex(state, index);
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable react/sort-comp */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { NavigationActions, getNavigation, NavigationProvider } from '../index';
|
||||
|
||||
export default function createNavigationContainer(Component) {
|
||||
|
||||
@@ -3,32 +3,51 @@ import NavigationStateUtils from '../StateUtils';
|
||||
const routeName = 'Anything';
|
||||
|
||||
describe('StateUtils', () => {
|
||||
// Getters
|
||||
it('gets route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.get(state, 'a')).toEqual({
|
||||
key: 'a',
|
||||
routeName,
|
||||
describe('get', () => {
|
||||
it('gets route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.get(state, 'a')).toEqual({
|
||||
key: 'a',
|
||||
routeName,
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when getting an unknown route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.get(state, 'b')).toBe(null);
|
||||
});
|
||||
expect(NavigationStateUtils.get(state, 'b')).toBe(null);
|
||||
});
|
||||
|
||||
it('gets route index', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.indexOf(state, 'a')).toBe(0);
|
||||
expect(NavigationStateUtils.indexOf(state, 'b')).toBe(1);
|
||||
expect(NavigationStateUtils.indexOf(state, 'c')).toBe(-1);
|
||||
describe('indexOf', () => {
|
||||
it('gets route index', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.indexOf(state, 'a')).toBe(0);
|
||||
expect(NavigationStateUtils.indexOf(state, 'b')).toBe(1);
|
||||
});
|
||||
|
||||
it('returns -1 when getting an unknown route index', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.indexOf(state, 'b')).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
it('has a route', () => {
|
||||
@@ -44,303 +63,390 @@ describe('StateUtils', () => {
|
||||
expect(NavigationStateUtils.has(state, 'c')).toBe(false);
|
||||
});
|
||||
|
||||
// Push
|
||||
it('pushes a route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
isTransitioning: false,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
};
|
||||
expect(NavigationStateUtils.push(state, { key: 'b', routeName })).toEqual(
|
||||
newState
|
||||
);
|
||||
});
|
||||
|
||||
it('does not push duplicated route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() =>
|
||||
NavigationStateUtils.push(state, { key: 'a', routeName })
|
||||
).toThrow('should not push route with duplicated key a');
|
||||
});
|
||||
|
||||
// Pop
|
||||
it('pops route', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.pop(state)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('does not pop route if not applicable', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.pop(state)).toBe(state);
|
||||
});
|
||||
|
||||
// Jump
|
||||
it('jumps to new index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.jumpToIndex(state, 0)).toBe(state);
|
||||
expect(NavigationStateUtils.jumpToIndex(state, 1)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('throws if jumps to invalid index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpToIndex(state, 2)).toThrow(
|
||||
'invalid index 2 to jump to'
|
||||
);
|
||||
});
|
||||
|
||||
it('jumps to new key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.jumpTo(state, 'a')).toBe(state);
|
||||
expect(NavigationStateUtils.jumpTo(state, 'b')).toEqual(newState);
|
||||
});
|
||||
|
||||
it('throws if jumps to invalid key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpTo(state, 'c')).toThrow(
|
||||
'invalid index -1 to jump to'
|
||||
);
|
||||
});
|
||||
|
||||
it('move backwards', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.back(state)).toEqual(newState);
|
||||
expect(NavigationStateUtils.back(newState)).toBe(newState);
|
||||
});
|
||||
|
||||
it('move forwards', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.forward(state)).toEqual(newState);
|
||||
expect(NavigationStateUtils.forward(newState)).toBe(newState);
|
||||
});
|
||||
|
||||
// Replace
|
||||
it('Replaces by key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'c', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAt(state, 'b', { key: 'c', routeName })
|
||||
).toEqual(newState);
|
||||
});
|
||||
|
||||
it('Replaces by index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'c', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAtIndex(state, 1, { key: 'c', routeName })
|
||||
).toEqual(newState);
|
||||
});
|
||||
|
||||
it('Returns the state with updated index if route is unchanged but index changes', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAtIndex(state, 1, state.routes[1])
|
||||
).toEqual({ ...state, index: 1 });
|
||||
});
|
||||
|
||||
// Reset
|
||||
it('Resets routes', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.reset(state, [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
])
|
||||
).toEqual(newState);
|
||||
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(state, []);
|
||||
}).toThrow('invalid routes to replace');
|
||||
});
|
||||
|
||||
it('Resets routes with index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.reset(
|
||||
state,
|
||||
[
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
describe('push', () => {
|
||||
it('pushes a route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
isTransitioning: false,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
0
|
||||
)
|
||||
).toEqual(newState);
|
||||
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(
|
||||
state,
|
||||
[
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
100
|
||||
};
|
||||
expect(NavigationStateUtils.push(state, { key: 'b', routeName })).toEqual(
|
||||
newState
|
||||
);
|
||||
}).toThrow('invalid index 100 to reset');
|
||||
});
|
||||
|
||||
it('does not push duplicated route', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() =>
|
||||
NavigationStateUtils.push(state, { key: 'a', routeName })
|
||||
).toThrow('should not push route with duplicated key a');
|
||||
});
|
||||
});
|
||||
|
||||
describe('pop', () => {
|
||||
it('pops route', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.pop(state)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('does not pop route if not applicable with single route config', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [{ key: 'a', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.pop(state)).toBe(state);
|
||||
});
|
||||
|
||||
it('does not pop route if not applicable with multiple route config', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.pop(state)).toBe(state);
|
||||
});
|
||||
});
|
||||
|
||||
describe('jumpToIndex', () => {
|
||||
it('jumps to new index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.jumpToIndex(state, 0)).toBe(state);
|
||||
expect(NavigationStateUtils.jumpToIndex(state, 1)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('throws if jumps to invalid index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpToIndex(state, 2)).toThrow(
|
||||
'invalid index 2 to jump to'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('jumpTo', () => {
|
||||
it('jumps to the current key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.jumpTo(state, 'a')).toBe(state);
|
||||
});
|
||||
|
||||
it('jumps to new key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.jumpTo(state, 'b')).toEqual(newState);
|
||||
});
|
||||
|
||||
it('throws if jumps to invalid key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpTo(state, 'c')).toThrow(
|
||||
'attempt to jump to unknown key "c"'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('back', () => {
|
||||
it('move backwards', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.back(state)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('does not move backwards when the active route is the first', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.back(state)).toBe(state);
|
||||
});
|
||||
});
|
||||
|
||||
describe('forward', () => {
|
||||
it('move forwards', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.forward(state)).toEqual(newState);
|
||||
});
|
||||
|
||||
it('does not move forward when active route is already the top-most', () => {
|
||||
const state = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(NavigationStateUtils.forward(state)).toEqual(state);
|
||||
});
|
||||
});
|
||||
|
||||
describe('replace', () => {
|
||||
it('Replaces by key', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'c', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAt(state, 'b', { key: 'c', routeName })
|
||||
).toEqual(newState);
|
||||
});
|
||||
|
||||
it('Replaces by index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'c', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAtIndex(state, 1, { key: 'c', routeName })
|
||||
).toEqual(newState);
|
||||
});
|
||||
|
||||
it('Returns the state with updated index if route is unchanged but index changes', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.replaceAtIndex(state, 1, state.routes[1])
|
||||
).toEqual({ ...state, index: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('reset', () => {
|
||||
it('Resets routes', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 1,
|
||||
routes: [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.reset(state, [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
])
|
||||
).toEqual(newState);
|
||||
});
|
||||
|
||||
it('throws when attempting to set empty state', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(state, []);
|
||||
}).toThrow('invalid routes to replace');
|
||||
});
|
||||
|
||||
it('Resets routes with index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const newState = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(
|
||||
NavigationStateUtils.reset(
|
||||
state,
|
||||
[
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
0
|
||||
)
|
||||
).toEqual(newState);
|
||||
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(
|
||||
state,
|
||||
[
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
100
|
||||
);
|
||||
}).toThrow('invalid index 100 to reset');
|
||||
});
|
||||
|
||||
it('throws when attempting to set an out of range route index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{ key: 'a', routeName },
|
||||
{ key: 'b', routeName },
|
||||
],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(
|
||||
state,
|
||||
[
|
||||
{ key: 'x', routeName },
|
||||
{ key: 'y', routeName },
|
||||
],
|
||||
100
|
||||
);
|
||||
}).toThrow('invalid index 100 to reset');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import getNavigation from '../getNavigation';
|
||||
import * as NavigationActions from '../NavigationActions';
|
||||
|
||||
it('getNavigation provides default action helpers', () => {
|
||||
const router = {
|
||||
@@ -22,12 +23,11 @@ it('getNavigation provides default action helpers', () => {
|
||||
topNav.navigate('GreatRoute');
|
||||
|
||||
expect(dispatch.mock.calls.length).toBe(1);
|
||||
expect(dispatch.mock.calls[0][0].type).toBe('Navigation/NAVIGATE');
|
||||
expect(dispatch.mock.calls[0][0].type).toBe(NavigationActions.NAVIGATE);
|
||||
expect(dispatch.mock.calls[0][0].routeName).toBe('GreatRoute');
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip('getNavigation provides router action helpers', () => {
|
||||
it('getNavigation provides router action helpers', () => {
|
||||
const router = {
|
||||
getActionCreators: () => ({
|
||||
foo: (bar) => ({ type: 'FooBarAction', bar }),
|
||||
@@ -39,7 +39,8 @@ it.skip('getNavigation provides router action helpers', () => {
|
||||
|
||||
const dispatch = jest.fn();
|
||||
|
||||
const topNav = getNavigation(
|
||||
let topNav;
|
||||
topNav = getNavigation(
|
||||
router,
|
||||
{},
|
||||
dispatch,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default function getChildRouter(router: any, routeName: string) {
|
||||
if (router.childRouters && router.childRouters[routeName]) {
|
||||
if (router.childRouters?.[routeName]) {
|
||||
return router.childRouters[routeName];
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ function createNavigator(NavigatorView, router, navigationConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
const descriptors = routes.reduce((acc, route) => {
|
||||
const descriptors = routes.reduce((descriptors, route) => {
|
||||
if (
|
||||
prevDescriptors &&
|
||||
prevDescriptors[route.key] &&
|
||||
@@ -44,8 +44,8 @@ function createNavigator(NavigatorView, router, navigationConfig) {
|
||||
screenProps === currentState.screenProps &&
|
||||
currentState.themeContext === currentState.theme
|
||||
) {
|
||||
acc[route.key] = prevDescriptors[route.key];
|
||||
return acc;
|
||||
descriptors[route.key] = prevDescriptors[route.key];
|
||||
return descriptors;
|
||||
}
|
||||
const getComponent = router.getComponentForRouteName.bind(
|
||||
null,
|
||||
@@ -57,14 +57,14 @@ function createNavigator(NavigatorView, router, navigationConfig) {
|
||||
screenProps,
|
||||
currentState.themeContext
|
||||
);
|
||||
acc[route.key] = {
|
||||
descriptors[route.key] = {
|
||||
key: route.key,
|
||||
getComponent,
|
||||
options,
|
||||
state: route,
|
||||
navigation: childNavigation,
|
||||
};
|
||||
return acc;
|
||||
return descriptors;
|
||||
}, {});
|
||||
|
||||
return { descriptors, screenProps, theme: state.themeContext };
|
||||
|
||||
@@ -19,7 +19,7 @@ export default (routeConfigs, config = {}) => {
|
||||
const getCustomActionCreators =
|
||||
config.getCustomActionCreators || defaultActionCreators;
|
||||
|
||||
const initialRouteParams = config.initialRouteParams;
|
||||
const { initialRouteParams } = config;
|
||||
const initialRouteName = config.initialRouteName || order[0];
|
||||
const backBehavior = config.backBehavior || 'none';
|
||||
const resetOnBlur = config.hasOwnProperty('resetOnBlur')
|
||||
@@ -59,7 +59,7 @@ export default (routeConfigs, config = {}) => {
|
||||
|
||||
function resetChildRoute(routeName) {
|
||||
let initialParams =
|
||||
routeName === initialRouteName ? initialRouteParams : undefined;
|
||||
routeName === initialRouteName ? initialRouteParams : null;
|
||||
// note(brentvatne): merging initialRouteParams *on top* of default params
|
||||
// on the route seems incorrect but it's consistent with existing behavior
|
||||
// in stackrouter
|
||||
@@ -71,13 +71,13 @@ export default (routeConfigs, config = {}) => {
|
||||
...childRouter.getStateForAction(childAction),
|
||||
key: routeName,
|
||||
routeName,
|
||||
params,
|
||||
...(params ? { params } : {}),
|
||||
};
|
||||
}
|
||||
return {
|
||||
key: routeName,
|
||||
routeName,
|
||||
params,
|
||||
...(params ? { params } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
12
packages/core/src/routers/__tests__/KeyGenerator.test.js
Normal file
12
packages/core/src/routers/__tests__/KeyGenerator.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { _TESTING_ONLY_normalize_keys, generateKey } from '../KeyGenerator';
|
||||
|
||||
it('should generate a new string key when called', () => {
|
||||
_TESTING_ONLY_normalize_keys();
|
||||
|
||||
expect(generateKey()).toBe('id-0');
|
||||
expect(generateKey()).toBe('id-1');
|
||||
});
|
||||
|
||||
it('should generate unique string keys without being normalized', () => {
|
||||
expect(generateKey()).not.toBe(generateKey());
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint no-shadow:0, react/no-multi-comp:0, react/display-name:0 */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import SwitchRouter from '../SwitchRouter';
|
||||
import StackRouter from '../StackRouter';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint react/no-multi-comp:0, react/display-name:0 */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import StackRouter from '../StackRouter';
|
||||
import TabRouter from '../TabRouter';
|
||||
@@ -114,6 +114,51 @@ Object.keys(ROUTERS).forEach((routerName) => {
|
||||
);
|
||||
expect(state0.routes[state0.index].params.foo).toEqual(42);
|
||||
});
|
||||
|
||||
it('merges existing params when set params on existing state', () => {
|
||||
const Screen = () => <div />;
|
||||
|
||||
const router = Router({
|
||||
Foo: {
|
||||
screen: Screen,
|
||||
params: { a: 1 },
|
||||
},
|
||||
});
|
||||
const key = 'Foo';
|
||||
const state = router.getStateForAction({
|
||||
type: NavigationActions.INIT,
|
||||
key,
|
||||
});
|
||||
|
||||
expect(state).toMatchObject({
|
||||
index: 0,
|
||||
routes: [{ key, params: { a: 1 } }],
|
||||
});
|
||||
|
||||
const newState = router.getStateForAction(
|
||||
NavigationActions.setParams({ key, params: { b: 2 } }),
|
||||
state
|
||||
);
|
||||
|
||||
expect(newState.routes[newState.index].params).toEqual({ a: 1, b: 2 });
|
||||
});
|
||||
|
||||
it('merges params when setting params during init', () => {
|
||||
const Screen = () => <div />;
|
||||
|
||||
const router = Router({
|
||||
Foo: {
|
||||
screen: Screen,
|
||||
params: { a: 1 },
|
||||
},
|
||||
});
|
||||
|
||||
const newState = router.getStateForAction(
|
||||
NavigationActions.setParams({ key: 'Foo', params: { b: 2 } })
|
||||
);
|
||||
|
||||
expect(newState.routes[newState.index].params).toEqual({ a: 1, b: 2 });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint no-shadow:0, react/no-multi-comp:0, react/display-name:0 */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import StackRouter from '../StackRouter';
|
||||
import * as StackActions from '../StackActions';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint react/display-name:0 */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import SwitchRouter from '../SwitchRouter';
|
||||
import StackRouter from '../StackRouter';
|
||||
import * as NavigationActions from '../../NavigationActions';
|
||||
@@ -158,7 +158,7 @@ describe('SwitchRouter', () => {
|
||||
expect(getSubState(1).routeName).toEqual('A');
|
||||
|
||||
// The back action should not switch to B. It should stay on A
|
||||
back({ key: null });
|
||||
back(null);
|
||||
expect(getSubState(1).routeName).toEqual('A');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint react/display-name:0 */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import TabRouter from '../TabRouter';
|
||||
|
||||
import * as NavigationActions from '../../NavigationActions';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import validateRouteConfigMap from '../validateRouteConfigMap';
|
||||
import StackRouter from '../StackRouter';
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function docsUrl(path: string) {
|
||||
return `https://reactnavigation.org/docs/${path}`;
|
||||
return `https://reactnavigation.org/docs/4.x/${path}`;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import withNavigation from './withNavigation';
|
||||
|
||||
const EventNameToPropName = {
|
||||
@@ -12,11 +12,28 @@ const EventNames = Object.keys(EventNameToPropName);
|
||||
|
||||
class NavigationEvents extends React.Component {
|
||||
componentDidMount() {
|
||||
this.subscriptions = {};
|
||||
|
||||
// We register all navigation listeners on mount to ensure listener stability across re-render
|
||||
// A former implementation was replacing (removing/adding) listeners on all update (if prop provided)
|
||||
// but there were issues (see https://github.com/react-navigation/react-navigation/issues/5058)
|
||||
this.subscribeAll();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.navigation !== prevProps.navigation) {
|
||||
this.removeAll();
|
||||
this.subscribeAll();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.removeAll();
|
||||
}
|
||||
|
||||
getPropListener = (eventName) => this.props[EventNameToPropName[eventName]];
|
||||
|
||||
subscribeAll() {
|
||||
this.subscriptions = {};
|
||||
|
||||
EventNames.forEach((eventName) => {
|
||||
this.subscriptions[eventName] = this.props.navigation.addListener(
|
||||
eventName,
|
||||
@@ -28,14 +45,12 @@ class NavigationEvents extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
removeAll() {
|
||||
EventNames.forEach((eventName) => {
|
||||
this.subscriptions[eventName].remove();
|
||||
});
|
||||
}
|
||||
|
||||
getPropListener = (eventName) => this.props[EventNameToPropName[eventName]];
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import NavigationContext from './NavigationContext';
|
||||
|
||||
export default class SceneView extends React.PureComponent {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import SceneView from '../SceneView';
|
||||
|
||||
export default class SwitchView extends React.Component {
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import NavigationEvents from '../NavigationEvents';
|
||||
import NavigationContext from '../NavigationContext';
|
||||
|
||||
const createPropListener = () => jest.fn();
|
||||
|
||||
const EVENT_TO_PROP_NAME = {
|
||||
willFocus: 'onWillFocus',
|
||||
didFocus: 'onDidFocus',
|
||||
willBlur: 'onWillBlur',
|
||||
didBlur: 'onDidBlur',
|
||||
};
|
||||
|
||||
// An easy way to create the 4 listeners prop
|
||||
const createEventListenersProp = () => ({
|
||||
onWillFocus: createPropListener(),
|
||||
@@ -122,6 +129,39 @@ describe('NavigationEvents', () => {
|
||||
checkPropListenerIsCalled('didBlur', 'onDidBlur');
|
||||
});
|
||||
|
||||
it('wires props listeners to latest navigation updates', () => {
|
||||
const {
|
||||
navigation,
|
||||
NavigationListenersAPI,
|
||||
} = createTestNavigationAndHelpers();
|
||||
const {
|
||||
navigation: nextNavigation,
|
||||
NavigationListenersAPI: nextNavigationListenersAPI,
|
||||
} = createTestNavigationAndHelpers();
|
||||
|
||||
const eventListenerProps = createEventListenersProp();
|
||||
const component = renderer.create(
|
||||
<NavigationEvents navigation={navigation} {...eventListenerProps} />
|
||||
);
|
||||
|
||||
Object.entries(EVENT_TO_PROP_NAME).forEach(([eventName, propName]) => {
|
||||
expect(eventListenerProps[propName]).toHaveBeenCalledTimes(0);
|
||||
NavigationListenersAPI.call(eventName);
|
||||
expect(eventListenerProps[propName]).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
component.update(
|
||||
<NavigationEvents navigation={nextNavigation} {...eventListenerProps} />
|
||||
);
|
||||
|
||||
Object.entries(EVENT_TO_PROP_NAME).forEach(([eventName, propName]) => {
|
||||
NavigationListenersAPI.call(eventName);
|
||||
expect(eventListenerProps[propName]).toHaveBeenCalledTimes(1);
|
||||
nextNavigationListenersAPI.call(eventName);
|
||||
expect(eventListenerProps[propName]).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('wire latest props listener to navigation listeners on updates (support closure/arrow functions update)', () => {
|
||||
const {
|
||||
navigation,
|
||||
|
||||
307
packages/core/src/views/__tests__/NavigationFocusEvents.test.js
Normal file
307
packages/core/src/views/__tests__/NavigationFocusEvents.test.js
Normal file
@@ -0,0 +1,307 @@
|
||||
import * as React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import NavigationFocusEvents from '../NavigationFocusEvents';
|
||||
import getEventManager from '../../getEventManager';
|
||||
import { NavigationActions, StackActions } from '@react-navigation/core';
|
||||
|
||||
const getNavigationMock = (mock = {}) => {
|
||||
const { addListener, emit } = getEventManager('target');
|
||||
|
||||
return {
|
||||
state: {
|
||||
routes: [
|
||||
{ key: 'a', routeName: 'foo' },
|
||||
{ key: 'b', routeName: 'bar' },
|
||||
],
|
||||
index: 0,
|
||||
},
|
||||
isFocused: () => true,
|
||||
addListener: jest.fn(addListener),
|
||||
emit: emit,
|
||||
dangerouslyGetParent: () => null,
|
||||
...mock,
|
||||
};
|
||||
};
|
||||
|
||||
it('emits refocus event with current route key on refocus', () => {
|
||||
const navigation = getNavigationMock();
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
navigation.emit('refocus');
|
||||
|
||||
expect(onEvent).toHaveBeenCalledTimes(1);
|
||||
const key = navigation.state.routes[navigation.state.index].key;
|
||||
expect(onEvent).toHaveBeenCalledWith(key, 'refocus');
|
||||
});
|
||||
|
||||
describe('on navigation action emitted', () => {
|
||||
it('does not emit if navigation is not focused', () => {
|
||||
const navigation = getNavigationMock({
|
||||
isFocused: () => false,
|
||||
});
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
navigation.emit('action', {
|
||||
state: navigation.state,
|
||||
action: NavigationActions.init(),
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
expect(onEvent).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('emits only willFocus and willBlur if state is transitioning', () => {
|
||||
const state = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 1,
|
||||
routeKeyHistory: ['First', 'Second'],
|
||||
isTransitioning: true,
|
||||
};
|
||||
const action = NavigationActions.init();
|
||||
|
||||
const navigation = getNavigationMock({
|
||||
state: state,
|
||||
});
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
const lastState = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 0,
|
||||
routeKeyHistory: ['First'],
|
||||
};
|
||||
navigation.emit('action', {
|
||||
state,
|
||||
lastState,
|
||||
action,
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
const expectedPayload = {
|
||||
action,
|
||||
state: { key: 'Second', routeName: 'Second' },
|
||||
lastState: { key: 'First', routeName: 'First' },
|
||||
context: 'Second:Navigation/INIT_Root',
|
||||
type: 'action',
|
||||
};
|
||||
|
||||
expect(onEvent.mock.calls).toEqual([
|
||||
['Second', 'willFocus', expectedPayload],
|
||||
['First', 'willBlur', expectedPayload],
|
||||
['Second', 'action', expectedPayload],
|
||||
]);
|
||||
});
|
||||
|
||||
it('emits didFocus after willFocus and didBlur after willBlur if no transitions', () => {
|
||||
const state = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 1,
|
||||
routeKeyHistory: ['First', 'Second'],
|
||||
};
|
||||
const action = NavigationActions.navigate({
|
||||
routeName: 'Second',
|
||||
});
|
||||
|
||||
const navigation = getNavigationMock({
|
||||
state: state,
|
||||
});
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
const lastState = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 0,
|
||||
routeKeyHistory: ['First'],
|
||||
};
|
||||
navigation.emit('action', {
|
||||
state,
|
||||
lastState,
|
||||
action,
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
const expectedPayload = {
|
||||
action,
|
||||
state: { key: 'Second', routeName: 'Second' },
|
||||
lastState: { key: 'First', routeName: 'First' },
|
||||
context: 'Second:Navigation/NAVIGATE_Root',
|
||||
type: 'action',
|
||||
};
|
||||
|
||||
expect(onEvent.mock.calls).toEqual([
|
||||
['Second', 'willFocus', expectedPayload],
|
||||
['Second', 'didFocus', expectedPayload],
|
||||
['First', 'willBlur', expectedPayload],
|
||||
['First', 'didBlur', expectedPayload],
|
||||
['Second', 'action', expectedPayload],
|
||||
]);
|
||||
});
|
||||
|
||||
it('emits didBlur and didFocus when transition ends', () => {
|
||||
const initialState = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 0,
|
||||
routeKeyHistory: ['First'],
|
||||
isTransitioning: true,
|
||||
};
|
||||
const intermediateState = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 1,
|
||||
routeKeyHistory: ['First', 'Second'],
|
||||
isTransitioning: true,
|
||||
};
|
||||
const finalState = {
|
||||
routes: [
|
||||
{ key: 'First', routeName: 'First' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 1,
|
||||
routeKeyHistory: ['First', 'Second'],
|
||||
isTransitioning: false,
|
||||
};
|
||||
const actionNavigate = NavigationActions.navigate({ routeName: 'Second' });
|
||||
const actionEndTransition = StackActions.completeTransition({
|
||||
key: 'Second',
|
||||
});
|
||||
|
||||
const navigation = getNavigationMock({
|
||||
state: intermediateState,
|
||||
});
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
navigation.emit('action', {
|
||||
state: intermediateState,
|
||||
lastState: initialState,
|
||||
action: actionNavigate,
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
const expectedPayloadNavigate = {
|
||||
action: actionNavigate,
|
||||
state: { key: 'Second', routeName: 'Second' },
|
||||
lastState: { key: 'First', routeName: 'First' },
|
||||
context: 'Second:Navigation/NAVIGATE_Root',
|
||||
type: 'action',
|
||||
};
|
||||
|
||||
expect(onEvent.mock.calls).toEqual([
|
||||
['Second', 'willFocus', expectedPayloadNavigate],
|
||||
['First', 'willBlur', expectedPayloadNavigate],
|
||||
['Second', 'action', expectedPayloadNavigate],
|
||||
]);
|
||||
onEvent.mockClear();
|
||||
|
||||
navigation.emit('action', {
|
||||
state: finalState,
|
||||
lastState: intermediateState,
|
||||
action: actionEndTransition,
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
const expectedPayloadEndTransition = {
|
||||
action: actionEndTransition,
|
||||
state: { key: 'Second', routeName: 'Second' },
|
||||
lastState: { key: 'Second', routeName: 'Second' },
|
||||
context: 'Second:Navigation/COMPLETE_TRANSITION_Root',
|
||||
type: 'action',
|
||||
};
|
||||
|
||||
expect(onEvent.mock.calls).toEqual([
|
||||
['First', 'didBlur', expectedPayloadEndTransition],
|
||||
['Second', 'didFocus', expectedPayloadEndTransition],
|
||||
['Second', 'action', expectedPayloadEndTransition],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on willFocus emitted', () => {
|
||||
it('emits didFocus after willFocus if no transition', () => {
|
||||
const navigation = getNavigationMock({
|
||||
state: {
|
||||
routes: [
|
||||
{ key: 'FirstLanding', routeName: 'FirstLanding' },
|
||||
{ key: 'Second', routeName: 'Second' },
|
||||
],
|
||||
index: 0,
|
||||
key: 'First',
|
||||
routeName: 'First',
|
||||
},
|
||||
});
|
||||
const onEvent = jest.fn();
|
||||
|
||||
renderer.create(
|
||||
<NavigationFocusEvents navigation={navigation} onEvent={onEvent} />
|
||||
);
|
||||
|
||||
const lastState = { key: 'Third', routeName: 'Third' };
|
||||
const action = NavigationActions.navigate({ routeName: 'First' });
|
||||
|
||||
navigation.emit('willFocus', {
|
||||
lastState,
|
||||
action,
|
||||
context: 'First:Navigation/NAVIGATE_Root',
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
const expectedPayload = {
|
||||
action,
|
||||
state: { key: 'FirstLanding', routeName: 'FirstLanding' },
|
||||
context:
|
||||
'FirstLanding:Navigation/NAVIGATE_First:Navigation/NAVIGATE_Root',
|
||||
type: 'action',
|
||||
};
|
||||
|
||||
expect(onEvent.mock.calls).toEqual([
|
||||
['FirstLanding', 'willFocus', expectedPayload],
|
||||
['FirstLanding', 'didFocus', expectedPayload],
|
||||
]);
|
||||
|
||||
onEvent.mockClear();
|
||||
|
||||
// the nested navigator might emit a didFocus that should be ignored
|
||||
navigation.emit('didFocus', {
|
||||
lastState,
|
||||
action,
|
||||
context: 'First:Navigation/NAVIGATE_Root',
|
||||
type: 'action',
|
||||
});
|
||||
|
||||
expect(onEvent).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import invariant from '../utils/invariant';
|
||||
import NavigationContext from './NavigationContext';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import withNavigation from './withNavigation';
|
||||
|
||||
|
||||
@@ -3,6 +3,52 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [2.6.0](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.5.2...react-navigation-drawer@2.6.0) (2020-10-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add detachInactiveScreens prop for bottom tabs and drawer ([#8816](https://github.com/react-navigation/drawer/issues/8816)) ([707bea3](https://github.com/react-navigation/drawer/commit/707bea3cba1aa1f7b1eb5884dd1d129dcc2bbdc2))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.5.2](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.5.1...react-navigation-drawer@2.5.2) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.5.1](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.5.0...react-navigation-drawer@2.5.1) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.4.12](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.11...react-navigation-drawer@2.4.12) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-drawer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-drawer",
|
||||
"version": "2.4.12",
|
||||
"version": "2.6.0",
|
||||
"description": "Drawer navigator component for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -38,19 +38,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/react-navigation/drawer#readme",
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-native": "^0.61.22",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-lifecycles-compat": "^3.0.4",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-gesture-handler": "^1.6.0",
|
||||
"react-native-reanimated": "^1.2.0",
|
||||
"react-native-screens": "^2.3.0",
|
||||
"react-native-testing-library": "^1.12.0",
|
||||
"react-navigation": "^4.3.8",
|
||||
"typescript": "~3.8.3"
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-gesture-handler": "~1.7.0",
|
||||
"react-native-reanimated": "~1.13.0",
|
||||
"react-native-screens": "~2.10.1",
|
||||
"react-native-testing-library": "^6.0.0",
|
||||
"react-navigation": "^4.4.3",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ export type NavigationDrawerConfig = {
|
||||
drawerBackgroundColor?: ThemedColor;
|
||||
overlayColor?: ThemedColor;
|
||||
screenContainerStyle?: StyleProp<ViewStyle>;
|
||||
detachInactiveScreens?: boolean;
|
||||
};
|
||||
|
||||
export type NavigationDrawerRouterConfig = {
|
||||
|
||||
@@ -49,6 +49,7 @@ type Props = {
|
||||
contentOptions?: object;
|
||||
};
|
||||
screenProps: unknown;
|
||||
detachInactiveScreens: boolean;
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -160,17 +161,13 @@ 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}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
private renderContent = () => {
|
||||
let { lazy, navigation } = this.props;
|
||||
let { lazy, navigation, detachInactiveScreens = true } = this.props;
|
||||
let { loaded } = this.state;
|
||||
let { routes } = navigation.state;
|
||||
|
||||
@@ -187,7 +184,8 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<ScreenContainer style={styles.content}>
|
||||
// @ts-ignore
|
||||
<ScreenContainer enabled={detachInactiveScreens} style={styles.content}>
|
||||
{routes.map((route, index) => {
|
||||
if (lazy && !loaded.includes(index)) {
|
||||
// Don't render a screen if we've never navigated to it
|
||||
@@ -205,6 +203,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
||||
{ opacity: isFocused ? 1 : 0 },
|
||||
]}
|
||||
isVisible={isFocused}
|
||||
enabled={detachInactiveScreens}
|
||||
>
|
||||
<SceneView
|
||||
navigation={descriptor.navigation}
|
||||
|
||||
@@ -6,6 +6,7 @@ type Props = {
|
||||
isVisible: boolean;
|
||||
children: React.ReactNode;
|
||||
style?: any;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
const FAR_FAR_AWAY = 30000; // this should be big enough to move the whole view out of its container
|
||||
@@ -13,7 +14,7 @@ const FAR_FAR_AWAY = 30000; // this should be big enough to move the whole view
|
||||
export default class ResourceSavingScene extends React.Component<Props> {
|
||||
render() {
|
||||
// react-native-screens is buggy on web
|
||||
if (screensEnabled?.() && Platform.OS !== 'web') {
|
||||
if (screensEnabled?.() && this.props.enabled && Platform.OS !== 'web') {
|
||||
const { isVisible, ...rest } = this.props;
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
@@ -3,6 +3,49 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.3.3](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.3.2...react-navigation-material-bottom-tabs@2.3.3) (2020-10-26)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.2](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.3.1...react-navigation-material-bottom-tabs@2.3.2) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.1](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.3.0...react-navigation-material-bottom-tabs@2.3.1) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.11](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.10...react-navigation-material-bottom-tabs@2.2.11) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-material-bottom-tabs",
|
||||
"version": "2.2.11",
|
||||
"version": "2.3.3",
|
||||
"description": "Material Bottom Tab Navigation component for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"module": "lib/module/index.js",
|
||||
@@ -38,18 +38,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/react-navigation/react-navigation-material-bottom-tabs#readme",
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@types/hoist-non-react-statics": "^3.3.1",
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-native": "^0.61.22",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-gesture-handler": "^1.6.0",
|
||||
"react-native-paper": "^3.1.1",
|
||||
"react-native-reanimated": "^1.2.0",
|
||||
"react-navigation": "^4.3.8",
|
||||
"typescript": "~3.8.3"
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-paper": "^4.2.0",
|
||||
"react-navigation": "^4.4.3",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
|
||||
@@ -3,6 +3,57 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.8.3](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.8.2...@react-navigation/native@3.8.3) (2020-10-26)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.8.2](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.8.1...@react-navigation/native@3.8.2) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.8.1](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.8.0...@react-navigation/native@3.8.1) (2020-09-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't use deprecated currentlyFocusedField ([#8684](https://github.com/react-navigation/react-navigation-native/issues/8684)) ([06a69f1](https://github.com/react-navigation/react-navigation-native/commit/06a69f1bfd81fe06b784ff4e6da290fee0c6467d)), closes [#8457](https://github.com/react-navigation/react-navigation-native/issues/8457)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.12](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.11...@react-navigation/native@3.7.12) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@react-navigation/native",
|
||||
"version": "3.7.12",
|
||||
"version": "3.8.3",
|
||||
"description": "React Native support for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -39,14 +39,14 @@
|
||||
"react-native-safe-area-view": "^0.14.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"@react-navigation/core": "^3.7.5",
|
||||
"@types/react-test-renderer": "^16.9.2",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-gesture-handler": "^1.6.0",
|
||||
"react-test-renderer": "^16.9.2"
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@react-navigation/core": "^3.7.9",
|
||||
"@types/react-test-renderer": "^16.9.3",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-gesture-handler": "~1.7.0",
|
||||
"react-test-renderer": "~16.13.1"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Platform, StyleSheet, View } from 'react-native';
|
||||
import { SceneView } from '@react-navigation/core';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ScrollView,
|
||||
Platform,
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
SectionList,
|
||||
RefreshControl,
|
||||
} from 'react-native';
|
||||
// eslint-disable-next-line import/named
|
||||
import { ScrollView as GHScrollView } from 'react-native-gesture-handler';
|
||||
import createNavigationAwareScrollable from './createNavigationAwareScrollable';
|
||||
import invariant from './utils/invariant';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { View } from 'react-native';
|
||||
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import renderer from 'react-test-renderer';
|
||||
import withOrientation, { isOrientationLandscape } from '../withOrientation';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable react/sort-comp */
|
||||
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Linking, Platform, BackHandler } from 'react-native';
|
||||
import {
|
||||
NavigationActions,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { TextInput } from 'react-native';
|
||||
|
||||
export default (Navigator, navigatorConfig) =>
|
||||
@@ -8,7 +8,9 @@ export default (Navigator, navigatorConfig) =>
|
||||
_previouslyFocusedTextInput = null;
|
||||
|
||||
_handleGestureBegin = () => {
|
||||
this._previouslyFocusedTextInput = TextInput.State.currentlyFocusedField();
|
||||
this._previouslyFocusedTextInput = TextInput.State.currentlyFocusedInput
|
||||
? TextInput.State.currentlyFocusedInput()
|
||||
: TextInput.State.currentlyFocusedField();
|
||||
if (this._previouslyFocusedTextInput) {
|
||||
TextInput.State.blurTextInput(this._previouslyFocusedTextInput);
|
||||
}
|
||||
@@ -32,7 +34,9 @@ export default (Navigator, navigatorConfig) =>
|
||||
// in the case where the index did not change, I believe. We
|
||||
// should revisit this after 2.0 release.
|
||||
if (transitionProps.index !== prevTransitionProps.index) {
|
||||
const currentField = TextInput.State.currentlyFocusedField();
|
||||
const currentField = TextInput.State.currentlyFocusedInput
|
||||
? TextInput.State.currentlyFocusedInput()
|
||||
: TextInput.State.currentlyFocusedField();
|
||||
if (currentField) {
|
||||
TextInput.State.blurTextInput(currentField);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import { withNavigation } from '@react-navigation/core';
|
||||
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Dimensions } from 'react-native';
|
||||
import hoistNonReactStatic from 'hoist-non-react-statics';
|
||||
|
||||
|
||||
@@ -3,6 +3,52 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [4.4.3](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.4.2...react-navigation@4.4.3) (2020-10-26)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.4.2](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.4.1...react-navigation@4.4.2) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.4.1](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.4.0...react-navigation@4.4.1) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* change old docUrl to new docUrl due v5 ([e09906a](https://github.com/react-navigation/react-navigation/commit/e09906a4235a0fca09140923ebe7af34b50b491a))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.3.8](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.7...react-navigation@4.3.8) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation",
|
||||
"version": "4.3.8",
|
||||
"version": "4.4.3",
|
||||
"description": "Routing and navigation for your React Native apps",
|
||||
"main": "src/index.js",
|
||||
"types": "typescript/react-navigation.d.ts",
|
||||
@@ -24,16 +24,16 @@
|
||||
"react-native": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/core": "^3.7.5",
|
||||
"@react-navigation/native": "^3.7.12"
|
||||
"@react-navigation/core": "^3.7.9",
|
||||
"@react-navigation/native": "^3.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-native": "^0.61.22",
|
||||
"@types/react-test-renderer": "^16.9.2",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-test-renderer": "^16.9.2",
|
||||
"typescript": "~3.8.3"
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
"@types/react-test-renderer": "^16.9.3",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-test-renderer": "~16.13.1",
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function docsUrl(path) {
|
||||
return `https://reactnavigation.org/docs/${path}`;
|
||||
return `https://reactnavigation.org/docs/4.x/${path}`;
|
||||
}
|
||||
|
||||
@@ -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,16 @@ export interface NavigationDescriptor<
|
||||
getComponent: () => React.ComponentType;
|
||||
}
|
||||
|
||||
export type NavigationView<
|
||||
Options,
|
||||
State,
|
||||
ScreenProps = unknown
|
||||
> = React.ComponentType<
|
||||
{
|
||||
descriptors: { [key: string]: NavigationDescriptor };
|
||||
navigationConfig: Options;
|
||||
screenProps?: ScreenProps;
|
||||
} & NavigationInjectedProps
|
||||
>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
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,
|
||||
@@ -897,11 +898,13 @@ export function withNavigation<
|
||||
}
|
||||
>;
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export function withNavigation<P extends NavigationInjectedProps>(
|
||||
Component: React.ComponentType<P>
|
||||
): React.ComponentType<Omit<P, keyof NavigationInjectedProps>>;
|
||||
|
||||
// For backwards compatibility
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export function withNavigation<T = {}, P = NavigationParams>(
|
||||
Component: React.ComponentType<T & NavigationInjectedProps<P>>
|
||||
): React.ComponentType<
|
||||
@@ -929,11 +932,13 @@ export function withNavigationFocus<
|
||||
}
|
||||
>;
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export function withNavigationFocus<P extends NavigationFocusInjectedProps>(
|
||||
Component: React.ComponentType<P>
|
||||
): React.ComponentType<Omit<P, keyof NavigationFocusInjectedProps>>;
|
||||
|
||||
// For backwards compatibility
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export function withNavigationFocus<T = {}, P = NavigationParams>(
|
||||
Component: React.ComponentType<T & NavigationFocusInjectedProps<P>>
|
||||
): React.ComponentType<
|
||||
|
||||
@@ -3,6 +3,121 @@
|
||||
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/react-navigation-stack/compare/react-navigation-stack@2.8.4...react-navigation-stack@2.9.0) (2020-10-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* sync latest stack ([6bdc1e9](https://github.com/react-navigation/react-navigation-stack/commit/6bdc1e9e5f6ca05e0494f6b9a1f7b9b60764628a))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.4](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.8.3...react-navigation-stack@2.8.4) (2020-10-02)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.3](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.8.2...react-navigation-stack@2.8.3) (2020-09-24)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.2](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.8.1...react-navigation-stack@2.8.2) (2020-06-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sync latest stack ([46b797d](https://github.com/react-navigation/react-navigation-stack/commit/46b797dd297f789e3c92ff6f5c4432fedc891767))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.1](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.8.0...react-navigation-stack@2.8.1) (2020-06-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* pop with correct key from nested stack ([2e7f4a6](https://github.com/react-navigation/react-navigation-stack/commit/2e7f4a6d10a00930bd5c53ef6f4bf964c9638db5))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [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)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* sync latest stack ([ba6d7dc](https://github.com/react-navigation/react-navigation-stack/commit/ba6d7dcbedcfca774a53de32f92acc45140bb1fe))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [2.6.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.5.1...react-navigation-stack@2.6.0) (2020-06-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* sync latest stack ([03f9f8c](https://github.com/react-navigation/react-navigation-stack/commit/03f9f8cd8ec3b5fe9dc2ed1ed2024e79dd06f854))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.5.1](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.5.0...react-navigation-stack@2.5.1) (2020-05-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sync latest stack ([bc1313b](https://github.com/react-navigation/react-navigation-stack/commit/bc1313b61da6134255adff477ded2ed8f632bf4a))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [2.5.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.4.0...react-navigation-stack@2.5.0) (2020-05-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* sync latest stack ([bb82d50](https://github.com/react-navigation/react-navigation-stack/commit/bb82d5000f6577f421cc7f72df8064eb4c2a0650))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [2.4.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.13...react-navigation-stack@2.4.0) (2020-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* sync latest stack ([8b79e9b](https://github.com/react-navigation/react-navigation-stack/commit/8b79e9bee65c3ba6a788ca76771379319168f117))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.13](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.12...react-navigation-stack@2.3.13) (2020-04-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
@@ -49,7 +49,7 @@ yarn example start
|
||||
|
||||
The code in this repo uses the source from [`@react-navigation/stack`](https://github.com/react-navigation/navigation-ex/tree/master/packages/stack) and patches it to make it usable in React Navigation 4. If you need to make changes, please send a pull request there.
|
||||
|
||||
If the change is specifically related to React Navigation 4 integration, first run `yarn sync`, then change the files in `src/vendor` and then run `yarn patch` to update the patch file with the latest changes.
|
||||
If the change is specifically related to React Navigation 4 integration, first run `yarn patch:apply`, then change the files in `src/vendor` to resolve any conflicts and then run `yarn patch:create` to update the patch file with the latest changes.
|
||||
|
||||
Make sure your code passes TypeScript and ESLint. Run the following to verify:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-stack",
|
||||
"version": "2.3.13",
|
||||
"version": "2.9.0",
|
||||
"description": "Stack navigator component for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"module": "lib/module/index.js",
|
||||
@@ -13,8 +13,8 @@
|
||||
"scripts": {
|
||||
"prepare": "bob build",
|
||||
"clean": "del lib",
|
||||
"sync": "bash scripts/sync-stack.sh",
|
||||
"patch": "diff -Naur ../../node_modules/@react-navigation/stack/src src/vendor > scripts/stack.patch; printf ''"
|
||||
"patch:apply": "bash scripts/sync-stack.sh",
|
||||
"patch:create": "diff -Naur ../../node_modules/@react-navigation/stack/src src/vendor > scripts/stack.patch; printf ''"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"publishConfig": {
|
||||
@@ -39,26 +39,26 @@
|
||||
},
|
||||
"homepage": "https://github.com/react-navigation/react-navigation-stack#readme",
|
||||
"dependencies": {
|
||||
"color": "^3.1.2",
|
||||
"react-native-iphone-x-helper": "^1.2.1"
|
||||
"color": "^3.1.3",
|
||||
"react-native-iphone-x-helper": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"@react-native-community/masked-view": "^0.1.7",
|
||||
"@react-navigation/stack": "^5.2.12",
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@react-native-community/masked-view": "0.1.10",
|
||||
"@react-navigation/stack": "^5.10.0",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-native": "^0.61.22",
|
||||
"@types/react-test-renderer": "^16.9.2",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.4",
|
||||
"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.8",
|
||||
"react-test-renderer": "~16.9.0",
|
||||
"typescript": "~3.8.3"
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
"@types/react-test-renderer": "^16.9.3",
|
||||
"del-cli": "^3.0.1",
|
||||
"react": "~16.13.1",
|
||||
"react-native": "~0.63.2",
|
||||
"react-native-gesture-handler": "~1.7.0",
|
||||
"react-native-safe-area-context": "3.1.4",
|
||||
"react-native-screens": "~2.10.1",
|
||||
"react-navigation": "^4.4.3",
|
||||
"react-test-renderer": "~16.13.1",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@react-native-community/masked-view": ">=0.1.0",
|
||||
|
||||
@@ -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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/index.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/index.tsx 2020-10-26 16:08:35.000000000 +0100
|
||||
@@ -3,11 +3,6 @@
|
||||
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
||||
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
|
||||
@@ -13,12 +13,13 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
|
||||
export const Assets = [
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
require('./views/assets/back-icon.png'),
|
||||
@@ -49,8 +44,10 @@
|
||||
@@ -49,9 +44,10 @@
|
||||
* Types
|
||||
*/
|
||||
export type {
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationProp,
|
||||
- StackScreenProps,
|
||||
+ NavigationStackState,
|
||||
+ StackNavigationProp as NavigationStackProp,
|
||||
+ StackNavigationOptions as NavigationStackOptions,
|
||||
@@ -27,9 +28,9 @@ 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-04-22 16:34:01.000000000 +0200
|
||||
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
|
||||
@@ -1,96 +0,0 @@
|
||||
@@ -1,101 +0,0 @@
|
||||
-import * as React from 'react';
|
||||
-import { Platform } from 'react-native';
|
||||
-import {
|
||||
@@ -41,9 +42,11 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
- StackRouterOptions,
|
||||
- StackNavigationState,
|
||||
- StackActions,
|
||||
- ParamListBase,
|
||||
- StackActionHelpers,
|
||||
-} from '@react-navigation/native';
|
||||
-import StackView from '../views/Stack/StackView';
|
||||
-import {
|
||||
-import type {
|
||||
- StackNavigationConfig,
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationEventMap,
|
||||
@@ -61,12 +64,16 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
-}: Props) {
|
||||
- const defaultOptions = {
|
||||
- gestureEnabled: Platform.OS === 'ios',
|
||||
- animationEnabled: Platform.OS !== 'web',
|
||||
- animationEnabled:
|
||||
- Platform.OS !== 'web' &&
|
||||
- Platform.OS !== 'windows' &&
|
||||
- Platform.OS !== 'macos',
|
||||
- };
|
||||
-
|
||||
- const { state, descriptors, navigation } = useNavigationBuilder<
|
||||
- StackNavigationState,
|
||||
- StackNavigationState<ParamListBase>,
|
||||
- StackRouterOptions,
|
||||
- StackActionHelpers<ParamListBase>,
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationEventMap
|
||||
- >(StackRouter, {
|
||||
@@ -86,8 +93,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
-
|
||||
- React.useEffect(
|
||||
- () =>
|
||||
- navigation.addListener &&
|
||||
- navigation.addListener('tabPress', (e) => {
|
||||
- navigation.addListener?.('tabPress', (e) => {
|
||||
- const isFocused = navigation.isFocused();
|
||||
-
|
||||
- // Run the operation in the next frame so we're sure all listeners have been run
|
||||
@@ -121,18 +127,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
-}
|
||||
-
|
||||
-export default createNavigatorFactory<
|
||||
- StackNavigationState,
|
||||
- StackNavigationState<ParamListBase>,
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationEventMap,
|
||||
- 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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/types.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -8,14 +8,28 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/types.tsx 2020-10-26 16:13:50.000000000 +0100
|
||||
@@ -8,15 +8,29 @@
|
||||
} 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,
|
||||
@@ -143,6 +149,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
- NavigationHelpers,
|
||||
- StackNavigationState,
|
||||
- StackActionHelpers,
|
||||
- RouteProp,
|
||||
-} from '@react-navigation/native';
|
||||
+ NavigationParams,
|
||||
+ NavigationNavigateAction,
|
||||
@@ -153,6 +160,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
+} from 'react-navigation';
|
||||
+
|
||||
+// @ts-ignore
|
||||
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
+export type Route<T extends string> = NavigationRoute;
|
||||
+
|
||||
+export type NavigationStackState = NavigationState;
|
||||
@@ -165,27 +173,35 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
|
||||
export type StackNavigationEventMap = {
|
||||
/**
|
||||
@@ -28,22 +42,29 @@
|
||||
transitionEnd: { data: { closing: boolean } };
|
||||
@@ -41,30 +55,29 @@
|
||||
gestureCancel: { data: undefined };
|
||||
};
|
||||
|
||||
-export type StackNavigationHelpers = NavigationHelpers<
|
||||
- ParamListBase,
|
||||
- StackNavigationEventMap
|
||||
->;
|
||||
-
|
||||
-> &
|
||||
- StackActionHelpers<ParamListBase>;
|
||||
+export type StackNavigationHelpers = NavigationProp<NavigationStackState>;
|
||||
|
||||
export type StackNavigationProp<
|
||||
- ParamList extends ParamListBase,
|
||||
- RouteName extends keyof ParamList = string
|
||||
-> = NavigationProp<
|
||||
- ParamList,
|
||||
- RouteName,
|
||||
- StackNavigationState,
|
||||
- StackNavigationState<ParamList>,
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationEventMap
|
||||
-> &
|
||||
- StackActionHelpers<ParamList>;
|
||||
-
|
||||
-export type StackScreenProps<
|
||||
- ParamList extends ParamListBase,
|
||||
- RouteName extends keyof ParamList = string
|
||||
-> = {
|
||||
- navigation: StackNavigationProp<ParamList, RouteName>;
|
||||
- route: RouteProp<ParamList, RouteName>;
|
||||
+ State = NavigationRoute,
|
||||
+ Params = NavigationParams
|
||||
+> = NavigationScreenProp<State, Params> & {
|
||||
@@ -206,11 +222,10 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
+ event: NavigationStackEventName,
|
||||
+ callback: NavigationEventCallback
|
||||
+ ) => NavigationEventSubscription;
|
||||
+};
|
||||
};
|
||||
|
||||
export type Layout = { width: number; height: number };
|
||||
|
||||
@@ -218,24 +239,27 @@
|
||||
@@ -241,24 +254,27 @@
|
||||
/**
|
||||
* Navigation prop for the header.
|
||||
*/
|
||||
@@ -225,7 +240,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
-export type StackDescriptor = Descriptor<
|
||||
- ParamListBase,
|
||||
- string,
|
||||
- StackNavigationState,
|
||||
- StackNavigationState<ParamListBase>,
|
||||
- StackNavigationOptions
|
||||
+export type StackDescriptor = NavigationDescriptor<
|
||||
+ NavigationParams,
|
||||
@@ -244,37 +259,58 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
export type StackNavigationOptions = StackHeaderOptions &
|
||||
Partial<TransitionPreset> & {
|
||||
/**
|
||||
@@ -317,6 +341,8 @@
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
};
|
||||
@@ -352,6 +368,8 @@
|
||||
* Defaults to `false` for the last screen when mode='modal', otherwise `true`.
|
||||
*/
|
||||
detachPreviousScreen?: boolean;
|
||||
+ onTransitionStart?: (props: TransitionCallbackProps) => void;
|
||||
+ onTransitionEnd?: (props: TransitionCallbackProps) => void;
|
||||
};
|
||||
|
||||
export type StackNavigationConfig = {
|
||||
@@ -365,7 +383,7 @@
|
||||
/**
|
||||
* Whether inactive screens should be detached from the view hierarchy to save memory.
|
||||
* Make sure to call `enableScreens` from `react-native-screens` to make it work.
|
||||
- * Defaults to `true`.
|
||||
+ * Defaults to `true` on Android, `false` on iOS.
|
||||
*/
|
||||
detachInactiveScreens?: boolean;
|
||||
};
|
||||
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-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/utils/PreviousSceneContext.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -1,12 +1,14 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -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
|
||||
@@ -283,7 +319,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
||||
|
||||
let leftLabel;
|
||||
|
||||
@@ -38,17 +40,12 @@
|
||||
@@ -38,17 +41,20 @@
|
||||
? o.headerTitle
|
||||
: o.title !== undefined
|
||||
? o.title
|
||||
@@ -291,6 +327,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
||||
+ : previous.route.routeName;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const goBack = React.useCallback(
|
||||
debounce(() => {
|
||||
- if (navigation.isFocused() && navigation.canGoBack()) {
|
||||
@@ -298,12 +335,18 @@ 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 }));
|
||||
+ const key = navigation.isFirstRouteInParent()
|
||||
+ ? // If we're the first route, we're going back to a parent navigator
|
||||
+ // So we need to get the key of the route we're nested in
|
||||
+ navigation.dangerouslyGetParent()?.state.key
|
||||
+ : scene.route.key;
|
||||
+
|
||||
+ if (key !== undefined) {
|
||||
+ navigation.dispatch(StackActions.pop({ key }));
|
||||
}
|
||||
}, 50),
|
||||
[navigation, scene.route.key]
|
||||
);
|
||||
@@ -63,7 +60,10 @@
|
||||
@@ -64,7 +70,10 @@
|
||||
leftLabel={leftLabel}
|
||||
headerTitle={
|
||||
typeof options.headerTitle !== 'function'
|
||||
@@ -315,7 +358,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
||||
: options.headerTitle
|
||||
}
|
||||
onGoBack={previous ? goBack : undefined}
|
||||
@@ -71,3 +71,18 @@
|
||||
@@ -72,3 +81,18 @@
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -335,8 +378,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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-10-26 16:14:24.000000000 +0100
|
||||
@@ -8,9 +8,9 @@
|
||||
StyleSheet,
|
||||
LayoutChangeEvent,
|
||||
@@ -345,26 +388,27 @@ 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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, StyleSheet, Platform, ViewProps } from 'react-native';
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -7,7 +7,7 @@
|
||||
StyleProp,
|
||||
ViewStyle,
|
||||
} from 'react-native';
|
||||
-import { useTheme } from '@react-navigation/native';
|
||||
+import useTheme from '../../../utils/useTheme';
|
||||
|
||||
type Props = ViewProps & {
|
||||
children?: React.ReactNode;
|
||||
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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-10-26 16:15:18.000000000 +0100
|
||||
@@ -1,11 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
-import {
|
||||
- NavigationContext,
|
||||
- NavigationRouteContext,
|
||||
@@ -372,18 +416,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';
|
||||
@@ -16,6 +11,7 @@
|
||||
forSlideRight,
|
||||
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
||||
import {
|
||||
+ Route,
|
||||
@@ -19,6 +14,7 @@
|
||||
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||
import type {
|
||||
Layout,
|
||||
+ Route,
|
||||
Scene,
|
||||
StackHeaderStyleInterpolator,
|
||||
@@ -99,9 +95,7 @@
|
||||
StackNavigationProp,
|
||||
@@ -105,9 +101,7 @@
|
||||
insets,
|
||||
scene,
|
||||
previous,
|
||||
@@ -394,7 +438,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
||||
styleInterpolator:
|
||||
mode === 'float'
|
||||
? isHeaderStatic
|
||||
@@ -120,7 +114,7 @@
|
||||
@@ -126,7 +120,7 @@
|
||||
key={scene.route.key}
|
||||
value={scene.descriptor.navigation}
|
||||
>
|
||||
@@ -403,9 +447,9 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
||||
<View
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
@@ -152,7 +146,7 @@
|
||||
)
|
||||
) : null}
|
||||
@@ -155,7 +149,7 @@
|
||||
>
|
||||
{header !== undefined ? header(props) : <Header {...props} />}
|
||||
</View>
|
||||
- </NavigationRouteContext.Provider>
|
||||
+ </>
|
||||
@@ -413,18 +457,18 @@ 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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -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';
|
||||
@@ -28,7 +28,7 @@
|
||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||
@@ -29,7 +29,7 @@
|
||||
onGoBack?: () => void;
|
||||
title?: string;
|
||||
leftLabel?: string;
|
||||
@@ -434,113 +478,121 @@ 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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, StyleSheet, Platform } from 'react-native';
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-10-26 16:14:52.000000000 +0100
|
||||
@@ -7,7 +7,7 @@
|
||||
StyleProp,
|
||||
TextStyle,
|
||||
} from 'react-native';
|
||||
-import { useTheme } from '@react-navigation/native';
|
||||
+import useTheme from '../../../utils/useTheme';
|
||||
|
||||
type Props = React.ComponentProps<typeof Animated.Text> & {
|
||||
type Props = Omit<TextProps, 'style'> & {
|
||||
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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -138,7 +138,7 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -162,7 +162,7 @@
|
||||
|
||||
private interactionHandle: number | undefined;
|
||||
|
||||
- private pendingGestureCallback: number | undefined;
|
||||
+ private pendingGestureCallback: any;
|
||||
|
||||
private animate = ({
|
||||
closing,
|
||||
private lastToValue: number | undefined;
|
||||
|
||||
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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-04-22 16:34:39.000000000 +0200
|
||||
@@ -1,10 +1,16 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-10-26 16:08:40.000000000 +0100
|
||||
@@ -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 { Scene, Layout, StackHeaderMode, TransitionPreset } from '../../types';
|
||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||
+import useTheme from '../../../utils/useTheme';
|
||||
+import {
|
||||
import type {
|
||||
+ Route,
|
||||
+ Scene,
|
||||
+ Layout,
|
||||
+ StackHeaderMode,
|
||||
+ TransitionPreset,
|
||||
+} from '../../types';
|
||||
|
||||
type Props = TransitionPreset & {
|
||||
index: number;
|
||||
@@ -183,7 +189,7 @@
|
||||
? { marginTop: headerHeight }
|
||||
: null
|
||||
}
|
||||
- contentStyle={[{ backgroundColor: colors.background }, cardStyle]}
|
||||
+ contentStyle={[{ backgroundColor: colors.background }, cardStyle] as any}
|
||||
style={StyleSheet.absoluteFill}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-04-22 16:35:12.000000000 +0200
|
||||
@@ -7,7 +7,7 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-10-26 16:17:14.000000000 +0100
|
||||
@@ -7,11 +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 {
|
||||
- ParamListBase,
|
||||
- Route,
|
||||
- StackNavigationState,
|
||||
-} from '@react-navigation/native';
|
||||
+import type { NavigationState as StackNavigationState } from 'react-navigation';
|
||||
|
||||
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
|
||||
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
|
||||
@@ -21,6 +21,7 @@
|
||||
import { forNoAnimation as forNoAnimationCard } from '../../TransitionConfigs/CardStyleInterpolators';
|
||||
import getDistanceForDirection from '../../utils/getDistanceForDirection';
|
||||
import {
|
||||
+ Route,
|
||||
MaybeScreenContainer,
|
||||
@@ -32,6 +28,7 @@
|
||||
Layout,
|
||||
StackHeaderMode,
|
||||
StackCardMode,
|
||||
+ Route,
|
||||
Scene,
|
||||
StackDescriptorMap,
|
||||
StackNavigationOptions,
|
||||
@@ -45,7 +42,7 @@
|
||||
type Props = {
|
||||
mode: StackCardMode;
|
||||
insets: EdgeInsets;
|
||||
- state: StackNavigationState<ParamListBase>;
|
||||
+ state: StackNavigationState;
|
||||
descriptors: StackDescriptorMap;
|
||||
routes: Route<string>[];
|
||||
openingRouteKeys: string[];
|
||||
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-04-22 16:34:01.000000000 +0200
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-04-22 16:38:12.000000000 +0200
|
||||
@@ -4,9 +4,10 @@
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-10-26 16:07:00.000000000 +0100
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-10-26 16:20:15.000000000 +0100
|
||||
@@ -2,12 +2,11 @@
|
||||
import { View, Platform, StyleSheet } from 'react-native';
|
||||
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
|
||||
import {
|
||||
- NavigationHelpersContext,
|
||||
StackActions,
|
||||
- StackNavigationState,
|
||||
- Route,
|
||||
- ParamListBase,
|
||||
-} from '@react-navigation/native';
|
||||
+ NavigationState as StackNavigationState,
|
||||
+ NavigationActions,
|
||||
+ SceneView,
|
||||
+} from 'react-navigation';
|
||||
|
||||
import { GestureHandlerRootView } from '../GestureHandler';
|
||||
import CardStack from './CardStack';
|
||||
import KeyboardManager from '../KeyboardManager';
|
||||
@@ -15,6 +16,7 @@
|
||||
@@ -17,6 +16,7 @@
|
||||
} from '../Header/HeaderContainer';
|
||||
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
|
||||
import {
|
||||
import type {
|
||||
+ Route,
|
||||
StackNavigationHelpers,
|
||||
StackNavigationConfig,
|
||||
StackDescriptorMap,
|
||||
@@ -24,6 +26,7 @@
|
||||
state: StackNavigationState;
|
||||
@@ -24,9 +24,10 @@
|
||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||
|
||||
type Props = StackNavigationConfig & {
|
||||
- state: StackNavigationState<ParamListBase>;
|
||||
+ state: StackNavigationState;
|
||||
navigation: StackNavigationHelpers;
|
||||
descriptors: StackDescriptorMap;
|
||||
+ screenProps: unknown;
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -292,7 +295,9 @@
|
||||
@@ -295,7 +296,9 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -551,7 +603,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -320,23 +325,44 @@
|
||||
@@ -323,26 +326,49 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -587,22 +639,24 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
+
|
||||
private handleOpenRoute = ({ route }: { route: Route<string> }) => {
|
||||
const { state, navigation } = this.props;
|
||||
const { closingRouteKeys, replacingRouteKeys } = this.state;
|
||||
|
||||
- if (
|
||||
- state.routeNames.includes(route.name) &&
|
||||
- !state.routes.some((r) => r.key === route.key)
|
||||
- ) {
|
||||
+ this.handleTransitionComplete();
|
||||
+
|
||||
+ if (!state.routes.some((r) => r.key === route.key)) {
|
||||
// If route isn't present in current state, assume that a close animation was cancelled
|
||||
if (
|
||||
closingRouteKeys.some((key) => key === route.key) &&
|
||||
replacingRouteKeys.every((key) => key !== route.key) &&
|
||||
- state.routeNames.includes(route.name) &&
|
||||
!state.routes.some((r) => r.key === route.key)
|
||||
) {
|
||||
// If route isn't present in current state, but was closing, assume that a close animation was cancelled
|
||||
// So we need to add this route back to the state
|
||||
- navigation.navigate(route);
|
||||
+ navigation.dispatch(NavigationActions.navigate(route));
|
||||
} else {
|
||||
this.setState((state) => ({
|
||||
routes: state.replacingRouteKeys.length
|
||||
@@ -362,12 +388,11 @@
|
||||
@@ -368,12 +394,11 @@
|
||||
// If a route exists in state, trigger a pop
|
||||
// This will happen in when the route was closed from the card component
|
||||
// e.g. When the close animation triggered from a gesture ends
|
||||
@@ -619,7 +673,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
// We need to clean up any state tracking the route and pop it immediately
|
||||
this.setState((state) => ({
|
||||
routes: state.routes.filter((r) => r.key !== route.key),
|
||||
@@ -384,22 +409,24 @@
|
||||
@@ -390,47 +415,41 @@
|
||||
private handleTransitionStart = (
|
||||
{ route }: { route: Route<string> },
|
||||
closing: boolean
|
||||
@@ -646,13 +700,68 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
- data: { closing },
|
||||
- target: route.key,
|
||||
- });
|
||||
-
|
||||
- private handleGestureStart = ({ route }: { route: Route<string> }) => {
|
||||
- this.props.navigation.emit({
|
||||
- type: 'gestureStart',
|
||||
- target: route.key,
|
||||
- });
|
||||
- };
|
||||
-
|
||||
- private handleGestureEnd = ({ route }: { route: Route<string> }) => {
|
||||
- this.props.navigation.emit({
|
||||
- type: 'gestureEnd',
|
||||
- target: route.key,
|
||||
- });
|
||||
- };
|
||||
-
|
||||
- private handleGestureCancel = ({ route }: { route: Route<string> }) => {
|
||||
- this.props.navigation.emit({
|
||||
- type: 'gestureCancel',
|
||||
- target: route.key,
|
||||
- });
|
||||
+ ) => {
|
||||
+ const { descriptors } = this.props;
|
||||
+ const descriptor =
|
||||
+ descriptors[route.key] || this.state.descriptors[route.key];
|
||||
+
|
||||
+ descriptor?.options.onTransitionEnd?.({ closing });
|
||||
+ descriptor?.options.onTransitionStart?.({ closing });
|
||||
+ };
|
||||
+
|
||||
+ private handleGestureStart = () => {
|
||||
+ // Do nothing
|
||||
+ };
|
||||
+
|
||||
+ private handleGestureEnd = () => {
|
||||
+ // Do nothing
|
||||
+ };
|
||||
+
|
||||
+ private handleGestureCancel = () => {
|
||||
+ // Do nothing
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
state,
|
||||
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
navigation,
|
||||
keyboardHandlingEnabled,
|
||||
mode = 'card',
|
||||
@@ -450,7 +469,7 @@
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
- <NavigationHelpersContext.Provider value={navigation}>
|
||||
+ <>
|
||||
<GestureHandlerWrapper style={styles.container}>
|
||||
<SafeAreaProviderCompat>
|
||||
<SafeAreaConsumer>
|
||||
@@ -491,7 +510,7 @@
|
||||
</SafeAreaConsumer>
|
||||
</SafeAreaProviderCompat>
|
||||
</GestureHandlerWrapper>
|
||||
- </NavigationHelpersContext.Provider>
|
||||
+ </>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -8,12 +8,117 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"zIndex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
importantForAccessibility="auto"
|
||||
onLayout={[Function]}
|
||||
pointerEvents="box-none"
|
||||
style={null}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"opacity": 1,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "#fff",
|
||||
"borderBottomColor": "#a7a7aa",
|
||||
"flex": 1,
|
||||
"shadowColor": "#a7a7aa",
|
||||
"shadowOffset": Object {
|
||||
"height": 0.5,
|
||||
"width": 0,
|
||||
},
|
||||
"shadowOpacity": 0.85,
|
||||
"shadowRadius": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"height": 44,
|
||||
"maxHeight": undefined,
|
||||
"minHeight": undefined,
|
||||
"opacity": undefined,
|
||||
"transform": undefined,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"height": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"justifyContent": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"marginHorizontal": 16,
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
accessibilityRole="header"
|
||||
aria-level="1"
|
||||
numberOfLines={1}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(0, 0, 0, 0.9)",
|
||||
"fontSize": 17,
|
||||
"fontWeight": "600",
|
||||
}
|
||||
}
|
||||
>
|
||||
Sub
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -29,6 +134,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
style={
|
||||
Object {
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
closing={false}
|
||||
@@ -37,6 +150,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
onClose={[Function]}
|
||||
onGestureBegin={[Function]}
|
||||
onGestureCanceled={[Function]}
|
||||
onGestureEnd={[Function]}
|
||||
onOpen={[Function]}
|
||||
onTransitionStart={[Function]}
|
||||
pointerEvents="box-none"
|
||||
@@ -57,8 +171,8 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -68,8 +182,8 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -77,11 +191,11 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
}
|
||||
>
|
||||
<View
|
||||
needsOffscreenAlphaCompositing={false}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 44,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -174,7 +288,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -190,6 +303,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
style={
|
||||
Object {
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
closing={false}
|
||||
@@ -198,6 +319,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
onClose={[Function]}
|
||||
onGestureBegin={[Function]}
|
||||
onGestureCanceled={[Function]}
|
||||
onGestureEnd={[Function]}
|
||||
onOpen={[Function]}
|
||||
onTransitionStart={[Function]}
|
||||
pointerEvents="box-none"
|
||||
@@ -218,8 +340,8 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -229,8 +351,8 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -238,11 +360,12 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
}
|
||||
>
|
||||
<View
|
||||
needsOffscreenAlphaCompositing={false}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 44,
|
||||
"marginTop": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -335,109 +458,15 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"height": 44,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
importantForAccessibility="auto"
|
||||
onLayout={[Function]}
|
||||
pointerEvents="box-none"
|
||||
style={null}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"opacity": 1,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "#fff",
|
||||
"borderBottomColor": "#a7a7aa",
|
||||
"flex": 1,
|
||||
"shadowColor": "#a7a7aa",
|
||||
"shadowOffset": Object {
|
||||
"height": 0.5,
|
||||
"width": 0,
|
||||
},
|
||||
"shadowOpacity": 0.85,
|
||||
"shadowRadius": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"height": 44,
|
||||
"maxHeight": undefined,
|
||||
"minHeight": undefined,
|
||||
"opacity": undefined,
|
||||
"transform": undefined,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"height": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"justifyContent": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"marginHorizontal": 18,
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
accessibilityRole="header"
|
||||
numberOfLines={1}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(0, 0, 0, 0.9)",
|
||||
"fontSize": 17,
|
||||
"fontWeight": "600",
|
||||
}
|
||||
}
|
||||
>
|
||||
Home
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
@@ -448,113 +477,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
importantForAccessibility="auto"
|
||||
onLayout={[Function]}
|
||||
pointerEvents="box-none"
|
||||
style={null}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"opacity": 1,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "#fff",
|
||||
"borderBottomColor": "#a7a7aa",
|
||||
"flex": 1,
|
||||
"shadowColor": "#a7a7aa",
|
||||
"shadowOffset": Object {
|
||||
"height": 0.5,
|
||||
"width": 0,
|
||||
},
|
||||
"shadowOpacity": 0.85,
|
||||
"shadowRadius": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"height": 44,
|
||||
"maxHeight": undefined,
|
||||
"minHeight": undefined,
|
||||
"opacity": undefined,
|
||||
"transform": undefined,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"height": 0,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"justifyContent": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"marginHorizontal": 18,
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
accessibilityRole="header"
|
||||
numberOfLines={1}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(0, 0, 0, 0.9)",
|
||||
"fontSize": 17,
|
||||
"fontWeight": "600",
|
||||
}
|
||||
}
|
||||
>
|
||||
Sub
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
|
||||
@@ -8,176 +8,11 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
closing={false}
|
||||
gestureVelocityImpact={0.3}
|
||||
importantForAccessibility="auto"
|
||||
onClose={[Function]}
|
||||
onGestureBegin={[Function]}
|
||||
onGestureCanceled={[Function]}
|
||||
onOpen={[Function]}
|
||||
onTransitionStart={[Function]}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
transitionSpec={
|
||||
Object {
|
||||
"close": Object {
|
||||
"animation": "spring",
|
||||
"config": Object {
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
"open": Object {
|
||||
"animation": "spring",
|
||||
"config": Object {
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 44,
|
||||
}
|
||||
}
|
||||
>
|
||||
<PanGestureHandler
|
||||
enabled={false}
|
||||
hitSlop={
|
||||
Object {
|
||||
"right": -700,
|
||||
}
|
||||
}
|
||||
maxDeltaY={20}
|
||||
minOffsetX={5}
|
||||
onHandlerStateChange={[Function]}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"transform": Array [
|
||||
Object {
|
||||
"translateX": 0,
|
||||
},
|
||||
Object {
|
||||
"translateX": 0,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "rgb(242, 242, 242)",
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"shadowColor": "#000",
|
||||
"shadowOffset": Object {
|
||||
"height": 1,
|
||||
"width": -1,
|
||||
},
|
||||
"shadowOpacity": 0.3,
|
||||
"shadowRadius": 5,
|
||||
"top": 0,
|
||||
"width": 3,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
},
|
||||
Array [
|
||||
Object {
|
||||
"backgroundColor": "rgb(242, 242, 242)",
|
||||
},
|
||||
undefined,
|
||||
],
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "column-reverse",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</PanGestureHandler>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -189,7 +24,7 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
style={null}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
@@ -198,6 +33,7 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -254,13 +90,14 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"marginHorizontal": 18,
|
||||
"marginHorizontal": 16,
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
accessibilityRole="header"
|
||||
aria-level="1"
|
||||
numberOfLines={1}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
@@ -294,23 +131,11 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`StackNavigator renders successfully 1`] = `
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -326,6 +151,14 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
style={
|
||||
Object {
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
closing={false}
|
||||
@@ -334,6 +167,7 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
onClose={[Function]}
|
||||
onGestureBegin={[Function]}
|
||||
onGestureCanceled={[Function]}
|
||||
onGestureEnd={[Function]}
|
||||
onOpen={[Function]}
|
||||
onTransitionStart={[Function]}
|
||||
pointerEvents="box-none"
|
||||
@@ -354,8 +188,8 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -365,8 +199,8 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 0.01,
|
||||
"restSpeedThreshold": 0.01,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
@@ -374,11 +208,11 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
}
|
||||
>
|
||||
<View
|
||||
needsOffscreenAlphaCompositing={false}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 44,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -467,14 +301,22 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`StackNavigator renders successfully 1`] = `
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -486,7 +328,7 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
style={null}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
@@ -495,6 +337,7 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
"zIndex": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -551,13 +394,14 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"marginHorizontal": 18,
|
||||
"marginHorizontal": 16,
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
accessibilityRole="header"
|
||||
aria-level="1"
|
||||
numberOfLines={1}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
@@ -575,5 +419,175 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
style={
|
||||
Object {
|
||||
"opacity": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
accessibilityElementsHidden={false}
|
||||
closing={false}
|
||||
gestureVelocityImpact={0.3}
|
||||
importantForAccessibility="auto"
|
||||
onClose={[Function]}
|
||||
onGestureBegin={[Function]}
|
||||
onGestureCanceled={[Function]}
|
||||
onGestureEnd={[Function]}
|
||||
onOpen={[Function]}
|
||||
onTransitionStart={[Function]}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"right": 0,
|
||||
"top": 0,
|
||||
}
|
||||
}
|
||||
transitionSpec={
|
||||
Object {
|
||||
"close": Object {
|
||||
"animation": "spring",
|
||||
"config": Object {
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
"open": Object {
|
||||
"animation": "spring",
|
||||
"config": Object {
|
||||
"damping": 500,
|
||||
"mass": 3,
|
||||
"overshootClamping": true,
|
||||
"restDisplacementThreshold": 10,
|
||||
"restSpeedThreshold": 10,
|
||||
"stiffness": 1000,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
needsOffscreenAlphaCompositing={false}
|
||||
pointerEvents="box-none"
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<PanGestureHandler
|
||||
enabled={false}
|
||||
hitSlop={
|
||||
Object {
|
||||
"right": -700,
|
||||
}
|
||||
}
|
||||
maxDeltaY={20}
|
||||
minOffsetX={5}
|
||||
onHandlerStateChange={[Function]}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"transform": Array [
|
||||
Object {
|
||||
"translateX": 0,
|
||||
},
|
||||
Object {
|
||||
"translateX": 0,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "rgb(242, 242, 242)",
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"position": "absolute",
|
||||
"shadowColor": "#000",
|
||||
"shadowOffset": Object {
|
||||
"height": 1,
|
||||
"width": -1,
|
||||
},
|
||||
"shadowOpacity": 0.3,
|
||||
"shadowRadius": 5,
|
||||
"top": 0,
|
||||
"width": 3,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"overflow": "hidden",
|
||||
},
|
||||
Array [
|
||||
Object {
|
||||
"backgroundColor": "rgb(242, 242, 242)",
|
||||
},
|
||||
undefined,
|
||||
],
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "column-reverse",
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</PanGestureHandler>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
CreateNavigatorConfig,
|
||||
} from 'react-navigation';
|
||||
import StackView from '../views/StackView';
|
||||
import {
|
||||
import type {
|
||||
StackNavigationConfig,
|
||||
StackNavigationOptions,
|
||||
StackNavigationProp,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
@@ -289,8 +289,8 @@ export function forScaleFromCenterAndroid({
|
||||
);
|
||||
|
||||
const opacity = progress.interpolate({
|
||||
inputRange: [0, 0.8, 1, 1.2, 2],
|
||||
outputRange: [0, 0.5, 1, 0.33, 0],
|
||||
inputRange: [0, 0.75, 0.875, 1, 1.0825, 1.2075, 2],
|
||||
outputRange: [0, 0, 1, 1, 1, 1, 0],
|
||||
});
|
||||
|
||||
const scale = conditional(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Animated, I18nManager } from 'react-native';
|
||||
import {
|
||||
import type {
|
||||
StackHeaderInterpolationProps,
|
||||
StackHeaderInterpolatedStyle,
|
||||
} from '../types';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Platform } from 'react-native';
|
||||
import {
|
||||
forHorizontalIOS,
|
||||
forVerticalIOS,
|
||||
@@ -14,10 +15,10 @@ import {
|
||||
FadeOutToBottomAndroidSpec,
|
||||
FadeInFromBottomAndroidSpec,
|
||||
} from './TransitionSpecs';
|
||||
import { TransitionPreset } from '../types';
|
||||
import { Platform } from 'react-native';
|
||||
import type { TransitionPreset } from '../types';
|
||||
|
||||
const ANDROID_VERSION_PIE = 28;
|
||||
const ANDROID_VERSION_10 = 29;
|
||||
|
||||
/**
|
||||
* Standard iOS navigation transition.
|
||||
@@ -102,10 +103,13 @@ export const ScaleFromCenterAndroid: TransitionPreset = {
|
||||
*/
|
||||
export const DefaultTransition = Platform.select({
|
||||
ios: SlideFromRightIOS,
|
||||
default:
|
||||
Platform.OS === 'android' && Platform.Version >= ANDROID_VERSION_PIE
|
||||
android:
|
||||
Platform.Version >= ANDROID_VERSION_10
|
||||
? ScaleFromCenterAndroid
|
||||
: Platform.Version >= ANDROID_VERSION_PIE
|
||||
? RevealFromBottomAndroid
|
||||
: FadeFromBottomAndroid,
|
||||
default: ScaleFromCenterAndroid,
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -11,8 +11,8 @@ export const TransitionIOSSpec: TransitionSpec = {
|
||||
damping: 500,
|
||||
mass: 3,
|
||||
overshootClamping: true,
|
||||
restDisplacementThreshold: 0.01,
|
||||
restSpeedThreshold: 0.01,
|
||||
restDisplacementThreshold: 10,
|
||||
restSpeedThreshold: 10,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
73
packages/stack/src/vendor/types.tsx
vendored
73
packages/stack/src/vendor/types.tsx
vendored
@@ -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,
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from 'react-navigation';
|
||||
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export type Route<T extends string> = NavigationRoute;
|
||||
|
||||
export type NavigationStackState = NavigationState;
|
||||
@@ -40,9 +41,22 @@ export type StackNavigationEventMap = {
|
||||
* Event which fires when a transition animation ends.
|
||||
*/
|
||||
transitionEnd: { data: { closing: boolean } };
|
||||
/**
|
||||
* Event which fires when navigation gesture starts.
|
||||
*/
|
||||
gestureStart: { data: undefined };
|
||||
/**
|
||||
* Event which fires when navigation gesture is completed.
|
||||
*/
|
||||
gestureEnd: { data: undefined };
|
||||
/**
|
||||
* Event which fires when navigation gesture is canceled.
|
||||
*/
|
||||
gestureCancel: { data: undefined };
|
||||
};
|
||||
|
||||
export type StackNavigationHelpers = NavigationProp<NavigationStackState>;
|
||||
|
||||
export type StackNavigationProp<
|
||||
State = NavigationRoute,
|
||||
Params = NavigationParams
|
||||
@@ -124,14 +138,14 @@ export type StackHeaderOptions = {
|
||||
/**
|
||||
* Style object for the title component.
|
||||
*/
|
||||
headerTitleStyle?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||
headerTitleStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
||||
/**
|
||||
* Style object for the container of the `headerTitle` component, for example to add padding.
|
||||
* By default, `headerTitleContainerStyle` is with an absolute position style and offsets both `left` and `right`.
|
||||
* This may lead to white space or overlap between `headerLeft` and `headerTitle` if a customized `headerLeft` is used.
|
||||
* It can be solved by adjusting `left` and `right` style in `headerTitleContainerStyle` and `marginHorizontal` in `headerTitleStyle`.
|
||||
*/
|
||||
headerTitleContainerStyle?: StyleProp<ViewStyle>;
|
||||
headerTitleContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||
/**
|
||||
* Tint color for the header.
|
||||
*/
|
||||
@@ -145,7 +159,8 @@ export type StackHeaderOptions = {
|
||||
*/
|
||||
headerBackAllowFontScaling?: boolean;
|
||||
/**
|
||||
* Title string used by the back button on iOS, or `null` to disable label. Defaults to the previous scene's `headerTitle`.
|
||||
* Title string used by the back button on iOS. Defaults to the previous scene's `headerTitle`.
|
||||
* Use `headerBackTitleVisible: false` to hide it.
|
||||
*/
|
||||
headerBackTitle?: string;
|
||||
/**
|
||||
@@ -169,7 +184,7 @@ export type StackHeaderOptions = {
|
||||
/**
|
||||
* Style object for the container of the `headerLeft` component, for example to add padding.
|
||||
*/
|
||||
headerLeftContainerStyle?: StyleProp<ViewStyle>;
|
||||
headerLeftContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||
/**
|
||||
* Function which returns a React Element to display on the right side of the header.
|
||||
*/
|
||||
@@ -177,7 +192,7 @@ export type StackHeaderOptions = {
|
||||
/**
|
||||
* Style object for the container of the `headerRight` component, for example to add padding.
|
||||
*/
|
||||
headerRightContainerStyle?: StyleProp<ViewStyle>;
|
||||
headerRightContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||
/**
|
||||
* Function which returns a React Element to display custom image in header's back button.
|
||||
* It receives the `tintColor` in in the options object as an argument. object.
|
||||
@@ -199,7 +214,7 @@ export type StackHeaderOptions = {
|
||||
/**
|
||||
* Style object for the header. You can specify a custom background color here, for example.
|
||||
*/
|
||||
headerStyle?: StyleProp<ViewStyle>;
|
||||
headerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||
/**
|
||||
* Defaults to `false`. If `true`, the header will not have a background unless you explicitly provide it with `headerBackground`.
|
||||
* The header will also float over the screen so that it overlaps the content underneath.
|
||||
@@ -287,7 +302,9 @@ export type StackNavigationOptions = StackHeaderOptions &
|
||||
/**
|
||||
* Function that returns a React Element to display as a overlay for the card.
|
||||
*/
|
||||
cardOverlay?: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||
cardOverlay?: (props: {
|
||||
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||
}) => React.ReactNode;
|
||||
/**
|
||||
* Style object for the card in stack.
|
||||
* You can provide a custom background color to use instead of the default background here.
|
||||
@@ -300,7 +317,8 @@ export type StackNavigationOptions = StackHeaderOptions &
|
||||
cardStyle?: StyleProp<ViewStyle>;
|
||||
/**
|
||||
* Whether transition animation should be enabled the screen.
|
||||
* If you set it to `false`, the screen won't animate when pushing or popping. Defaults to `true`.
|
||||
* 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.
|
||||
*/
|
||||
animationEnabled?: boolean;
|
||||
/**
|
||||
@@ -310,24 +328,26 @@ export type StackNavigationOptions = StackHeaderOptions &
|
||||
animationTypeForReplace?: 'push' | 'pop';
|
||||
/**
|
||||
* Whether you can use gestures to dismiss this screen. Defaults to `true` on iOS, `false` on Android.
|
||||
* Not supported on Web.
|
||||
*/
|
||||
gestureEnabled?: boolean;
|
||||
/**
|
||||
* Object to override the distance of touch start from the edge of the screen to recognize gestures.
|
||||
* Not supported on Web.
|
||||
*/
|
||||
gestureResponseDistance?: {
|
||||
/**
|
||||
* Distance for horizontal direction. Defaults to 25.
|
||||
* Distance for vertical direction. Defaults to 135.
|
||||
*/
|
||||
vertical?: number;
|
||||
/**
|
||||
* Distance for vertical direction. Defaults to 135.
|
||||
* Distance for horizontal direction. Defaults to 25.
|
||||
*/
|
||||
horizontal?: number;
|
||||
};
|
||||
/**
|
||||
* Number which determines the relevance of velocity for the gesture.
|
||||
* Defaults to 0.3.
|
||||
* Number which determines the relevance of velocity for the gesture. Defaults to 0.3.
|
||||
* Not supported on Web.
|
||||
*/
|
||||
gestureVelocityImpact?: number;
|
||||
/**
|
||||
@@ -341,6 +361,13 @@ export type StackNavigationOptions = StackHeaderOptions &
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
};
|
||||
/**
|
||||
* Whether to detach the previous screen from the view hierarchy to save memory.
|
||||
* Set it to `false` if you need the previous screen to be seen through the active screen.
|
||||
* Only applicable if `detachInactiveScreens` isn't set to `false`.
|
||||
* Defaults to `false` for the last screen when mode='modal', otherwise `true`.
|
||||
*/
|
||||
detachPreviousScreen?: boolean;
|
||||
onTransitionStart?: (props: TransitionCallbackProps) => void;
|
||||
onTransitionEnd?: (props: TransitionCallbackProps) => void;
|
||||
};
|
||||
@@ -353,6 +380,12 @@ export type StackNavigationConfig = {
|
||||
* Defaults to `true`.
|
||||
*/
|
||||
keyboardHandlingEnabled?: boolean;
|
||||
/**
|
||||
* Whether inactive screens should be detached from the view hierarchy to save memory.
|
||||
* Make sure to call `enableScreens` from `react-native-screens` to make it work.
|
||||
* Defaults to `true` on Android, `false` on iOS.
|
||||
*/
|
||||
detachInactiveScreens?: boolean;
|
||||
};
|
||||
|
||||
export type StackHeaderLeftButtonProps = {
|
||||
@@ -394,7 +427,7 @@ export type StackHeaderLeftButtonProps = {
|
||||
/**
|
||||
* Style object for the label.
|
||||
*/
|
||||
labelStyle?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
||||
/**
|
||||
* Whether label font should scale to respect Text Size accessibility settings.
|
||||
*/
|
||||
@@ -419,6 +452,10 @@ export type StackHeaderLeftButtonProps = {
|
||||
* Accessibility label for the button for screen readers.
|
||||
*/
|
||||
accessibilityLabel?: string;
|
||||
/**
|
||||
* Style object for the button.
|
||||
*/
|
||||
style?: StyleProp<ViewStyle>;
|
||||
};
|
||||
|
||||
export type StackHeaderTitleProps = {
|
||||
@@ -441,7 +478,7 @@ export type StackHeaderTitleProps = {
|
||||
/**
|
||||
* Style object for the title element.
|
||||
*/
|
||||
style?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
||||
};
|
||||
|
||||
export type TransitionSpec =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { PanGestureHandler } from 'react-native-gesture-handler';
|
||||
|
||||
export default React.createContext<React.Ref<PanGestureHandler> | undefined>(
|
||||
undefined
|
||||
);
|
||||
export default React.createContext<React.Ref<
|
||||
import('react-native-gesture-handler').PanGestureHandler
|
||||
> | null>(null);
|
||||
|
||||
5
packages/stack/src/vendor/utils/HeaderShownContext.tsx
vendored
Normal file
5
packages/stack/src/vendor/utils/HeaderShownContext.tsx
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as React from 'react';
|
||||
|
||||
const HeaderShownContext = React.createContext(false);
|
||||
|
||||
export default HeaderShownContext;
|
||||
8
packages/stack/src/vendor/utils/PreviousSceneContext.tsx
vendored
Normal file
8
packages/stack/src/vendor/utils/PreviousSceneContext.tsx
vendored
Normal 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;
|
||||
@@ -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,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { I18nManager } from 'react-native';
|
||||
import { GestureDirection } from '../types';
|
||||
import type { GestureDirection } from '../types';
|
||||
|
||||
export default function getInvertedMultiplier(
|
||||
gestureDirection: GestureDirection
|
||||
|
||||
@@ -39,7 +39,6 @@ export default class BorderlessButton extends React.Component<Props> {
|
||||
const { children, style, enabled, ...rest } = this.props;
|
||||
|
||||
return (
|
||||
// @ts-ignore
|
||||
<AnimatedBaseButton
|
||||
{...rest}
|
||||
onActiveStateChange={this.handleActiveStateChange}
|
||||
|
||||
1
packages/stack/src/vendor/views/GestureHandler.android.tsx
vendored
Normal file
1
packages/stack/src/vendor/views/GestureHandler.android.tsx
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './GestureHandlerNative';
|
||||
1
packages/stack/src/vendor/views/GestureHandler.ios.tsx
vendored
Normal file
1
packages/stack/src/vendor/views/GestureHandler.ios.tsx
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './GestureHandlerNative';
|
||||
24
packages/stack/src/vendor/views/GestureHandler.tsx
vendored
Normal file
24
packages/stack/src/vendor/views/GestureHandler.tsx
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import type { PanGestureHandlerProperties } from 'react-native-gesture-handler';
|
||||
|
||||
const Dummy: any = ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
);
|
||||
|
||||
export const PanGestureHandler = Dummy as React.ComponentType<
|
||||
PanGestureHandlerProperties
|
||||
>;
|
||||
|
||||
export const GestureHandlerRootView = View;
|
||||
|
||||
export const GestureState = {
|
||||
UNDETERMINED: 0,
|
||||
FAILED: 1,
|
||||
BEGAN: 2,
|
||||
CANCELLED: 3,
|
||||
ACTIVE: 4,
|
||||
END: 5,
|
||||
};
|
||||
|
||||
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
|
||||
22
packages/stack/src/vendor/views/GestureHandlerNative.tsx
vendored
Normal file
22
packages/stack/src/vendor/views/GestureHandlerNative.tsx
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
PanGestureHandler as PanGestureHandlerNative,
|
||||
PanGestureHandlerProperties,
|
||||
} from 'react-native-gesture-handler';
|
||||
import GestureHandlerRefContext from '../utils/GestureHandlerRefContext';
|
||||
|
||||
export function PanGestureHandler(props: PanGestureHandlerProperties) {
|
||||
const gestureRef = React.useRef<PanGestureHandlerNative>(null);
|
||||
|
||||
return (
|
||||
<GestureHandlerRefContext.Provider value={gestureRef}>
|
||||
<PanGestureHandlerNative {...props} ref={gestureRef} />
|
||||
</GestureHandlerRefContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
GestureHandlerRootView,
|
||||
State as GestureState,
|
||||
PanGestureHandlerGestureEvent,
|
||||
} from 'react-native-gesture-handler';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user