mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-17 17:42:46 +08:00
Compare commits
20 Commits
react-navi
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162e225fa4 | ||
|
|
ce9991ffff | ||
|
|
3bb21e256f | ||
|
|
f1a06e2f92 | ||
|
|
c0763fca16 | ||
|
|
62da341b67 | ||
|
|
09a10faa44 | ||
|
|
b9ecbd222d | ||
|
|
a57e47786c | ||
|
|
424923019a | ||
|
|
06a69f1bfd | ||
|
|
1fa2edd9f2 | ||
|
|
fcd7d83c4c | ||
|
|
4f7983134b | ||
|
|
46b797dd29 | ||
|
|
1a6f4a581f | ||
|
|
2e7f4a6d10 | ||
|
|
6515fbe2dc | ||
|
|
454e05b02e | ||
|
|
442ca3e700 |
@@ -14,5 +14,8 @@
|
|||||||
"react-native-screens"
|
"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 { registerRootComponent } from 'expo';
|
||||||
import {
|
import {
|
||||||
Animated,
|
Animated,
|
||||||
@@ -346,6 +346,7 @@ class MainScreen extends React.Component<any, State> {
|
|||||||
if (route.screen || route.path || route.params) {
|
if (route.screen || route.path || route.params) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { path, params, screen } = route;
|
const { path, params, screen } = route;
|
||||||
|
// @ts-ignore
|
||||||
const { router } = screen;
|
const { router } = screen;
|
||||||
const action =
|
const action =
|
||||||
path &&
|
path &&
|
||||||
@@ -386,6 +387,7 @@ class MainScreen extends React.Component<any, State> {
|
|||||||
|
|
||||||
const Navigation = createAppContainer(
|
const Navigation = createAppContainer(
|
||||||
createStackNavigator(
|
createStackNavigator(
|
||||||
|
// @ts-ignore
|
||||||
{
|
{
|
||||||
...ExampleInfo,
|
...ExampleInfo,
|
||||||
Index: {
|
Index: {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"slug": "react-navigation-4-example",
|
"slug": "react-navigation-4-example",
|
||||||
"description": "Demo app to showcase various functionality of React Navigation",
|
"description": "Demo app to showcase various functionality of React Navigation",
|
||||||
"privacy": "public",
|
"privacy": "public",
|
||||||
"sdkVersion": "36.0.0",
|
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"ios",
|
"ios",
|
||||||
"android",
|
"android",
|
||||||
|
|||||||
@@ -8,29 +8,29 @@
|
|||||||
"ios": "expo start --ios"
|
"ios": "expo start --ios"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.8.7",
|
"@babel/runtime": "^7.11.0",
|
||||||
"@expo/vector-icons": "^10.0.6",
|
"@expo/vector-icons": "^10.0.0",
|
||||||
"@react-native-community/masked-view": "0.1.7",
|
"@react-native-community/masked-view": "0.1.10",
|
||||||
"expo": "^36.0.0",
|
"expo": "^39.0.0",
|
||||||
"expo-asset": "~8.0.0",
|
"expo-asset": "~8.2.0",
|
||||||
"expo-barcode-scanner": "^8.0.0",
|
"expo-barcode-scanner": "~9.0.0",
|
||||||
"expo-blur": "~8.0.0",
|
"expo-blur": "~8.2.0",
|
||||||
"expo-constants": "~8.0.0",
|
"expo-constants": "~9.2.0",
|
||||||
"hoist-non-react-statics": "^3.3.1",
|
"hoist-non-react-statics": "^3.3.1",
|
||||||
"react": "16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
|
"react-native": "~0.63.2",
|
||||||
"react-native-gesture-handler": "~1.6.0",
|
"react-native-gesture-handler": "~1.7.0",
|
||||||
"react-native-iphone-x-helper": "^1.2.1",
|
"react-native-iphone-x-helper": "^1.2.1",
|
||||||
"react-native-maps": "0.27.0",
|
"react-native-maps": "0.27.1",
|
||||||
"react-native-paper": "^3.4.0",
|
"react-native-paper": "^4.0.1",
|
||||||
"react-native-reanimated": "~1.7.0",
|
"react-native-reanimated": "~1.13.0",
|
||||||
"react-native-safe-area-context": "0.7.3",
|
"react-native-safe-area-context": "3.1.4",
|
||||||
"react-native-screens": "2.3.0",
|
"react-native-screens": "~2.10.1",
|
||||||
"react-native-webview": "8.1.2",
|
"react-native-webview": "10.7.0",
|
||||||
"react-navigation-header-buttons": "^3.0.5"
|
"react-navigation-header-buttons": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-plugin-module-resolver": "^4.0.0",
|
"babel-plugin-module-resolver": "^4.0.0",
|
||||||
"expo-cli": "^3.13.8"
|
"expo-cli": "^3.27.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { ScrollView, StyleSheet } from 'react-native';
|
import { ScrollView, StyleSheet } from 'react-native';
|
||||||
import { BorderlessButton } from 'react-native-gesture-handler';
|
import { BorderlessButton } from 'react-native-gesture-handler';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { View, Text, StyleSheet, Dimensions } from 'react-native';
|
import { View, Text, StyleSheet, Dimensions } from 'react-native';
|
||||||
import { NavigationStackScreenComponent } from 'react-navigation-stack';
|
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 { ScrollView, StyleProp, TextStyle } from 'react-native';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Button, ScrollView, View, Text } from 'react-native';
|
import { Button, ScrollView, View, Text } from 'react-native';
|
||||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Dimensions,
|
Dimensions,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
AccessibilityStates,
|
|
||||||
Platform,
|
Platform,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
@@ -88,11 +87,9 @@ export default class Button extends React.Component<ButtonProps> {
|
|||||||
buttonStyles.push({ backgroundColor: color });
|
buttonStyles.push({ backgroundColor: color });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const accessibilityStates: AccessibilityStates[] = [];
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
buttonStyles.push(styles.buttonDisabled);
|
buttonStyles.push(styles.buttonDisabled);
|
||||||
textStyles.push(styles.textDisabled);
|
textStyles.push(styles.textDisabled);
|
||||||
accessibilityStates.push('disabled');
|
|
||||||
}
|
}
|
||||||
const formattedTitle =
|
const formattedTitle =
|
||||||
Platform.OS === 'android' ? title.toUpperCase() : title;
|
Platform.OS === 'android' ? title.toUpperCase() : title;
|
||||||
@@ -100,7 +97,7 @@ export default class Button extends React.Component<ButtonProps> {
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
accessibilityLabel={accessibilityLabel}
|
accessibilityLabel={accessibilityLabel}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityStates={accessibilityStates}
|
accessibilityState={{ disabled }}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Platform, StyleSheet, View } from 'react-native';
|
import { Platform, StyleSheet, View } from 'react-native';
|
||||||
import BaseButton, { ButtonProps } from './Button';
|
import BaseButton, { ButtonProps } from './Button';
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ class NavigationAwareScrollViewBase extends React.Component<{
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.subscription = this.props.navigation.addListener('refocus', () => {
|
this.subscription = this.props.navigation.addListener('refocus', () => {
|
||||||
if (this.props.navigation.isFocused()) {
|
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() {
|
componentWillUnmount() {
|
||||||
this.subscription && this.subscription.remove();
|
this.subscription?.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
setNativeProps(props: ScrollViewProperties) {
|
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 { Button, ScrollView, StyleSheet, View } from 'react-native';
|
||||||
import {
|
import {
|
||||||
ThemeColors,
|
ThemeColors,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Text, View } from 'react-native';
|
import { Text, View } from 'react-native';
|
||||||
import { Themed } from 'react-navigation';
|
import { Themed } from 'react-navigation';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Text } from 'react-native';
|
import { Text } from 'react-native';
|
||||||
import {
|
import {
|
||||||
Themed,
|
Themed,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { ScrollView, StatusBar } from 'react-native';
|
import { ScrollView, StatusBar } from 'react-native';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
ScrollView,
|
ScrollView,
|
||||||
StatusBar,
|
StatusBar,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Button, ScrollView } from 'react-native';
|
import { Button, ScrollView } from 'react-native';
|
||||||
import { Themed, SafeAreaView } from 'react-navigation';
|
import { Themed, SafeAreaView } from 'react-navigation';
|
||||||
import {
|
import {
|
||||||
@@ -91,8 +91,4 @@ const DrawerExample = createDrawerNavigator(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawerExample.navigationOptions = {
|
|
||||||
headerShown: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DrawerExample;
|
export default DrawerExample;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||||
import SimpleTabs from './SimpleTabs';
|
import SimpleTabs from './SimpleTabs';
|
||||||
|
|||||||
40
package.json
40
package.json
@@ -25,28 +25,28 @@
|
|||||||
"example": "yarn --cwd example"
|
"example": "yarn --cwd example"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
||||||
"@babel/preset-env": "^7.8.7",
|
"@babel/preset-env": "^7.11.0",
|
||||||
"@babel/preset-react": "^7.8.3",
|
"@babel/preset-react": "^7.10.4",
|
||||||
"@babel/preset-typescript": "^7.8.3",
|
"@babel/preset-typescript": "^7.10.4",
|
||||||
"@babel/runtime": "^7.8.7",
|
"@babel/runtime": "^7.11.0",
|
||||||
"@commitlint/config-conventional": "^8.3.4",
|
"@commitlint/config-conventional": "^11.0.0",
|
||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^26.0.8",
|
||||||
"babel-jest": "^25.2.3",
|
"babel-jest": "^26.2.2",
|
||||||
"commitlint": "^8.3.5",
|
"commitlint": "^11.0.0",
|
||||||
"core-js": "^3.6.4",
|
"core-js": "^3.6.5",
|
||||||
"eslint": "^7.0.0",
|
"eslint": "^7.6.0",
|
||||||
"eslint-config-satya164": "^3.1.7",
|
"eslint-config-satya164": "^3.1.8",
|
||||||
"husky": "^4.2.1",
|
"husky": "^4.2.5",
|
||||||
"jest": "^25.1.0",
|
"jest": "^26.2.2",
|
||||||
"lerna": "^3.20.2",
|
"lerna": "^3.22.1",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.1.2",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5"
|
"react-native": "~0.63.2"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [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
|
**Note:** Version bump only for package react-navigation-animated-switch
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-navigation-animated-switch",
|
"name": "react-navigation-animated-switch",
|
||||||
"version": "0.5.12",
|
"version": "0.6.1",
|
||||||
"description": "Animated switch for React Navigation",
|
"description": "Animated switch for React Navigation",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"react-native": "lib/module/index.js",
|
"react-native": "lib/module/index.js",
|
||||||
@@ -21,15 +21,15 @@
|
|||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "0.10.0",
|
"@react-native-community/bob": "0.16.2",
|
||||||
"@types/react": "16.9.23",
|
"@types/react": "16.9.49",
|
||||||
"@types/react-native": "0.61.22",
|
"@types/react-native": "0.63.20",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-native-reanimated": "~1.7.0",
|
"react-native-reanimated": "~1.13.0",
|
||||||
"react-navigation": "^4.3.9",
|
"react-navigation": "^4.4.1",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "*",
|
"react": "*",
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/core",
|
"name": "@react-navigation/core",
|
||||||
"version": "3.7.6",
|
"version": "3.7.7",
|
||||||
"description": "Core utilities for the react-navigation framework",
|
"description": "Core utilities for the react-navigation framework",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"react-native": "lib/module/index.js",
|
"react-native": "lib/module/index.js",
|
||||||
@@ -37,16 +37,16 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hoist-non-react-statics": "^3.3.2",
|
"hoist-non-react-statics": "^3.3.2",
|
||||||
"path-to-regexp": "^1.8.0",
|
"path-to-regexp": "^1.8.0",
|
||||||
"query-string": "^6.11.1",
|
"query-string": "^6.13.1",
|
||||||
"react-is": "^16.13.0"
|
"react-is": "^16.13.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.10.0",
|
"@react-native-community/bob": "^0.16.2",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-native-testing-library": "^1.12.0",
|
"react-native-testing-library": "^6.0.0",
|
||||||
"react-test-renderer": "^16.9.2"
|
"react-test-renderer": "~16.13.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "*"
|
"react": "*"
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ const StateUtils = {
|
|||||||
*/
|
*/
|
||||||
jumpTo(state, key) {
|
jumpTo(state, key) {
|
||||||
const index = StateUtils.indexOf(state, key);
|
const index = StateUtils.indexOf(state, key);
|
||||||
|
invariant(index !== -1, 'attempt to jump to unknown key "%s"', key);
|
||||||
return StateUtils.jumpToIndex(state, index);
|
return StateUtils.jumpToIndex(state, index);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable react/sort-comp */
|
/* eslint-disable react/sort-comp */
|
||||||
|
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { NavigationActions, getNavigation, NavigationProvider } from '../index';
|
import { NavigationActions, getNavigation, NavigationProvider } from '../index';
|
||||||
|
|
||||||
export default function createNavigationContainer(Component) {
|
export default function createNavigationContainer(Component) {
|
||||||
|
|||||||
@@ -3,32 +3,51 @@ import NavigationStateUtils from '../StateUtils';
|
|||||||
const routeName = 'Anything';
|
const routeName = 'Anything';
|
||||||
|
|
||||||
describe('StateUtils', () => {
|
describe('StateUtils', () => {
|
||||||
// Getters
|
describe('get', () => {
|
||||||
it('gets route', () => {
|
it('gets route', () => {
|
||||||
const state = {
|
const state = {
|
||||||
index: 0,
|
index: 0,
|
||||||
routes: [{ key: 'a', routeName }],
|
routes: [{ key: 'a', routeName }],
|
||||||
isTransitioning: false,
|
isTransitioning: false,
|
||||||
};
|
};
|
||||||
expect(NavigationStateUtils.get(state, 'a')).toEqual({
|
expect(NavigationStateUtils.get(state, 'a')).toEqual({
|
||||||
key: 'a',
|
key: 'a',
|
||||||
routeName,
|
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', () => {
|
describe('indexOf', () => {
|
||||||
const state = {
|
it('gets route index', () => {
|
||||||
index: 1,
|
const state = {
|
||||||
routes: [
|
index: 1,
|
||||||
{ key: 'a', routeName },
|
routes: [
|
||||||
{ key: 'b', routeName },
|
{ key: 'a', routeName },
|
||||||
],
|
{ key: 'b', routeName },
|
||||||
isTransitioning: false,
|
],
|
||||||
};
|
isTransitioning: false,
|
||||||
expect(NavigationStateUtils.indexOf(state, 'a')).toBe(0);
|
};
|
||||||
expect(NavigationStateUtils.indexOf(state, 'b')).toBe(1);
|
expect(NavigationStateUtils.indexOf(state, 'a')).toBe(0);
|
||||||
expect(NavigationStateUtils.indexOf(state, 'c')).toBe(-1);
|
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', () => {
|
it('has a route', () => {
|
||||||
@@ -44,303 +63,390 @@ describe('StateUtils', () => {
|
|||||||
expect(NavigationStateUtils.has(state, 'c')).toBe(false);
|
expect(NavigationStateUtils.has(state, 'c')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Push
|
describe('push', () => {
|
||||||
it('pushes a route', () => {
|
it('pushes a route', () => {
|
||||||
const state = {
|
const state = {
|
||||||
index: 0,
|
index: 0,
|
||||||
routes: [{ key: 'a', routeName }],
|
routes: [{ key: 'a', routeName }],
|
||||||
isTransitioning: false,
|
isTransitioning: false,
|
||||||
};
|
};
|
||||||
const newState = {
|
const newState = {
|
||||||
index: 1,
|
index: 1,
|
||||||
isTransitioning: false,
|
isTransitioning: false,
|
||||||
routes: [
|
routes: [
|
||||||
{ key: 'a', routeName },
|
{ key: 'a', routeName },
|
||||||
{ key: 'b', 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 },
|
|
||||||
],
|
],
|
||||||
0
|
};
|
||||||
)
|
expect(NavigationStateUtils.push(state, { key: 'b', routeName })).toEqual(
|
||||||
).toEqual(newState);
|
newState
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
NavigationStateUtils.reset(
|
|
||||||
state,
|
|
||||||
[
|
|
||||||
{ key: 'x', routeName },
|
|
||||||
{ key: 'y', routeName },
|
|
||||||
],
|
|
||||||
100
|
|
||||||
);
|
);
|
||||||
}).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 getNavigation from '../getNavigation';
|
||||||
|
import * as NavigationActions from '../NavigationActions';
|
||||||
|
|
||||||
it('getNavigation provides default action helpers', () => {
|
it('getNavigation provides default action helpers', () => {
|
||||||
const router = {
|
const router = {
|
||||||
@@ -22,12 +23,11 @@ it('getNavigation provides default action helpers', () => {
|
|||||||
topNav.navigate('GreatRoute');
|
topNav.navigate('GreatRoute');
|
||||||
|
|
||||||
expect(dispatch.mock.calls.length).toBe(1);
|
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');
|
expect(dispatch.mock.calls[0][0].routeName).toBe('GreatRoute');
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
it('getNavigation provides router action helpers', () => {
|
||||||
it.skip('getNavigation provides router action helpers', () => {
|
|
||||||
const router = {
|
const router = {
|
||||||
getActionCreators: () => ({
|
getActionCreators: () => ({
|
||||||
foo: (bar) => ({ type: 'FooBarAction', bar }),
|
foo: (bar) => ({ type: 'FooBarAction', bar }),
|
||||||
@@ -39,7 +39,8 @@ it.skip('getNavigation provides router action helpers', () => {
|
|||||||
|
|
||||||
const dispatch = jest.fn();
|
const dispatch = jest.fn();
|
||||||
|
|
||||||
const topNav = getNavigation(
|
let topNav;
|
||||||
|
topNav = getNavigation(
|
||||||
router,
|
router,
|
||||||
{},
|
{},
|
||||||
dispatch,
|
dispatch,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export default function getChildRouter(router: any, routeName: string) {
|
export default function getChildRouter(router: any, routeName: string) {
|
||||||
if (router.childRouters && router.childRouters[routeName]) {
|
if (router.childRouters?.[routeName]) {
|
||||||
return 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 (
|
if (
|
||||||
prevDescriptors &&
|
prevDescriptors &&
|
||||||
prevDescriptors[route.key] &&
|
prevDescriptors[route.key] &&
|
||||||
@@ -44,8 +44,8 @@ function createNavigator(NavigatorView, router, navigationConfig) {
|
|||||||
screenProps === currentState.screenProps &&
|
screenProps === currentState.screenProps &&
|
||||||
currentState.themeContext === currentState.theme
|
currentState.themeContext === currentState.theme
|
||||||
) {
|
) {
|
||||||
acc[route.key] = prevDescriptors[route.key];
|
descriptors[route.key] = prevDescriptors[route.key];
|
||||||
return acc;
|
return descriptors;
|
||||||
}
|
}
|
||||||
const getComponent = router.getComponentForRouteName.bind(
|
const getComponent = router.getComponentForRouteName.bind(
|
||||||
null,
|
null,
|
||||||
@@ -57,14 +57,14 @@ function createNavigator(NavigatorView, router, navigationConfig) {
|
|||||||
screenProps,
|
screenProps,
|
||||||
currentState.themeContext
|
currentState.themeContext
|
||||||
);
|
);
|
||||||
acc[route.key] = {
|
descriptors[route.key] = {
|
||||||
key: route.key,
|
key: route.key,
|
||||||
getComponent,
|
getComponent,
|
||||||
options,
|
options,
|
||||||
state: route,
|
state: route,
|
||||||
navigation: childNavigation,
|
navigation: childNavigation,
|
||||||
};
|
};
|
||||||
return acc;
|
return descriptors;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return { descriptors, screenProps, theme: state.themeContext };
|
return { descriptors, screenProps, theme: state.themeContext };
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default (routeConfigs, config = {}) => {
|
|||||||
const getCustomActionCreators =
|
const getCustomActionCreators =
|
||||||
config.getCustomActionCreators || defaultActionCreators;
|
config.getCustomActionCreators || defaultActionCreators;
|
||||||
|
|
||||||
const initialRouteParams = config.initialRouteParams;
|
const { initialRouteParams } = config;
|
||||||
const initialRouteName = config.initialRouteName || order[0];
|
const initialRouteName = config.initialRouteName || order[0];
|
||||||
const backBehavior = config.backBehavior || 'none';
|
const backBehavior = config.backBehavior || 'none';
|
||||||
const resetOnBlur = config.hasOwnProperty('resetOnBlur')
|
const resetOnBlur = config.hasOwnProperty('resetOnBlur')
|
||||||
@@ -59,7 +59,7 @@ export default (routeConfigs, config = {}) => {
|
|||||||
|
|
||||||
function resetChildRoute(routeName) {
|
function resetChildRoute(routeName) {
|
||||||
let initialParams =
|
let initialParams =
|
||||||
routeName === initialRouteName ? initialRouteParams : undefined;
|
routeName === initialRouteName ? initialRouteParams : null;
|
||||||
// note(brentvatne): merging initialRouteParams *on top* of default params
|
// note(brentvatne): merging initialRouteParams *on top* of default params
|
||||||
// on the route seems incorrect but it's consistent with existing behavior
|
// on the route seems incorrect but it's consistent with existing behavior
|
||||||
// in stackrouter
|
// in stackrouter
|
||||||
@@ -71,13 +71,13 @@ export default (routeConfigs, config = {}) => {
|
|||||||
...childRouter.getStateForAction(childAction),
|
...childRouter.getStateForAction(childAction),
|
||||||
key: routeName,
|
key: routeName,
|
||||||
routeName,
|
routeName,
|
||||||
params,
|
...(params ? { params } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
key: routeName,
|
key: routeName,
|
||||||
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 */
|
/* 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 SwitchRouter from '../SwitchRouter';
|
||||||
import StackRouter from '../StackRouter';
|
import StackRouter from '../StackRouter';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint react/no-multi-comp:0, react/display-name:0 */
|
/* eslint react/no-multi-comp:0, react/display-name:0 */
|
||||||
|
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import StackRouter from '../StackRouter';
|
import StackRouter from '../StackRouter';
|
||||||
import TabRouter from '../TabRouter';
|
import TabRouter from '../TabRouter';
|
||||||
@@ -114,6 +114,51 @@ Object.keys(ROUTERS).forEach((routerName) => {
|
|||||||
);
|
);
|
||||||
expect(state0.routes[state0.index].params.foo).toEqual(42);
|
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 */
|
/* 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 StackRouter from '../StackRouter';
|
||||||
import * as StackActions from '../StackActions';
|
import * as StackActions from '../StackActions';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint react/display-name:0 */
|
/* eslint react/display-name:0 */
|
||||||
|
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import SwitchRouter from '../SwitchRouter';
|
import SwitchRouter from '../SwitchRouter';
|
||||||
import StackRouter from '../StackRouter';
|
import StackRouter from '../StackRouter';
|
||||||
import * as NavigationActions from '../../NavigationActions';
|
import * as NavigationActions from '../../NavigationActions';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint react/display-name:0 */
|
/* eslint react/display-name:0 */
|
||||||
|
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import TabRouter from '../TabRouter';
|
import TabRouter from '../TabRouter';
|
||||||
|
|
||||||
import * as NavigationActions from '../../NavigationActions';
|
import * as NavigationActions from '../../NavigationActions';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import validateRouteConfigMap from '../validateRouteConfigMap';
|
import validateRouteConfigMap from '../validateRouteConfigMap';
|
||||||
import StackRouter from '../StackRouter';
|
import StackRouter from '../StackRouter';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import withNavigation from './withNavigation';
|
import withNavigation from './withNavigation';
|
||||||
|
|
||||||
const EventNameToPropName = {
|
const EventNameToPropName = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import NavigationContext from './NavigationContext';
|
import NavigationContext from './NavigationContext';
|
||||||
|
|
||||||
export default class SceneView extends React.PureComponent {
|
export default class SceneView extends React.PureComponent {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import SceneView from '../SceneView';
|
import SceneView from '../SceneView';
|
||||||
|
|
||||||
export default class SwitchView extends React.Component {
|
export default class SwitchView extends React.Component {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import NavigationEvents from '../NavigationEvents';
|
import NavigationEvents from '../NavigationEvents';
|
||||||
import NavigationContext from '../NavigationContext';
|
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 hoistStatics from 'hoist-non-react-statics';
|
||||||
import invariant from '../utils/invariant';
|
import invariant from '../utils/invariant';
|
||||||
import NavigationContext from './NavigationContext';
|
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 hoistStatics from 'hoist-non-react-statics';
|
||||||
import withNavigation from './withNavigation';
|
import withNavigation from './withNavigation';
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [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
|
**Note:** Version bump only for package react-navigation-drawer
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-navigation-drawer",
|
"name": "react-navigation-drawer",
|
||||||
"version": "2.4.13",
|
"version": "2.5.1",
|
||||||
"description": "Drawer navigator component for React Navigation",
|
"description": "Drawer navigator component for React Navigation",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"react-native": "lib/module/index.js",
|
"react-native": "lib/module/index.js",
|
||||||
@@ -38,19 +38,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/react-navigation/drawer#readme",
|
"homepage": "https://github.com/react-navigation/drawer#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.10.0",
|
"@react-native-community/bob": "^0.16.2",
|
||||||
"@types/react": "^16.9.23",
|
"@types/react": "^16.9.44",
|
||||||
"@types/react-native": "^0.61.22",
|
"@types/react-native": "^0.63.4",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-lifecycles-compat": "^3.0.4",
|
"react-lifecycles-compat": "^3.0.4",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-native-gesture-handler": "^1.6.0",
|
"react-native-gesture-handler": "~1.7.0",
|
||||||
"react-native-reanimated": "^1.2.0",
|
"react-native-reanimated": "~1.13.0",
|
||||||
"react-native-screens": "^2.3.0",
|
"react-native-screens": "~2.10.1",
|
||||||
"react-native-testing-library": "^1.12.0",
|
"react-native-testing-library": "^6.0.0",
|
||||||
"react-navigation": "^4.3.9",
|
"react-navigation": "^4.4.1",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "*",
|
"react": "*",
|
||||||
|
|||||||
@@ -75,8 +75,11 @@ const DrawerNavigator = (
|
|||||||
const drawerRouter = DrawerRouter(routeConfigs, mergedConfig);
|
const drawerRouter = DrawerRouter(routeConfigs, mergedConfig);
|
||||||
|
|
||||||
// TODO: don't have time to fix it right now
|
// TODO: don't have time to fix it right now
|
||||||
// @ts-ignore
|
const navigator = createNavigator(
|
||||||
const navigator = createNavigator(DrawerView, drawerRouter, mergedConfig);
|
DrawerView as any,
|
||||||
|
drawerRouter,
|
||||||
|
mergedConfig
|
||||||
|
);
|
||||||
return navigator;
|
return navigator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -160,10 +160,6 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
|||||||
drawerOpenProgress={progress}
|
drawerOpenProgress={progress}
|
||||||
navigation={this.props.navigation}
|
navigation={this.props.navigation}
|
||||||
descriptors={this.props.descriptors}
|
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}
|
{...this.props.navigationConfig}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [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
|
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-navigation-material-bottom-tabs",
|
"name": "react-navigation-material-bottom-tabs",
|
||||||
"version": "2.2.12",
|
"version": "2.3.1",
|
||||||
"description": "Material Bottom Tab Navigation component for React Navigation",
|
"description": "Material Bottom Tab Navigation component for React Navigation",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"module": "lib/module/index.js",
|
"module": "lib/module/index.js",
|
||||||
@@ -38,18 +38,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/react-navigation/react-navigation-material-bottom-tabs#readme",
|
"homepage": "https://github.com/react-navigation/react-navigation-material-bottom-tabs#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.10.0",
|
"@react-native-community/bob": "^0.16.2",
|
||||||
"@types/hoist-non-react-statics": "^3.3.1",
|
"@types/hoist-non-react-statics": "^3.3.1",
|
||||||
"@types/react": "^16.9.23",
|
"@types/react": "^16.9.44",
|
||||||
"@types/react-native": "^0.61.22",
|
"@types/react-native": "^0.63.4",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-native-gesture-handler": "^1.6.0",
|
"react-native-paper": "^4.2.0",
|
||||||
"react-native-paper": "^3.1.1",
|
"react-navigation": "^4.4.1",
|
||||||
"react-native-reanimated": "^1.2.0",
|
"typescript": "^4.0.3"
|
||||||
"react-navigation": "^4.3.9",
|
|
||||||
"typescript": "~3.8.3"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "*",
|
"react": "*",
|
||||||
|
|||||||
@@ -3,6 +3,33 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [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
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/native",
|
"name": "@react-navigation/native",
|
||||||
"version": "3.7.13",
|
"version": "3.8.1",
|
||||||
"description": "React Native support for React Navigation",
|
"description": "React Native support for React Navigation",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"react-native": "lib/module/index.js",
|
"react-native": "lib/module/index.js",
|
||||||
@@ -39,14 +39,14 @@
|
|||||||
"react-native-safe-area-view": "^0.14.9"
|
"react-native-safe-area-view": "^0.14.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.10.0",
|
"@react-native-community/bob": "^0.16.2",
|
||||||
"@react-navigation/core": "^3.7.6",
|
"@react-navigation/core": "^3.7.7",
|
||||||
"@types/react-test-renderer": "^16.9.2",
|
"@types/react-test-renderer": "^16.9.3",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-native-gesture-handler": "^1.6.0",
|
"react-native-gesture-handler": "~1.7.0",
|
||||||
"react-test-renderer": "^16.9.2"
|
"react-test-renderer": "~16.13.1"
|
||||||
},
|
},
|
||||||
"@react-native-community/bob": {
|
"@react-native-community/bob": {
|
||||||
"source": "src",
|
"source": "src",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Platform, StyleSheet, View } from 'react-native';
|
import { Platform, StyleSheet, View } from 'react-native';
|
||||||
import { SceneView } from '@react-navigation/core';
|
import { SceneView } from '@react-navigation/core';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Platform,
|
Platform,
|
||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
SectionList,
|
SectionList,
|
||||||
RefreshControl,
|
RefreshControl,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
// eslint-disable-next-line import/named
|
|
||||||
import { ScrollView as GHScrollView } from 'react-native-gesture-handler';
|
import { ScrollView as GHScrollView } from 'react-native-gesture-handler';
|
||||||
import createNavigationAwareScrollable from './createNavigationAwareScrollable';
|
import createNavigationAwareScrollable from './createNavigationAwareScrollable';
|
||||||
import invariant from './utils/invariant';
|
import invariant from './utils/invariant';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
|
|
||||||
import renderer from 'react-test-renderer';
|
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 { View } from 'react-native';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import withOrientation, { isOrientationLandscape } from '../withOrientation';
|
import withOrientation, { isOrientationLandscape } from '../withOrientation';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable react/sort-comp */
|
/* eslint-disable react/sort-comp */
|
||||||
|
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { Linking, Platform, BackHandler } from 'react-native';
|
import { Linking, Platform, BackHandler } from 'react-native';
|
||||||
import {
|
import {
|
||||||
NavigationActions,
|
NavigationActions,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { TextInput } from 'react-native';
|
import { TextInput } from 'react-native';
|
||||||
|
|
||||||
export default (Navigator, navigatorConfig) =>
|
export default (Navigator, navigatorConfig) =>
|
||||||
@@ -8,7 +8,9 @@ export default (Navigator, navigatorConfig) =>
|
|||||||
_previouslyFocusedTextInput = null;
|
_previouslyFocusedTextInput = null;
|
||||||
|
|
||||||
_handleGestureBegin = () => {
|
_handleGestureBegin = () => {
|
||||||
this._previouslyFocusedTextInput = TextInput.State.currentlyFocusedField();
|
this._previouslyFocusedTextInput = TextInput.State.currentlyFocusedInput
|
||||||
|
? TextInput.State.currentlyFocusedInput()
|
||||||
|
: TextInput.State.currentlyFocusedField();
|
||||||
if (this._previouslyFocusedTextInput) {
|
if (this._previouslyFocusedTextInput) {
|
||||||
TextInput.State.blurTextInput(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
|
// in the case where the index did not change, I believe. We
|
||||||
// should revisit this after 2.0 release.
|
// should revisit this after 2.0 release.
|
||||||
if (transitionProps.index !== prevTransitionProps.index) {
|
if (transitionProps.index !== prevTransitionProps.index) {
|
||||||
const currentField = TextInput.State.currentlyFocusedField();
|
const currentField = TextInput.State.currentlyFocusedInput
|
||||||
|
? TextInput.State.currentlyFocusedInput()
|
||||||
|
: TextInput.State.currentlyFocusedField();
|
||||||
if (currentField) {
|
if (currentField) {
|
||||||
TextInput.State.blurTextInput(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 hoistStatics from 'hoist-non-react-statics';
|
||||||
import { withNavigation } from '@react-navigation/core';
|
import { withNavigation } from '@react-navigation/core';
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,24 @@ module.exports = {
|
|||||||
get createNavigationFactory() {
|
get createNavigationFactory() {
|
||||||
return require('./throwIfWrongVersion').default;
|
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() {
|
get NavigationContainer() {
|
||||||
return require('./throwIfWrongVersion').default;
|
return require('./throwIfWrongVersion').default;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export default function () {
|
export default function () {
|
||||||
throw new Error(
|
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 { Dimensions } from 'react-native';
|
||||||
import hoistNonReactStatic from 'hoist-non-react-statics';
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
## [4.3.9](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.8...react-navigation@4.3.9) (2020-04-30)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-navigation",
|
"name": "react-navigation",
|
||||||
"version": "4.3.9",
|
"version": "4.4.1",
|
||||||
"description": "Routing and navigation for your React Native apps",
|
"description": "Routing and navigation for your React Native apps",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"types": "typescript/react-navigation.d.ts",
|
"types": "typescript/react-navigation.d.ts",
|
||||||
@@ -24,16 +24,16 @@
|
|||||||
"react-native": "*"
|
"react-native": "*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/core": "^3.7.6",
|
"@react-navigation/core": "^3.7.7",
|
||||||
"@react-navigation/native": "^3.7.13"
|
"@react-navigation/native": "^3.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^16.9.23",
|
"@types/react": "^16.9.44",
|
||||||
"@types/react-native": "^0.61.22",
|
"@types/react-native": "^0.63.4",
|
||||||
"@types/react-test-renderer": "^16.9.2",
|
"@types/react-test-renderer": "^16.9.3",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.63.2",
|
||||||
"react-test-renderer": "^16.9.2",
|
"react-test-renderer": "~16.13.1",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "^4.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
|
|
||||||
|
|||||||
@@ -734,7 +734,9 @@ export namespace StackActions {
|
|||||||
export const REPLACE: 'Navigation/REPLACE';
|
export const REPLACE: 'Navigation/REPLACE';
|
||||||
export const COMPLETE_TRANSITION: 'Navigation/COMPLETE_TRANSITION';
|
export const COMPLETE_TRANSITION: 'Navigation/COMPLETE_TRANSITION';
|
||||||
|
|
||||||
export function pop(options: NavigationPopActionPayload): NavigationPopAction;
|
export function pop(
|
||||||
|
options?: NavigationPopActionPayload
|
||||||
|
): NavigationPopAction;
|
||||||
export function popToTop(
|
export function popToTop(
|
||||||
options?: NavigationPopToTopActionPayload
|
options?: NavigationPopToTopActionPayload
|
||||||
): NavigationPopToTopAction;
|
): NavigationPopToTopAction;
|
||||||
@@ -810,17 +812,16 @@ export interface NavigationDescriptor<
|
|||||||
getComponent: () => React.ComponentType;
|
getComponent: () => React.ComponentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NavigationView<
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
Options,
|
export type NavigationView<Options, State, ScreenProps = unknown> =
|
||||||
State,
|
| React.ComponentType<
|
||||||
ScreenProps = unknown
|
{
|
||||||
> = React.ComponentType<
|
descriptors: { [key: string]: NavigationDescriptor };
|
||||||
{
|
navigationConfig: Options;
|
||||||
descriptors: { [key: string]: NavigationDescriptor };
|
screenProps?: ScreenProps;
|
||||||
navigationConfig: Options;
|
} & NavigationInjectedProps
|
||||||
screenProps?: ScreenProps;
|
>
|
||||||
} & NavigationInjectedProps
|
| React.ComponentType<any>;
|
||||||
>;
|
|
||||||
|
|
||||||
export type CreateNavigatorConfig<
|
export type CreateNavigatorConfig<
|
||||||
NavigatorConfig,
|
NavigatorConfig,
|
||||||
@@ -897,11 +898,13 @@ export function withNavigation<
|
|||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
export function withNavigation<P extends NavigationInjectedProps>(
|
export function withNavigation<P extends NavigationInjectedProps>(
|
||||||
Component: React.ComponentType<P>
|
Component: React.ComponentType<P>
|
||||||
): React.ComponentType<Omit<P, keyof NavigationInjectedProps>>;
|
): React.ComponentType<Omit<P, keyof NavigationInjectedProps>>;
|
||||||
|
|
||||||
// For backwards compatibility
|
// For backwards compatibility
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
export function withNavigation<T = {}, P = NavigationParams>(
|
export function withNavigation<T = {}, P = NavigationParams>(
|
||||||
Component: React.ComponentType<T & NavigationInjectedProps<P>>
|
Component: React.ComponentType<T & NavigationInjectedProps<P>>
|
||||||
): React.ComponentType<
|
): React.ComponentType<
|
||||||
@@ -929,11 +932,13 @@ export function withNavigationFocus<
|
|||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
export function withNavigationFocus<P extends NavigationFocusInjectedProps>(
|
export function withNavigationFocus<P extends NavigationFocusInjectedProps>(
|
||||||
Component: React.ComponentType<P>
|
Component: React.ComponentType<P>
|
||||||
): React.ComponentType<Omit<P, keyof NavigationFocusInjectedProps>>;
|
): React.ComponentType<Omit<P, keyof NavigationFocusInjectedProps>>;
|
||||||
|
|
||||||
// For backwards compatibility
|
// For backwards compatibility
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
export function withNavigationFocus<T = {}, P = NavigationParams>(
|
export function withNavigationFocus<T = {}, P = NavigationParams>(
|
||||||
Component: React.ComponentType<T & NavigationFocusInjectedProps<P>>
|
Component: React.ComponentType<T & NavigationFocusInjectedProps<P>>
|
||||||
): React.ComponentType<
|
): React.ComponentType<
|
||||||
|
|||||||
@@ -3,6 +3,47 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [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)
|
# [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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-navigation-stack",
|
"name": "react-navigation-stack",
|
||||||
"version": "2.7.0",
|
"version": "2.8.3",
|
||||||
"description": "Stack navigator component for React Navigation",
|
"description": "Stack navigator component for React Navigation",
|
||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"module": "lib/module/index.js",
|
"module": "lib/module/index.js",
|
||||||
@@ -43,22 +43,22 @@
|
|||||||
"react-native-iphone-x-helper": "^1.2.1"
|
"react-native-iphone-x-helper": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.10.0",
|
"@react-native-community/bob": "^0.16.2",
|
||||||
"@react-native-community/masked-view": "^0.1.7",
|
"@react-native-community/masked-view": "0.1.10",
|
||||||
"@react-navigation/stack": "^5.5.1",
|
"@react-navigation/stack": "^5.9.0",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.23",
|
"@types/react": "^16.9.44",
|
||||||
"@types/react-native": "^0.61.22",
|
"@types/react-native": "^0.63.4",
|
||||||
"@types/react-test-renderer": "^16.9.2",
|
"@types/react-test-renderer": "^16.9.3",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.1",
|
||||||
"react": "~16.9.0",
|
"react": "~16.13.1",
|
||||||
"react-native": "~0.61.4",
|
"react-native": "~0.63.2",
|
||||||
"react-native-gesture-handler": "^1.6.0",
|
"react-native-gesture-handler": "~1.7.0",
|
||||||
"react-native-safe-area-context": "^0.7.3",
|
"react-native-safe-area-context": "3.1.4",
|
||||||
"react-native-screens": "^2.3.0",
|
"react-native-screens": "~2.10.1",
|
||||||
"react-navigation": "^4.3.9",
|
"react-navigation": "^4.4.1",
|
||||||
"react-test-renderer": "~16.9.0",
|
"react-test-renderer": "~16.13.1",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-native-community/masked-view": ">=0.1.0",
|
"@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
|
diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/index.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/index.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/index.tsx 2020-06-24 23:16:17.000000000 +0200
|
||||||
@@ -3,11 +3,6 @@
|
@@ -3,11 +3,6 @@
|
||||||
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
||||||
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
|
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
|
||||||
@@ -28,7 +28,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
|
|||||||
StackHeaderLeftButtonProps,
|
StackHeaderLeftButtonProps,
|
||||||
StackHeaderTitleProps,
|
StackHeaderTitleProps,
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx src/vendor/navigators/createStackNavigator.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx src/vendor/navigators/createStackNavigator.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
|
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
|
||||||
@@ -1,96 +0,0 @@
|
@@ -1,96 +0,0 @@
|
||||||
-import * as React from 'react';
|
-import * as React from 'react';
|
||||||
@@ -44,7 +44,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
|||||||
- StackActions,
|
- StackActions,
|
||||||
-} from '@react-navigation/native';
|
-} from '@react-navigation/native';
|
||||||
-import StackView from '../views/Stack/StackView';
|
-import StackView from '../views/Stack/StackView';
|
||||||
-import {
|
-import type {
|
||||||
- StackNavigationConfig,
|
- StackNavigationConfig,
|
||||||
- StackNavigationOptions,
|
- StackNavigationOptions,
|
||||||
- StackNavigationEventMap,
|
- StackNavigationEventMap,
|
||||||
@@ -128,12 +128,12 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
|||||||
- typeof StackNavigator
|
- typeof StackNavigator
|
||||||
->(StackNavigator);
|
->(StackNavigator);
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/types.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/types.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/types.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/types.tsx 2020-06-24 23:18:40.000000000 +0200
|
||||||
@@ -8,15 +8,28 @@
|
@@ -8,15 +8,28 @@
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
import {
|
import type {
|
||||||
+ NavigationRoute,
|
+ NavigationRoute,
|
||||||
+ NavigationState,
|
+ NavigationState,
|
||||||
+ NavigationScreenProp,
|
+ NavigationScreenProp,
|
||||||
@@ -261,28 +261,40 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type StackNavigationConfig = {
|
export type StackNavigationConfig = {
|
||||||
|
diff -Naur ../../node_modules/@react-navigation/stack/src/utils/PreviousSceneContext.tsx src/vendor/utils/PreviousSceneContext.tsx
|
||||||
|
--- ../../node_modules/@react-navigation/stack/src/utils/PreviousSceneContext.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
|
+++ src/vendor/utils/PreviousSceneContext.tsx 2020-06-24 23:26:38.000000000 +0200
|
||||||
|
@@ -1,6 +1,5 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
-import type { Route } from '@react-navigation/native';
|
||||||
|
-import type { Scene } from '../types';
|
||||||
|
+import type { Route, Scene } from '../types';
|
||||||
|
|
||||||
|
const PreviousSceneContext = React.createContext<
|
||||||
|
Scene<Route<string>> | undefined
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx src/vendor/views/Header/Header.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx src/vendor/views/Header/Header.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/Header.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/Header.tsx 2020-06-25 03:01:13.000000000 +0200
|
||||||
@@ -1,12 +1,14 @@
|
@@ -1,12 +1,15 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
-import { StackActions } from '@react-navigation/native';
|
-import { StackActions } from '@react-navigation/native';
|
||||||
+import { Dimensions } from 'react-native';
|
+import { Dimensions } from 'react-native';
|
||||||
+import { StackActions } from 'react-navigation';
|
+import { StackActions } from 'react-navigation';
|
||||||
+import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
+import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
||||||
|
+
|
||||||
|
+import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
|
||||||
|
|
||||||
-import HeaderSegment from './HeaderSegment';
|
-import HeaderSegment from './HeaderSegment';
|
||||||
+import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
|
|
||||||
import HeaderTitle from './HeaderTitle';
|
import HeaderTitle from './HeaderTitle';
|
||||||
import debounce from '../../utils/debounce';
|
import debounce from '../../utils/debounce';
|
||||||
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
import type { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
||||||
|
|
||||||
-export default React.memo(function Header(props: StackHeaderProps) {
|
-export default React.memo(function Header(props: StackHeaderProps) {
|
||||||
+const Header = React.memo(function Header(props: StackHeaderProps) {
|
+const Header = React.memo(function Header(props: StackHeaderProps) {
|
||||||
const {
|
const {
|
||||||
scene,
|
scene,
|
||||||
previous,
|
previous,
|
||||||
@@ -22,7 +24,7 @@
|
@@ -22,7 +25,7 @@
|
||||||
? options.headerTitle
|
? options.headerTitle
|
||||||
: options.title !== undefined
|
: options.title !== undefined
|
||||||
? options.title
|
? options.title
|
||||||
@@ -291,7 +303,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
|||||||
|
|
||||||
let leftLabel;
|
let leftLabel;
|
||||||
|
|
||||||
@@ -38,18 +40,13 @@
|
@@ -38,17 +41,20 @@
|
||||||
? o.headerTitle
|
? o.headerTitle
|
||||||
: o.title !== undefined
|
: o.title !== undefined
|
||||||
? o.title
|
? o.title
|
||||||
@@ -307,12 +319,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
|||||||
- ...StackActions.pop(),
|
- ...StackActions.pop(),
|
||||||
- source: scene.route.key,
|
- source: scene.route.key,
|
||||||
- });
|
- });
|
||||||
- }
|
+ const key = navigation.isFirstRouteInParent()
|
||||||
+ navigation.dispatch(StackActions.pop({ key: scene.route.key }));
|
+ ? // 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),
|
}, 50),
|
||||||
[navigation, scene.route.key]
|
[navigation, scene.route.key]
|
||||||
);
|
@@ -64,7 +70,10 @@
|
||||||
@@ -64,7 +61,10 @@
|
|
||||||
leftLabel={leftLabel}
|
leftLabel={leftLabel}
|
||||||
headerTitle={
|
headerTitle={
|
||||||
typeof options.headerTitle !== 'function'
|
typeof options.headerTitle !== 'function'
|
||||||
@@ -324,7 +342,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
|||||||
: options.headerTitle
|
: options.headerTitle
|
||||||
}
|
}
|
||||||
onGoBack={previous ? goBack : undefined}
|
onGoBack={previous ? goBack : undefined}
|
||||||
@@ -72,3 +72,18 @@
|
@@ -72,3 +81,18 @@
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -344,8 +362,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
|||||||
+
|
+
|
||||||
+export default Header;
|
+export default Header;
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-06-24 23:21:49.000000000 +0200
|
||||||
@@ -8,9 +8,9 @@
|
@@ -8,9 +8,9 @@
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
LayoutChangeEvent,
|
LayoutChangeEvent,
|
||||||
@@ -354,12 +372,12 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
|
|||||||
import MaskedView from '../MaskedView';
|
import MaskedView from '../MaskedView';
|
||||||
import { TouchableItem } from '../TouchableItem';
|
import { TouchableItem } from '../TouchableItem';
|
||||||
+import useTheme from '../../../utils/useTheme';
|
+import useTheme from '../../../utils/useTheme';
|
||||||
import { StackHeaderLeftButtonProps } from '../../types';
|
import type { StackHeaderLeftButtonProps } from '../../types';
|
||||||
|
|
||||||
type Props = StackHeaderLeftButtonProps;
|
type Props = StackHeaderLeftButtonProps;
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx src/vendor/views/Header/HeaderBackground.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx src/vendor/views/Header/HeaderBackground.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-06-24 23:16:23.000000000 +0200
|
||||||
@@ -7,7 +7,7 @@
|
@@ -7,7 +7,7 @@
|
||||||
StyleProp,
|
StyleProp,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
@@ -370,8 +388,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
|
|||||||
type Props = ViewProps & {
|
type Props = ViewProps & {
|
||||||
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx src/vendor/views/Header/HeaderContainer.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx src/vendor/views/Header/HeaderContainer.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-06-24 23:21:29.000000000 +0200
|
||||||
@@ -1,11 +1,6 @@
|
@@ -1,11 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||||
@@ -382,18 +400,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
|||||||
- ParamListBase,
|
- ParamListBase,
|
||||||
-} from '@react-navigation/native';
|
-} from '@react-navigation/native';
|
||||||
+import { NavigationContext } from 'react-navigation';
|
+import { NavigationContext } from 'react-navigation';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
|
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
@@ -17,6 +12,7 @@
|
@@ -19,6 +14,7 @@
|
||||||
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
import type {
|
||||||
import {
|
|
||||||
+ Route,
|
|
||||||
Layout,
|
Layout,
|
||||||
|
+ Route,
|
||||||
Scene,
|
Scene,
|
||||||
StackHeaderStyleInterpolator,
|
StackHeaderStyleInterpolator,
|
||||||
@@ -117,9 +113,7 @@
|
StackNavigationProp,
|
||||||
|
@@ -109,9 +105,7 @@
|
||||||
insets,
|
insets,
|
||||||
scene,
|
scene,
|
||||||
previous,
|
previous,
|
||||||
@@ -404,7 +422,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
|||||||
styleInterpolator:
|
styleInterpolator:
|
||||||
mode === 'float'
|
mode === 'float'
|
||||||
? isHeaderStatic
|
? isHeaderStatic
|
||||||
@@ -138,7 +132,7 @@
|
@@ -130,7 +124,7 @@
|
||||||
key={scene.route.key}
|
key={scene.route.key}
|
||||||
value={scene.descriptor.navigation}
|
value={scene.descriptor.navigation}
|
||||||
>
|
>
|
||||||
@@ -413,7 +431,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
|||||||
<View
|
<View
|
||||||
onLayout={
|
onLayout={
|
||||||
onContentHeightChange
|
onContentHeightChange
|
||||||
@@ -164,7 +158,7 @@
|
@@ -156,7 +150,7 @@
|
||||||
>
|
>
|
||||||
{header !== undefined ? header(props) : <Header {...props} />}
|
{header !== undefined ? header(props) : <Header {...props} />}
|
||||||
</View>
|
</View>
|
||||||
@@ -423,14 +441,14 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx src/vendor/views/Header/HeaderSegment.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx src/vendor/views/Header/HeaderSegment.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-06-24 23:20:58.000000000 +0200
|
||||||
@@ -8,7 +8,7 @@
|
@@ -8,7 +8,7 @@
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
-import { Route } from '@react-navigation/native';
|
-import type { Route } from '@react-navigation/native';
|
||||||
+import { NavigationRoute } from 'react-navigation';
|
+import type { NavigationRoute } from 'react-navigation';
|
||||||
import HeaderBackButton from './HeaderBackButton';
|
import HeaderBackButton from './HeaderBackButton';
|
||||||
import HeaderBackground from './HeaderBackground';
|
import HeaderBackground from './HeaderBackground';
|
||||||
import memoize from '../../utils/memoize';
|
import memoize from '../../utils/memoize';
|
||||||
@@ -444,8 +462,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSeg
|
|||||||
};
|
};
|
||||||
|
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx src/vendor/views/Header/HeaderTitle.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx src/vendor/views/Header/HeaderTitle.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-06-24 23:16:23.000000000 +0200
|
||||||
@@ -1,6 +1,6 @@
|
@@ -1,6 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Animated, StyleSheet, Platform } from 'react-native';
|
import { Animated, StyleSheet, Platform } from 'react-native';
|
||||||
@@ -455,8 +473,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTit
|
|||||||
type Props = Omit<React.ComponentProps<typeof Animated.Text>, 'key'> & {
|
type Props = Omit<React.ComponentProps<typeof Animated.Text>, 'key'> & {
|
||||||
tintColor?: string;
|
tintColor?: string;
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx src/vendor/views/Stack/Card.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx src/vendor/views/Stack/Card.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Stack/Card.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Stack/Card.tsx 2020-06-24 23:16:23.000000000 +0200
|
||||||
@@ -146,7 +146,7 @@
|
@@ -146,7 +146,7 @@
|
||||||
|
|
||||||
private interactionHandle: number | undefined;
|
private interactionHandle: number | undefined;
|
||||||
@@ -467,45 +485,46 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx s
|
|||||||
private animate = ({
|
private animate = ({
|
||||||
closing,
|
closing,
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx src/vendor/views/Stack/CardContainer.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx src/vendor/views/Stack/CardContainer.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Stack/CardContainer.tsx 2020-06-24 23:20:38.000000000 +0200
|
||||||
@@ -1,11 +1,12 @@
|
@@ -1,12 +1,13 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||||
-import { Route, useTheme } from '@react-navigation/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 Card from './Card';
|
||||||
import HeaderHeightContext from '../../utils/HeaderHeightContext';
|
import HeaderHeightContext from '../../utils/HeaderHeightContext';
|
||||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||||
|
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||||
+import useTheme from '../../../utils/useTheme';
|
+import useTheme from '../../../utils/useTheme';
|
||||||
import {
|
import type {
|
||||||
+ Route,
|
+ Route,
|
||||||
Scene,
|
Scene,
|
||||||
Layout,
|
Layout,
|
||||||
StackHeaderMode,
|
StackHeaderMode,
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx src/vendor/views/Stack/CardStack.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx src/vendor/views/Stack/CardStack.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-06-08 11:23:27.000000000 +0200
|
+++ src/vendor/views/Stack/CardStack.tsx 2020-06-24 23:20:16.000000000 +0200
|
||||||
@@ -7,7 +7,7 @@
|
@@ -7,7 +7,7 @@
|
||||||
Platform,
|
Platform,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
-import { Route, StackNavigationState } from '@react-navigation/native';
|
-import type { Route, StackNavigationState } from '@react-navigation/native';
|
||||||
+import { NavigationState as StackNavigationState } from 'react-navigation';
|
+import type { NavigationState as StackNavigationState } from 'react-navigation';
|
||||||
|
|
||||||
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
|
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
|
||||||
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
|
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
|
||||||
@@ -22,6 +22,7 @@
|
@@ -25,6 +25,7 @@
|
||||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
|
||||||
import getDistanceForDirection from '../../utils/getDistanceForDirection';
|
|
||||||
import {
|
|
||||||
+ Route,
|
|
||||||
Layout,
|
Layout,
|
||||||
StackHeaderMode,
|
StackHeaderMode,
|
||||||
StackCardMode,
|
StackCardMode,
|
||||||
|
+ Route,
|
||||||
|
Scene,
|
||||||
|
StackDescriptorMap,
|
||||||
|
StackNavigationOptions,
|
||||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx src/vendor/views/Stack/StackView.tsx
|
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx src/vendor/views/Stack/StackView.tsx
|
||||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-06-08 11:22:56.000000000 +0200
|
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-06-25 01:58:50.000000000 +0200
|
||||||
+++ src/vendor/views/Stack/StackView.tsx 2020-06-08 11:23:40.000000000 +0200
|
+++ src/vendor/views/Stack/StackView.tsx 2020-06-24 23:19:46.000000000 +0200
|
||||||
@@ -2,11 +2,11 @@
|
@@ -2,11 +2,11 @@
|
||||||
import { View, Platform, StyleSheet } from 'react-native';
|
import { View, Platform, StyleSheet } from 'react-native';
|
||||||
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
|
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
|
||||||
@@ -525,7 +544,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
|||||||
@@ -16,6 +16,7 @@
|
@@ -16,6 +16,7 @@
|
||||||
} from '../Header/HeaderContainer';
|
} from '../Header/HeaderContainer';
|
||||||
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
|
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
|
||||||
import {
|
import type {
|
||||||
+ Route,
|
+ Route,
|
||||||
StackNavigationHelpers,
|
StackNavigationHelpers,
|
||||||
StackNavigationConfig,
|
StackNavigationConfig,
|
||||||
@@ -661,7 +680,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
|||||||
navigation,
|
navigation,
|
||||||
keyboardHandlingEnabled,
|
keyboardHandlingEnabled,
|
||||||
mode = 'card',
|
mode = 'card',
|
||||||
@@ -425,7 +454,7 @@
|
@@ -427,7 +456,7 @@
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -670,7 +689,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
|||||||
<GestureHandlerWrapper style={styles.container}>
|
<GestureHandlerWrapper style={styles.container}>
|
||||||
<SafeAreaProviderCompat>
|
<SafeAreaProviderCompat>
|
||||||
<SafeAreaConsumer>
|
<SafeAreaConsumer>
|
||||||
@@ -458,7 +487,7 @@
|
@@ -460,7 +489,7 @@
|
||||||
</SafeAreaConsumer>
|
</SafeAreaConsumer>
|
||||||
</SafeAreaProviderCompat>
|
</SafeAreaProviderCompat>
|
||||||
</GestureHandlerWrapper>
|
</GestureHandlerWrapper>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import createAppContainer, {
|
|||||||
_TESTING_ONLY_reset_container_count,
|
_TESTING_ONLY_reset_container_count,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
} from '../../../../native/src/createAppContainer';
|
} from '../../../../native/src/createAppContainer';
|
||||||
import { StackNavigationProp } from '../../vendor/types';
|
import type { StackNavigationProp } from '../../vendor/types';
|
||||||
|
|
||||||
const NavigationTestUtils = {
|
const NavigationTestUtils = {
|
||||||
resetInternalState: _TESTING_ONLY_reset_container_count,
|
resetInternalState: _TESTING_ONLY_reset_container_count,
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
accessibilityRole="header"
|
accessibilityRole="header"
|
||||||
|
aria-level="1"
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
onLayout={[Function]}
|
onLayout={[Function]}
|
||||||
style={
|
style={
|
||||||
@@ -136,6 +137,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<View
|
||||||
|
collapsable={false}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"opacity": 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<View
|
<View
|
||||||
accessibilityElementsHidden={false}
|
accessibilityElementsHidden={false}
|
||||||
closing={false}
|
closing={false}
|
||||||
@@ -144,6 +153,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
onClose={[Function]}
|
onClose={[Function]}
|
||||||
onGestureBegin={[Function]}
|
onGestureBegin={[Function]}
|
||||||
onGestureCanceled={[Function]}
|
onGestureCanceled={[Function]}
|
||||||
|
onGestureEnd={[Function]}
|
||||||
onOpen={[Function]}
|
onOpen={[Function]}
|
||||||
onTransitionStart={[Function]}
|
onTransitionStart={[Function]}
|
||||||
pointerEvents="box-none"
|
pointerEvents="box-none"
|
||||||
@@ -188,7 +198,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
"flex": 1,
|
"flex": 1,
|
||||||
"opacity": 1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -296,6 +305,14 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<View
|
||||||
|
collapsable={false}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"opacity": 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<View
|
<View
|
||||||
accessibilityElementsHidden={false}
|
accessibilityElementsHidden={false}
|
||||||
closing={false}
|
closing={false}
|
||||||
@@ -304,6 +321,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
onClose={[Function]}
|
onClose={[Function]}
|
||||||
onGestureBegin={[Function]}
|
onGestureBegin={[Function]}
|
||||||
onGestureCanceled={[Function]}
|
onGestureCanceled={[Function]}
|
||||||
|
onGestureEnd={[Function]}
|
||||||
onOpen={[Function]}
|
onOpen={[Function]}
|
||||||
onTransitionStart={[Function]}
|
onTransitionStart={[Function]}
|
||||||
pointerEvents="box-none"
|
pointerEvents="box-none"
|
||||||
@@ -349,7 +367,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
|
|||||||
Object {
|
Object {
|
||||||
"flex": 1,
|
"flex": 1,
|
||||||
"marginTop": 0,
|
"marginTop": 0,
|
||||||
"opacity": 1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
|||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
accessibilityRole="header"
|
accessibilityRole="header"
|
||||||
|
aria-level="1"
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
onLayout={[Function]}
|
onLayout={[Function]}
|
||||||
style={
|
style={
|
||||||
@@ -153,6 +154,14 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<View
|
||||||
|
collapsable={false}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"opacity": 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<View
|
<View
|
||||||
accessibilityElementsHidden={false}
|
accessibilityElementsHidden={false}
|
||||||
closing={false}
|
closing={false}
|
||||||
@@ -161,6 +170,7 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
|||||||
onClose={[Function]}
|
onClose={[Function]}
|
||||||
onGestureBegin={[Function]}
|
onGestureBegin={[Function]}
|
||||||
onGestureCanceled={[Function]}
|
onGestureCanceled={[Function]}
|
||||||
|
onGestureEnd={[Function]}
|
||||||
onOpen={[Function]}
|
onOpen={[Function]}
|
||||||
onTransitionStart={[Function]}
|
onTransitionStart={[Function]}
|
||||||
pointerEvents="box-none"
|
pointerEvents="box-none"
|
||||||
@@ -205,7 +215,6 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
|||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
"flex": 1,
|
"flex": 1,
|
||||||
"opacity": 1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -397,6 +406,7 @@ exports[`StackNavigator renders successfully 1`] = `
|
|||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
accessibilityRole="header"
|
accessibilityRole="header"
|
||||||
|
aria-level="1"
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
onLayout={[Function]}
|
onLayout={[Function]}
|
||||||
style={
|
style={
|
||||||
@@ -434,6 +444,14 @@ exports[`StackNavigator renders successfully 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<View
|
||||||
|
collapsable={false}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"opacity": 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<View
|
<View
|
||||||
accessibilityElementsHidden={false}
|
accessibilityElementsHidden={false}
|
||||||
closing={false}
|
closing={false}
|
||||||
@@ -442,6 +460,7 @@ exports[`StackNavigator renders successfully 1`] = `
|
|||||||
onClose={[Function]}
|
onClose={[Function]}
|
||||||
onGestureBegin={[Function]}
|
onGestureBegin={[Function]}
|
||||||
onGestureCanceled={[Function]}
|
onGestureCanceled={[Function]}
|
||||||
|
onGestureEnd={[Function]}
|
||||||
onOpen={[Function]}
|
onOpen={[Function]}
|
||||||
onTransitionStart={[Function]}
|
onTransitionStart={[Function]}
|
||||||
pointerEvents="box-none"
|
pointerEvents="box-none"
|
||||||
@@ -486,7 +505,6 @@ exports[`StackNavigator renders successfully 1`] = `
|
|||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
"flex": 1,
|
"flex": 1,
|
||||||
"opacity": 1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
CreateNavigatorConfig,
|
CreateNavigatorConfig,
|
||||||
} from 'react-navigation';
|
} from 'react-navigation';
|
||||||
import StackView from '../views/StackView';
|
import StackView from '../views/StackView';
|
||||||
import {
|
import type {
|
||||||
StackNavigationConfig,
|
StackNavigationConfig,
|
||||||
StackNavigationOptions,
|
StackNavigationOptions,
|
||||||
StackNavigationProp,
|
StackNavigationProp,
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import {
|
import type {
|
||||||
NavigationRoute,
|
NavigationRoute,
|
||||||
NavigationParams,
|
NavigationParams,
|
||||||
NavigationScreenConfig,
|
NavigationScreenConfig,
|
||||||
SupportedThemes,
|
SupportedThemes,
|
||||||
} from 'react-navigation';
|
} from 'react-navigation';
|
||||||
import { StackNavigationProp, StackNavigationOptions } from './vendor/types';
|
import type {
|
||||||
|
StackNavigationProp,
|
||||||
|
StackNavigationOptions,
|
||||||
|
} from './vendor/types';
|
||||||
|
|
||||||
export type NavigationStackScreenProps<
|
export type NavigationStackScreenProps<
|
||||||
Params = NavigationParams,
|
Params = NavigationParams,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { StyleProp, ViewStyle } from 'react-native';
|
import type { StyleProp, ViewStyle } from 'react-native';
|
||||||
import { StackNavigationOptions, StackNavigationConfig } from '../vendor/types';
|
import type {
|
||||||
|
StackNavigationOptions,
|
||||||
|
StackNavigationConfig,
|
||||||
|
} from '../vendor/types';
|
||||||
|
|
||||||
type Validation = {
|
type Validation = {
|
||||||
message: string;
|
message: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
import { StackNavigationOptions } from '../vendor/types';
|
import type { StackNavigationOptions } from '../vendor/types';
|
||||||
|
|
||||||
type Validation = {
|
type Validation = {
|
||||||
check: (o: Record<string, any>) => boolean;
|
check: (o: Record<string, any>) => boolean;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Animated } from 'react-native';
|
import { Animated } from 'react-native';
|
||||||
import { isIphoneX } from 'react-native-iphone-x-helper';
|
import { isIphoneX } from 'react-native-iphone-x-helper';
|
||||||
import conditional from '../utils/conditional';
|
import conditional from '../utils/conditional';
|
||||||
import {
|
import type {
|
||||||
StackCardInterpolationProps,
|
StackCardInterpolationProps,
|
||||||
StackCardInterpolatedStyle,
|
StackCardInterpolatedStyle,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Animated, I18nManager } from 'react-native';
|
import { Animated, I18nManager } from 'react-native';
|
||||||
import {
|
import type {
|
||||||
StackHeaderInterpolationProps,
|
StackHeaderInterpolationProps,
|
||||||
StackHeaderInterpolatedStyle,
|
StackHeaderInterpolatedStyle,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Platform } from 'react-native';
|
||||||
import {
|
import {
|
||||||
forHorizontalIOS,
|
forHorizontalIOS,
|
||||||
forVerticalIOS,
|
forVerticalIOS,
|
||||||
@@ -14,8 +15,7 @@ import {
|
|||||||
FadeOutToBottomAndroidSpec,
|
FadeOutToBottomAndroidSpec,
|
||||||
FadeInFromBottomAndroidSpec,
|
FadeInFromBottomAndroidSpec,
|
||||||
} from './TransitionSpecs';
|
} from './TransitionSpecs';
|
||||||
import { TransitionPreset } from '../types';
|
import type { TransitionPreset } from '../types';
|
||||||
import { Platform } from 'react-native';
|
|
||||||
|
|
||||||
const ANDROID_VERSION_PIE = 28;
|
const ANDROID_VERSION_PIE = 28;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Easing } from 'react-native';
|
import { Easing } from 'react-native';
|
||||||
import { TransitionSpec } from '../types';
|
import type { TransitionSpec } from '../types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exact values from UINavigationController's animation configuration.
|
* Exact values from UINavigationController's animation configuration.
|
||||||
|
|||||||
33
packages/stack/src/vendor/types.tsx
vendored
33
packages/stack/src/vendor/types.tsx
vendored
@@ -1,13 +1,13 @@
|
|||||||
import * as React from 'react';
|
import type * as React from 'react';
|
||||||
import {
|
import type {
|
||||||
Animated,
|
Animated,
|
||||||
StyleProp,
|
StyleProp,
|
||||||
TextStyle,
|
TextStyle,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
LayoutChangeEvent,
|
LayoutChangeEvent,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
import {
|
import type {
|
||||||
NavigationRoute,
|
NavigationRoute,
|
||||||
NavigationState,
|
NavigationState,
|
||||||
NavigationScreenProp,
|
NavigationScreenProp,
|
||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from 'react-navigation';
|
} from 'react-navigation';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export type Route<T extends string> = NavigationRoute;
|
export type Route<T extends string> = NavigationRoute;
|
||||||
|
|
||||||
export type NavigationStackState = NavigationState;
|
export type NavigationStackState = NavigationState;
|
||||||
@@ -40,6 +41,18 @@ export type StackNavigationEventMap = {
|
|||||||
* Event which fires when a transition animation ends.
|
* Event which fires when a transition animation ends.
|
||||||
*/
|
*/
|
||||||
transitionEnd: { data: { closing: boolean } };
|
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 StackNavigationHelpers = NavigationProp<NavigationStackState>;
|
||||||
@@ -124,7 +137,7 @@ export type StackHeaderOptions = {
|
|||||||
/**
|
/**
|
||||||
* Style object for the title component.
|
* 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.
|
* 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`.
|
* By default, `headerTitleContainerStyle` is with an absolute position style and offsets both `left` and `right`.
|
||||||
@@ -288,7 +301,9 @@ export type StackNavigationOptions = StackHeaderOptions &
|
|||||||
/**
|
/**
|
||||||
* Function that returns a React Element to display as a overlay for the card.
|
* 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.
|
* Style object for the card in stack.
|
||||||
* You can provide a custom background color to use instead of the default background here.
|
* You can provide a custom background color to use instead of the default background here.
|
||||||
@@ -423,6 +438,10 @@ export type StackHeaderLeftButtonProps = {
|
|||||||
* Accessibility label for the button for screen readers.
|
* Accessibility label for the button for screen readers.
|
||||||
*/
|
*/
|
||||||
accessibilityLabel?: string;
|
accessibilityLabel?: string;
|
||||||
|
/**
|
||||||
|
* Style object for the button.
|
||||||
|
*/
|
||||||
|
style?: StyleProp<ViewStyle>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StackHeaderTitleProps = {
|
export type StackHeaderTitleProps = {
|
||||||
@@ -445,7 +464,7 @@ export type StackHeaderTitleProps = {
|
|||||||
/**
|
/**
|
||||||
* Style object for the title element.
|
* Style object for the title element.
|
||||||
*/
|
*/
|
||||||
style?: React.ComponentProps<typeof Animated.Text>['style'];
|
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TransitionSpec =
|
export type TransitionSpec =
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { StackCardInterpolationProps } from '../types';
|
import type { StackCardInterpolationProps } from '../types';
|
||||||
|
|
||||||
export default React.createContext<StackCardInterpolationProps | undefined>(
|
export default React.createContext<StackCardInterpolationProps | undefined>(
|
||||||
undefined
|
undefined
|
||||||
|
|||||||
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 getInvertedMultiplier from './getInvertedMultiplier';
|
||||||
import { GestureDirection, Layout } from '../types';
|
import type { GestureDirection, Layout } from '../types';
|
||||||
|
|
||||||
export default function getDistanceForDirection(
|
export default function getDistanceForDirection(
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { I18nManager } from 'react-native';
|
import { I18nManager } from 'react-native';
|
||||||
import { GestureDirection } from '../types';
|
import type { GestureDirection } from '../types';
|
||||||
|
|
||||||
export default function getInvertedMultiplier(
|
export default function getInvertedMultiplier(
|
||||||
gestureDirection: GestureDirection
|
gestureDirection: GestureDirection
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export default class BorderlessButton extends React.Component<Props> {
|
|||||||
const { children, style, enabled, ...rest } = this.props;
|
const { children, style, enabled, ...rest } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
|
||||||
<AnimatedBaseButton
|
<AnimatedBaseButton
|
||||||
{...rest}
|
{...rest}
|
||||||
onActiveStateChange={this.handleActiveStateChange}
|
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';
|
||||||
@@ -4,9 +4,10 @@ import { StackActions } from 'react-navigation';
|
|||||||
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
||||||
|
|
||||||
import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
|
import HeaderSegment, { getDefaultHeaderHeight } from './HeaderSegment';
|
||||||
|
|
||||||
import HeaderTitle from './HeaderTitle';
|
import HeaderTitle from './HeaderTitle';
|
||||||
import debounce from '../../utils/debounce';
|
import debounce from '../../utils/debounce';
|
||||||
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
import type { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
||||||
|
|
||||||
const Header = React.memo(function Header(props: StackHeaderProps) {
|
const Header = React.memo(function Header(props: StackHeaderProps) {
|
||||||
const {
|
const {
|
||||||
@@ -46,7 +47,15 @@ const Header = React.memo(function Header(props: StackHeaderProps) {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const goBack = React.useCallback(
|
const goBack = React.useCallback(
|
||||||
debounce(() => {
|
debounce(() => {
|
||||||
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),
|
}, 50),
|
||||||
[navigation, scene.route.key]
|
[navigation, scene.route.key]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
LayoutChangeEvent,
|
LayoutChangeEvent,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import MaskedView from '../MaskedView';
|
|
||||||
import { TouchableItem } from '../TouchableItem';
|
|
||||||
import useTheme from '../../../utils/useTheme';
|
import useTheme from '../../../utils/useTheme';
|
||||||
import { StackHeaderLeftButtonProps } from '../../types';
|
import MaskedView from '../MaskedView';
|
||||||
|
import TouchableItem from '../TouchableItem';
|
||||||
|
import type { StackHeaderLeftButtonProps } from '../../types';
|
||||||
|
|
||||||
type Props = StackHeaderLeftButtonProps;
|
type Props = StackHeaderLeftButtonProps;
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ export default function HeaderBackButton({
|
|||||||
titleLayout,
|
titleLayout,
|
||||||
truncatedLabel = 'Back',
|
truncatedLabel = 'Back',
|
||||||
accessibilityLabel = label && label !== 'Back' ? `${label}, back` : 'Go back',
|
accessibilityLabel = label && label !== 'Back' ? `${label}, back` : 'Go back',
|
||||||
|
style,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { dark, colors } = useTheme();
|
const { dark, colors } = useTheme();
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ export default function HeaderBackButton({
|
|||||||
delayPressIn={0}
|
delayPressIn={0}
|
||||||
onPress={disabled ? undefined : handlePress}
|
onPress={disabled ? undefined : handlePress}
|
||||||
pressColor={pressColorAndroid}
|
pressColor={pressColorAndroid}
|
||||||
style={[styles.container, disabled && styles.disabled]}
|
style={[styles.container, disabled && styles.disabled, style]}
|
||||||
hitSlop={Platform.select({
|
hitSlop={Platform.select({
|
||||||
ios: undefined,
|
ios: undefined,
|
||||||
default: { top: 16, right: 16, bottom: 16, left: 16 },
|
default: { top: 16, right: 16, bottom: 16, left: 16 },
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||||
import { NavigationContext } from 'react-navigation';
|
import { NavigationContext } from 'react-navigation';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
|
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
import {
|
import {
|
||||||
@@ -11,9 +11,10 @@ import {
|
|||||||
forSlideRight,
|
forSlideRight,
|
||||||
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
||||||
import HeaderShownContext from '../../utils/HeaderShownContext';
|
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||||
import {
|
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||||
Route,
|
import type {
|
||||||
Layout,
|
Layout,
|
||||||
|
Route,
|
||||||
Scene,
|
Scene,
|
||||||
StackHeaderStyleInterpolator,
|
StackHeaderStyleInterpolator,
|
||||||
StackNavigationProp,
|
StackNavigationProp,
|
||||||
@@ -25,9 +26,9 @@ export type Props = {
|
|||||||
layout: Layout;
|
layout: Layout;
|
||||||
insets: EdgeInsets;
|
insets: EdgeInsets;
|
||||||
scenes: (Scene<Route<string>> | undefined)[];
|
scenes: (Scene<Route<string>> | undefined)[];
|
||||||
getPreviousRoute: (props: {
|
getPreviousScene: (props: {
|
||||||
route: Route<string>;
|
route: Route<string>;
|
||||||
}) => Route<string> | undefined;
|
}) => Scene<Route<string>> | undefined;
|
||||||
getFocusedRoute: () => Route<string>;
|
getFocusedRoute: () => Route<string>;
|
||||||
onContentHeightChange?: (props: {
|
onContentHeightChange?: (props: {
|
||||||
route: Route<string>;
|
route: Route<string>;
|
||||||
@@ -43,8 +44,8 @@ export default function HeaderContainer({
|
|||||||
scenes,
|
scenes,
|
||||||
layout,
|
layout,
|
||||||
insets,
|
insets,
|
||||||
|
getPreviousScene,
|
||||||
getFocusedRoute,
|
getFocusedRoute,
|
||||||
getPreviousRoute,
|
|
||||||
onContentHeightChange,
|
onContentHeightChange,
|
||||||
gestureDirection,
|
gestureDirection,
|
||||||
styleInterpolator,
|
styleInterpolator,
|
||||||
@@ -52,6 +53,7 @@ export default function HeaderContainer({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
const focusedRoute = getFocusedRoute();
|
const focusedRoute = getFocusedRoute();
|
||||||
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
||||||
|
const parentPreviousScene = React.useContext(PreviousSceneContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View pointerEvents="box-none" style={style}>
|
<View pointerEvents="box-none" style={style}>
|
||||||
@@ -71,22 +73,8 @@ export default function HeaderContainer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isFocused = focusedRoute.key === scene.route.key;
|
const isFocused = focusedRoute.key === scene.route.key;
|
||||||
const previousRoute = getPreviousRoute({ route: scene.route });
|
const previous =
|
||||||
|
getPreviousScene({ route: scene.route }) ?? parentPreviousScene;
|
||||||
let previous;
|
|
||||||
|
|
||||||
if (previousRoute) {
|
|
||||||
// The previous scene will be shortly before the current scene in the array
|
|
||||||
// So loop back from current index to avoid looping over the full array
|
|
||||||
for (let j = i - 1; j >= 0; j--) {
|
|
||||||
const s = self[j];
|
|
||||||
|
|
||||||
if (s && s.route.key === previousRoute.key) {
|
|
||||||
previous = s;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the screen is next to a headerless screen, we need to make the header appear static
|
// If the screen is next to a headerless screen, we need to make the header appear static
|
||||||
// This makes the header look like it's moving with the screen
|
// This makes the header look like it's moving with the screen
|
||||||
|
|||||||
170
packages/stack/src/vendor/views/Header/HeaderContainer.tsx.orig
vendored
Normal file
170
packages/stack/src/vendor/views/Header/HeaderContainer.tsx.orig
vendored
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||||
|
import {
|
||||||
|
NavigationContext,
|
||||||
|
NavigationRouteContext,
|
||||||
|
Route,
|
||||||
|
ParamListBase,
|
||||||
|
} from '@react-navigation/native';
|
||||||
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
|
|
||||||
|
import Header from './Header';
|
||||||
|
import {
|
||||||
|
forSlideLeft,
|
||||||
|
forSlideUp,
|
||||||
|
forNoAnimation,
|
||||||
|
forSlideRight,
|
||||||
|
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
||||||
|
import HeaderShownContext from '../../utils/HeaderShownContext';
|
||||||
|
import PreviousSceneContext from '../../utils/PreviousSceneContext';
|
||||||
|
import type {
|
||||||
|
Layout,
|
||||||
|
Scene,
|
||||||
|
StackHeaderStyleInterpolator,
|
||||||
|
StackNavigationProp,
|
||||||
|
GestureDirection,
|
||||||
|
} from '../../types';
|
||||||
|
|
||||||
|
export type Props = {
|
||||||
|
mode: 'float' | 'screen';
|
||||||
|
layout: Layout;
|
||||||
|
insets: EdgeInsets;
|
||||||
|
scenes: (Scene<Route<string>> | undefined)[];
|
||||||
|
getPreviousScene: (props: {
|
||||||
|
route: Route<string>;
|
||||||
|
}) => Scene<Route<string>> | undefined;
|
||||||
|
getFocusedRoute: () => Route<string>;
|
||||||
|
onContentHeightChange?: (props: {
|
||||||
|
route: Route<string>;
|
||||||
|
height: number;
|
||||||
|
}) => void;
|
||||||
|
styleInterpolator: StackHeaderStyleInterpolator;
|
||||||
|
gestureDirection: GestureDirection;
|
||||||
|
style?: StyleProp<ViewStyle>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function HeaderContainer({
|
||||||
|
mode,
|
||||||
|
scenes,
|
||||||
|
layout,
|
||||||
|
insets,
|
||||||
|
getPreviousScene,
|
||||||
|
getFocusedRoute,
|
||||||
|
onContentHeightChange,
|
||||||
|
gestureDirection,
|
||||||
|
styleInterpolator,
|
||||||
|
style,
|
||||||
|
}: Props) {
|
||||||
|
const focusedRoute = getFocusedRoute();
|
||||||
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
||||||
|
const parentPreviousScene = React.useContext(PreviousSceneContext);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View pointerEvents="box-none" style={style}>
|
||||||
|
{scenes.slice(-3).map((scene, i, self) => {
|
||||||
|
if ((mode === 'screen' && i !== self.length - 1) || !scene) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
header,
|
||||||
|
headerShown = isParentHeaderShown === false,
|
||||||
|
headerTransparent,
|
||||||
|
} = scene.descriptor.options || {};
|
||||||
|
|
||||||
|
if (!headerShown) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isFocused = focusedRoute.key === scene.route.key;
|
||||||
|
const previous =
|
||||||
|
getPreviousScene({ route: scene.route }) ?? parentPreviousScene;
|
||||||
|
|
||||||
|
// If the screen is next to a headerless screen, we need to make the header appear static
|
||||||
|
// This makes the header look like it's moving with the screen
|
||||||
|
const previousScene = self[i - 1];
|
||||||
|
const nextScene = self[i + 1];
|
||||||
|
|
||||||
|
const {
|
||||||
|
headerShown: previousHeaderShown = isParentHeaderShown === false,
|
||||||
|
} = previousScene?.descriptor.options || {};
|
||||||
|
|
||||||
|
const { headerShown: nextHeaderShown = isParentHeaderShown === false } =
|
||||||
|
nextScene?.descriptor.options || {};
|
||||||
|
|
||||||
|
const isHeaderStatic =
|
||||||
|
(previousHeaderShown === false &&
|
||||||
|
// We still need to animate when coming back from next scene
|
||||||
|
// A hacky way to check this is if the next scene exists
|
||||||
|
!nextScene) ||
|
||||||
|
nextHeaderShown === false;
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
mode,
|
||||||
|
layout,
|
||||||
|
insets,
|
||||||
|
scene,
|
||||||
|
previous,
|
||||||
|
navigation: scene.descriptor.navigation as StackNavigationProp<
|
||||||
|
ParamListBase
|
||||||
|
>,
|
||||||
|
styleInterpolator:
|
||||||
|
mode === 'float'
|
||||||
|
? isHeaderStatic
|
||||||
|
? gestureDirection === 'vertical' ||
|
||||||
|
gestureDirection === 'vertical-inverted'
|
||||||
|
? forSlideUp
|
||||||
|
: gestureDirection === 'horizontal-inverted'
|
||||||
|
? forSlideRight
|
||||||
|
: forSlideLeft
|
||||||
|
: styleInterpolator
|
||||||
|
: forNoAnimation,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NavigationContext.Provider
|
||||||
|
key={scene.route.key}
|
||||||
|
value={scene.descriptor.navigation}
|
||||||
|
>
|
||||||
|
<NavigationRouteContext.Provider value={scene.route}>
|
||||||
|
<View
|
||||||
|
onLayout={
|
||||||
|
onContentHeightChange
|
||||||
|
? (e) =>
|
||||||
|
onContentHeightChange({
|
||||||
|
route: scene.route,
|
||||||
|
height: e.nativeEvent.layout.height,
|
||||||
|
})
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
pointerEvents={isFocused ? 'box-none' : 'none'}
|
||||||
|
accessibilityElementsHidden={!isFocused}
|
||||||
|
importantForAccessibility={
|
||||||
|
isFocused ? 'auto' : 'no-hide-descendants'
|
||||||
|
}
|
||||||
|
style={
|
||||||
|
// Avoid positioning the focused header absolutely
|
||||||
|
// Otherwise accessibility tools don't seem to be able to find it
|
||||||
|
(mode === 'float' && !isFocused) || headerTransparent
|
||||||
|
? styles.header
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{header !== undefined ? header(props) : <Header {...props} />}
|
||||||
|
</View>
|
||||||
|
</NavigationRouteContext.Provider>
|
||||||
|
</NavigationContext.Provider>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
header: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -7,12 +7,12 @@ import {
|
|||||||
Platform,
|
Platform,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
||||||
import { NavigationRoute } from 'react-navigation';
|
import type { NavigationRoute } from 'react-navigation';
|
||||||
import HeaderBackButton from './HeaderBackButton';
|
import HeaderBackButton from './HeaderBackButton';
|
||||||
import HeaderBackground from './HeaderBackground';
|
import HeaderBackground from './HeaderBackground';
|
||||||
import memoize from '../../utils/memoize';
|
import memoize from '../../utils/memoize';
|
||||||
import {
|
import type {
|
||||||
Layout,
|
Layout,
|
||||||
StackHeaderStyleInterpolator,
|
StackHeaderStyleInterpolator,
|
||||||
StackHeaderLeftButtonProps,
|
StackHeaderLeftButtonProps,
|
||||||
@@ -62,7 +62,6 @@ export const getDefaultHeaderHeight = (
|
|||||||
let headerHeight;
|
let headerHeight;
|
||||||
|
|
||||||
if (Platform.OS === 'ios') {
|
if (Platform.OS === 'ios') {
|
||||||
// @ts-ignore
|
|
||||||
if (isLandscape && !Platform.isPad) {
|
if (isLandscape && !Platform.isPad) {
|
||||||
headerHeight = 32;
|
headerHeight = 32;
|
||||||
} else {
|
} else {
|
||||||
@@ -208,7 +207,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
|||||||
borderTopStartRadius,
|
borderTopStartRadius,
|
||||||
borderTopWidth,
|
borderTopWidth,
|
||||||
borderWidth,
|
borderWidth,
|
||||||
// @ts-ignore: web support for shadow
|
// @ts-expect-error: web support for shadow
|
||||||
boxShadow,
|
boxShadow,
|
||||||
elevation,
|
elevation,
|
||||||
shadowColor,
|
shadowColor,
|
||||||
@@ -224,7 +223,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
|||||||
warnIfHeaderStylesDefined(unsafeStyles);
|
warnIfHeaderStylesDefined(unsafeStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
const safeStyles = {
|
const safeStyles: ViewStyle = {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
borderBottomColor,
|
borderBottomColor,
|
||||||
borderBottomEndRadius,
|
borderBottomEndRadius,
|
||||||
@@ -250,7 +249,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
|||||||
borderTopStartRadius,
|
borderTopStartRadius,
|
||||||
borderTopWidth,
|
borderTopWidth,
|
||||||
borderWidth,
|
borderWidth,
|
||||||
// @ts-ignore
|
// @ts-expect-error: boxShadow is only for Web
|
||||||
boxShadow,
|
boxShadow,
|
||||||
elevation,
|
elevation,
|
||||||
shadowColor,
|
shadowColor,
|
||||||
@@ -265,9 +264,9 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
|||||||
// So we need to filter them out
|
// So we need to filter them out
|
||||||
// Users can use `null` instead
|
// Users can use `null` instead
|
||||||
for (const styleProp in safeStyles) {
|
for (const styleProp in safeStyles) {
|
||||||
// @ts-ignore
|
// @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles
|
||||||
if (safeStyles[styleProp] === undefined) {
|
if (safeStyles[styleProp] === undefined) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
delete safeStyles[styleProp];
|
delete safeStyles[styleProp];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Animated, StyleSheet, Platform } from 'react-native';
|
import {
|
||||||
|
Animated,
|
||||||
|
StyleSheet,
|
||||||
|
Platform,
|
||||||
|
TextProps,
|
||||||
|
StyleProp,
|
||||||
|
TextStyle,
|
||||||
|
} from 'react-native';
|
||||||
import useTheme from '../../../utils/useTheme';
|
import useTheme from '../../../utils/useTheme';
|
||||||
|
|
||||||
type Props = Omit<React.ComponentProps<typeof Animated.Text>, 'key'> & {
|
type Props = Omit<TextProps, 'style'> & {
|
||||||
tintColor?: string;
|
tintColor?: string;
|
||||||
children?: string;
|
children?: string;
|
||||||
|
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function HeaderTitle({ tintColor, style, ...rest }: Props) {
|
export default function HeaderTitle({ tintColor, style, ...rest }: Props) {
|
||||||
@@ -13,6 +21,7 @@ export default function HeaderTitle({ tintColor, style, ...rest }: Props) {
|
|||||||
return (
|
return (
|
||||||
<Animated.Text
|
<Animated.Text
|
||||||
accessibilityRole="header"
|
accessibilityRole="header"
|
||||||
|
aria-level="1"
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
{...rest}
|
{...rest}
|
||||||
style={[
|
style={[
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default class KeyboardManager extends React.Component<Props> {
|
|||||||
|
|
||||||
// Numeric id of the previously focused text input
|
// Numeric id of the previously focused text input
|
||||||
// When a gesture didn't change the tab, we can restore the focused input with this
|
// When a gesture didn't change the tab, we can restore the focused input with this
|
||||||
private previouslyFocusedTextInput: number | null = null;
|
private previouslyFocusedTextInput: any | null = null;
|
||||||
private startTimestamp: number = 0;
|
private startTimestamp: number = 0;
|
||||||
private keyboardTimeout: any;
|
private keyboardTimeout: any;
|
||||||
|
|
||||||
@@ -35,7 +35,9 @@ export default class KeyboardManager extends React.Component<Props> {
|
|||||||
|
|
||||||
this.clearKeyboardTimeout();
|
this.clearKeyboardTimeout();
|
||||||
|
|
||||||
const input = TextInput.State.currentlyFocusedField();
|
const input: any = TextInput.State.currentlyFocusedInput
|
||||||
|
? TextInput.State.currentlyFocusedInput()
|
||||||
|
: TextInput.State.currentlyFocusedField();
|
||||||
|
|
||||||
// When a page change begins, blur the currently focused input
|
// When a page change begins, blur the currently focused input
|
||||||
TextInput.State.blurTextInput(input);
|
TextInput.State.blurTextInput(input);
|
||||||
|
|||||||
1
packages/stack/src/vendor/views/MaskedView.android.tsx
vendored
Normal file
1
packages/stack/src/vendor/views/MaskedView.android.tsx
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './MaskedViewNative';
|
||||||
1
packages/stack/src/vendor/views/MaskedView.ios.tsx
vendored
Normal file
1
packages/stack/src/vendor/views/MaskedView.ios.tsx
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './MaskedViewNative';
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import * as React from 'react';
|
/**
|
||||||
|
* Use a stub for MaskedView on all Platforms that don't support it.
|
||||||
|
*/
|
||||||
|
import type * as React from 'react';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
maskElement: React.ReactElement;
|
maskElement: React.ReactElement;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user