mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-18 18:08:17 +08:00
Compare commits
9 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8318c49331 | ||
|
|
ece6e3899e | ||
|
|
da944ccef9 | ||
|
|
bc3586ae3e | ||
|
|
19be2b4bbc | ||
|
|
a8851b730d | ||
|
|
7a5bcb446b | ||
|
|
1345a8fec6 | ||
|
|
7393464515 |
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"git": {
|
|
||||||
"commitMessage": "chore: release %s",
|
|
||||||
"tagName": "v%s"
|
|
||||||
},
|
|
||||||
"github": {
|
|
||||||
"release": true
|
|
||||||
},
|
|
||||||
"plugins": {
|
|
||||||
"@release-it/conventional-changelog": {
|
|
||||||
"preset": "angular"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable import/no-commonjs */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable import/no-commonjs */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ['@commitlint/config-conventional'],
|
extends: ['@commitlint/config-conventional'],
|
||||||
};
|
};
|
||||||
|
|||||||
20
package.json
20
package.json
@@ -23,22 +23,22 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||||
"@babel/preset-env": "^7.5.5",
|
"@babel/preset-env": "^7.6.2",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"@babel/preset-typescript": "^7.3.3",
|
"@babel/preset-typescript": "^7.6.0",
|
||||||
"@babel/runtime": "^7.5.5",
|
"@babel/runtime": "^7.6.2",
|
||||||
"@commitlint/config-conventional": "^8.0.0",
|
"@commitlint/config-conventional": "^8.2.0",
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
"codecov": "^3.5.0",
|
"codecov": "^3.6.1",
|
||||||
"commitlint": "^8.0.0",
|
"commitlint": "^8.2.0",
|
||||||
"core-js": "^3.2.1",
|
"core-js": "^3.2.1",
|
||||||
"eslint": "^5.16.0",
|
"eslint": "^6.5.1",
|
||||||
"eslint-config-satya164": "^2.4.1",
|
"eslint-config-satya164": "^3.1.2",
|
||||||
"husky": "^2.4.0",
|
"husky": "^3.0.8",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"lerna": "^3.16.4",
|
"lerna": "^3.16.4",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.11](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.10...@react-navigation/bottom-tabs@5.0.0-alpha.11) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.9...@react-navigation/bottom-tabs@5.0.0-alpha.10) (2019-09-27)
|
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.9...@react-navigation/bottom-tabs@5.0.0-alpha.10) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"android",
|
"android",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.10",
|
"version": "5.0.0-alpha.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -33,17 +33,17 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8",
|
"@react-navigation/routers": "^5.0.0-alpha.9",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "0.59.10",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -290,8 +290,7 @@ export default class TabBarBottom extends React.Component<Props, State> {
|
|||||||
style={[
|
style={[
|
||||||
styles.container,
|
styles.container,
|
||||||
keyboardHidesTabBar
|
keyboardHidesTabBar
|
||||||
? // eslint-disable-next-line react-native/no-inline-styles
|
? {
|
||||||
{
|
|
||||||
// When the keyboard is shown, slide down the tab bar
|
// When the keyboard is shown, slide down the tab bar
|
||||||
transform: [
|
transform: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,12 +24,7 @@ export default class ResourceSavingScene extends React.Component<Props> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[styles.container, style, { opacity: isVisible ? 1 : 0 }]}
|
||||||
styles.container,
|
|
||||||
style,
|
|
||||||
// eslint-disable-next-line react-native/no-inline-styles
|
|
||||||
{ opacity: isVisible ? 1 : 0 },
|
|
||||||
]}
|
|
||||||
collapsable={false}
|
collapsable={false}
|
||||||
removeClippedSubviews={
|
removeClippedSubviews={
|
||||||
// On iOS, set removeClippedSubviews to true only when not focused
|
// On iOS, set removeClippedSubviews to true only when not focused
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/compat@5.0.0-alpha.4...@react-navigation/compat@5.0.0-alpha.5) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/compat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/compat@5.0.0-alpha.3...@react-navigation/compat@5.0.0-alpha.4) (2019-09-27)
|
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/compat@5.0.0-alpha.3...@react-navigation/compat@5.0.0-alpha.4) (2019-09-27)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/compat
|
**Note:** Version bump only for package @react-navigation/compat
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/compat",
|
"name": "@react-navigation/compat",
|
||||||
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
||||||
"version": "5.0.0-alpha.4",
|
"version": "5.0.0-alpha.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -24,12 +24,12 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8"
|
"@react-navigation/routers": "^5.0.0-alpha.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^16.8.19",
|
"@types/react": "^16.9.4",
|
||||||
"react": "^16.8.3",
|
"react": "^16.8.3",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -3,6 +3,23 @@
|
|||||||
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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.12](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.11...@react-navigation/core@5.0.0-alpha.12) (2019-10-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* don't merge state with existing state during reset. fixes [#111](https://github.com/react-navigation/navigation-ex/issues/111) ([7393464](https://github.com/react-navigation/navigation-ex/commit/7393464))
|
||||||
|
* don't throw when switching navigator. fixes [#91](https://github.com/react-navigation/navigation-ex/issues/91) ([19be2b4](https://github.com/react-navigation/navigation-ex/commit/19be2b4))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add a getRootState method ([#119](https://github.com/react-navigation/navigation-ex/issues/119)) ([7a5bcb4](https://github.com/react-navigation/navigation-ex/commit/7a5bcb4))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.11](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.10...@react-navigation/core@5.0.0-alpha.11) (2019-09-27)
|
# [5.0.0-alpha.11](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.10...@react-navigation/core@5.0.0-alpha.11) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation"
|
"react-navigation"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.11",
|
"version": "5.0.0-alpha.12",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -31,19 +31,19 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"escape-string-regexp": "^2.0.0",
|
"escape-string-regexp": "^2.0.0",
|
||||||
"query-string": "^6.8.3",
|
"query-string": "^6.8.3",
|
||||||
"shortid": "^2.2.14",
|
"shortid": "^2.2.15",
|
||||||
"use-subscription": "^1.0.0"
|
"use-subscription": "^1.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.4.5",
|
"@babel/core": "^7.6.2",
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.19",
|
"@types/react": "^16.9.4",
|
||||||
"@types/shortid": "^0.0.29",
|
"@types/shortid": "^0.0.29",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "^16.8.3",
|
"react": "^16.8.3",
|
||||||
"react-native-testing-library": "^1.9.1",
|
"react-native-testing-library": "^1.9.1",
|
||||||
"react-test-renderer": "16.8.3",
|
"react-test-renderer": "16.8.3",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.3"
|
"react": "^16.8.3"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import shortid from 'shortid';
|
import shortid from 'shortid';
|
||||||
import { CommonAction, NavigationState } from './types';
|
import { CommonAction, NavigationState, PartialState } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base router object that can be used when writing custom routers.
|
* Base router object that can be used when writing custom routers.
|
||||||
@@ -9,7 +9,7 @@ const BaseRouter = {
|
|||||||
getStateForAction<State extends NavigationState>(
|
getStateForAction<State extends NavigationState>(
|
||||||
state: State,
|
state: State,
|
||||||
action: CommonAction
|
action: CommonAction
|
||||||
): State | null {
|
): State | PartialState<State> | null {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REPLACE': {
|
case 'REPLACE': {
|
||||||
const index = action.source
|
const index = action.source
|
||||||
@@ -56,12 +56,7 @@ const BaseRouter = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'RESET':
|
case 'RESET':
|
||||||
return {
|
return action.payload as PartialState<State>;
|
||||||
...state,
|
|
||||||
...action.payload,
|
|
||||||
key: state.key,
|
|
||||||
routeNames: state.routeNames,
|
|
||||||
};
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// eslint-disable-next-line import/no-cycle
|
||||||
import { NavigationState, PartialState } from './types';
|
import { NavigationState, PartialState } from './types';
|
||||||
|
|
||||||
export type Action =
|
export type Action =
|
||||||
|
|||||||
@@ -18,25 +18,30 @@ export const SingleNavigatorContext = React.createContext<
|
|||||||
* Component which ensures that there's only one navigator nested under it.
|
* Component which ensures that there's only one navigator nested under it.
|
||||||
*/
|
*/
|
||||||
export default function EnsureSingleNavigator({ children }: Props) {
|
export default function EnsureSingleNavigator({ children }: Props) {
|
||||||
const [currentKey, setCurrentKey] = React.useState<string | undefined>();
|
const navigatorKeyRef = React.useRef<string | undefined>();
|
||||||
|
|
||||||
const value = React.useMemo(
|
const value = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
register(key: string) {
|
register(key: string) {
|
||||||
|
const currentKey = navigatorKeyRef.current;
|
||||||
|
|
||||||
if (currentKey !== undefined && key !== currentKey) {
|
if (currentKey !== undefined && key !== currentKey) {
|
||||||
throw new Error(MULTIPLE_NAVIGATOR_ERROR);
|
throw new Error(MULTIPLE_NAVIGATOR_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentKey(key);
|
navigatorKeyRef.current = key;
|
||||||
},
|
},
|
||||||
unregister(key: string) {
|
unregister(key: string) {
|
||||||
if (currentKey !== undefined && key !== currentKey) {
|
const currentKey = navigatorKeyRef.current;
|
||||||
throw new Error(MULTIPLE_NAVIGATOR_ERROR);
|
|
||||||
|
if (key !== currentKey) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentKey(undefined);
|
navigatorKeyRef.current = undefined;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
[currentKey]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { NavigationAction, NavigationHelpers, ParamListBase } from './types';
|
import {
|
||||||
|
NavigationAction,
|
||||||
|
NavigationHelpers,
|
||||||
|
NavigationState,
|
||||||
|
ParamListBase,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
export type ChildActionListener = (
|
export type ChildActionListener = (
|
||||||
action: NavigationAction,
|
action: NavigationAction,
|
||||||
@@ -14,6 +19,8 @@ export type FocusedNavigationListener = <T>(
|
|||||||
callback: FocusedNavigationCallback<T>
|
callback: FocusedNavigationCallback<T>
|
||||||
) => { handled: boolean; result: T };
|
) => { handled: boolean; result: T };
|
||||||
|
|
||||||
|
export type NavigatorStateGetter = () => NavigationState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context which holds the required helpers needed to build nested navigators.
|
* Context which holds the required helpers needed to build nested navigators.
|
||||||
*/
|
*/
|
||||||
@@ -25,6 +32,7 @@ const NavigationBuilderContext = React.createContext<{
|
|||||||
addActionListener?: (listener: ChildActionListener) => void;
|
addActionListener?: (listener: ChildActionListener) => void;
|
||||||
addFocusedListener?: (listener: FocusedNavigationListener) => void;
|
addFocusedListener?: (listener: FocusedNavigationListener) => void;
|
||||||
onRouteFocus?: (key: string) => void;
|
onRouteFocus?: (key: string) => void;
|
||||||
|
addStateGetter?: (key: string, getter: NavigatorStateGetter) => void;
|
||||||
trackAction: (action: NavigationAction) => void;
|
trackAction: (action: NavigationAction) => void;
|
||||||
}>({
|
}>({
|
||||||
trackAction: () => undefined,
|
trackAction: () => undefined,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import NavigationBuilderContext from './NavigationBuilderContext';
|
|||||||
import ResetRootContext from './ResetRootContext';
|
import ResetRootContext from './ResetRootContext';
|
||||||
import useFocusedListeners from './useFocusedListeners';
|
import useFocusedListeners from './useFocusedListeners';
|
||||||
import useDevTools from './useDevTools';
|
import useDevTools from './useDevTools';
|
||||||
|
import useStateGetters from './useStateGetters';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Route,
|
Route,
|
||||||
@@ -24,7 +25,9 @@ const MISSING_CONTEXT_ERROR =
|
|||||||
export const NavigationStateContext = React.createContext<{
|
export const NavigationStateContext = React.createContext<{
|
||||||
state?: NavigationState | PartialState<NavigationState>;
|
state?: NavigationState | PartialState<NavigationState>;
|
||||||
getState: () => NavigationState | PartialState<NavigationState> | undefined;
|
getState: () => NavigationState | PartialState<NavigationState> | undefined;
|
||||||
setState: (state: NavigationState | undefined) => void;
|
setState: (
|
||||||
|
state: NavigationState | PartialState<NavigationState> | undefined
|
||||||
|
) => void;
|
||||||
key?: string;
|
key?: string;
|
||||||
performTransaction: (action: () => void) => void;
|
performTransaction: (action: () => void) => void;
|
||||||
}>({
|
}>({
|
||||||
@@ -106,6 +109,8 @@ const Container = React.forwardRef(function NavigationContainer(
|
|||||||
|
|
||||||
const { listeners, addListener: addFocusedListener } = useFocusedListeners();
|
const { listeners, addListener: addFocusedListener } = useFocusedListeners();
|
||||||
|
|
||||||
|
const { getStateForRoute, addStateGetter } = useStateGetters();
|
||||||
|
|
||||||
const dispatch = (
|
const dispatch = (
|
||||||
action: NavigationAction | ((state: NavigationState) => NavigationAction)
|
action: NavigationAction | ((state: NavigationState) => NavigationAction)
|
||||||
) => {
|
) => {
|
||||||
@@ -132,13 +137,16 @@ const Container = React.forwardRef(function NavigationContainer(
|
|||||||
[trackAction]
|
[trackAction]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getRootState = () => {
|
||||||
|
return getStateForRoute('root');
|
||||||
|
};
|
||||||
|
|
||||||
React.useImperativeHandle(ref, () => ({
|
React.useImperativeHandle(ref, () => ({
|
||||||
...(Object.keys(CommonActions) as Array<keyof typeof CommonActions>).reduce<
|
...(Object.keys(CommonActions) as Array<keyof typeof CommonActions>).reduce<
|
||||||
any
|
any
|
||||||
>((acc, name) => {
|
>((acc, name) => {
|
||||||
acc[name] = (...args: any[]) =>
|
acc[name] = (...args: any[]) =>
|
||||||
dispatch(
|
dispatch(
|
||||||
// eslint-disable-next-line import/namespace
|
|
||||||
CommonActions[name](
|
CommonActions[name](
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...args
|
...args
|
||||||
@@ -149,14 +157,16 @@ const Container = React.forwardRef(function NavigationContainer(
|
|||||||
resetRoot,
|
resetRoot,
|
||||||
dispatch,
|
dispatch,
|
||||||
canGoBack,
|
canGoBack,
|
||||||
|
getRootState,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const builderContext = React.useMemo(
|
const builderContext = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
addFocusedListener,
|
addFocusedListener,
|
||||||
|
addStateGetter,
|
||||||
trackAction,
|
trackAction,
|
||||||
}),
|
}),
|
||||||
[addFocusedListener, trackAction]
|
[addFocusedListener, trackAction, addStateGetter]
|
||||||
);
|
);
|
||||||
|
|
||||||
const performTransaction = React.useCallback((callback: () => void) => {
|
const performTransaction = React.useCallback((callback: () => void) => {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default function SceneView<
|
|||||||
}, [getState, route.key]);
|
}, [getState, route.key]);
|
||||||
|
|
||||||
const setCurrentState = React.useCallback(
|
const setCurrentState = React.useCallback(
|
||||||
(child: NavigationState | undefined) => {
|
(child: NavigationState | PartialState<NavigationState> | undefined) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
|
|||||||
@@ -125,15 +125,5 @@ it('resets state to new state with RESET', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toEqual({ ...STATE, index: 0, routes });
|
expect(result).toEqual({ index: 0, routes });
|
||||||
});
|
|
||||||
|
|
||||||
it('ignores key and routeNames when resetting with RESET', () => {
|
|
||||||
const result = BaseRouter.getStateForAction(
|
|
||||||
STATE,
|
|
||||||
// @ts-ignore
|
|
||||||
CommonActions.reset({ index: 2, key: 'foo', routeNames: ['test'] })
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result).toEqual({ ...STATE, index: 2 });
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -321,3 +321,56 @@ it('handle resetting state with ref', () => {
|
|||||||
expect(onStateChange).toBeCalledTimes(1);
|
expect(onStateChange).toBeCalledTimes(1);
|
||||||
expect(onStateChange).lastCalledWith(state);
|
expect(onStateChange).lastCalledWith(state);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handle getRootState', () => {
|
||||||
|
const TestNavigator = (props: any) => {
|
||||||
|
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
|
||||||
|
|
||||||
|
return descriptors[state.routes[state.index].key].render();
|
||||||
|
};
|
||||||
|
|
||||||
|
const ref = React.createRef<NavigationContainerRef>();
|
||||||
|
|
||||||
|
const element = (
|
||||||
|
<NavigationContainer ref={ref}>
|
||||||
|
<TestNavigator initialRouteName="foo">
|
||||||
|
<Screen name="foo">
|
||||||
|
{() => (
|
||||||
|
<TestNavigator>
|
||||||
|
<Screen name="qux" component={() => null} />
|
||||||
|
<Screen name="lex" component={() => null} />
|
||||||
|
</TestNavigator>
|
||||||
|
)}
|
||||||
|
</Screen>
|
||||||
|
<Screen name="bar" component={() => null} />
|
||||||
|
</TestNavigator>
|
||||||
|
</NavigationContainer>
|
||||||
|
);
|
||||||
|
|
||||||
|
render(element);
|
||||||
|
|
||||||
|
let state;
|
||||||
|
if (ref.current) {
|
||||||
|
state = ref.current.getRootState();
|
||||||
|
}
|
||||||
|
expect(state).toEqual({
|
||||||
|
index: 0,
|
||||||
|
key: '7',
|
||||||
|
routeNames: ['foo', 'bar'],
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
key: 'foo',
|
||||||
|
name: 'foo',
|
||||||
|
state: {
|
||||||
|
index: 0,
|
||||||
|
key: '8',
|
||||||
|
routeNames: ['qux', 'lex'],
|
||||||
|
routes: [{ key: 'qux', name: 'qux' }, { key: 'lex', name: 'lex' }],
|
||||||
|
stale: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ key: 'bar', name: 'bar' },
|
||||||
|
],
|
||||||
|
stale: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -655,6 +655,7 @@ it('throws when a React Element is not the direct children', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it("doesn't throw when direct children is Screen or empty element", () => {
|
it("doesn't throw when direct children is Screen or empty element", () => {
|
||||||
const TestNavigator = (props: any) => {
|
const TestNavigator = (props: any) => {
|
||||||
useNavigationBuilder(MockRouter, props);
|
useNavigationBuilder(MockRouter, props);
|
||||||
@@ -694,3 +695,30 @@ it('throws when multiple screens with same name are defined', () => {
|
|||||||
"A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named 'foo')"
|
"A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named 'foo')"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('switches rendered navigators', () => {
|
||||||
|
const TestNavigator = (props: any) => {
|
||||||
|
useNavigationBuilder(MockRouter, props);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const root = render(
|
||||||
|
<NavigationContainer>
|
||||||
|
<TestNavigator key="a">
|
||||||
|
<Screen name="foo" component={jest.fn()} />
|
||||||
|
</TestNavigator>
|
||||||
|
</NavigationContainer>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(() =>
|
||||||
|
root.update(
|
||||||
|
<NavigationContainer>
|
||||||
|
<TestNavigator key="b">
|
||||||
|
<Screen name="foo" component={jest.fn()} />
|
||||||
|
</TestNavigator>
|
||||||
|
</NavigationContainer>
|
||||||
|
)
|
||||||
|
).not.toThrowError(
|
||||||
|
'Another navigator is already registered for this container.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ it("action doesn't bubble if target is specified", () => {
|
|||||||
expect(onStateChange).not.toBeCalled();
|
expect(onStateChange).not.toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
it("doesn't crash if no navigator handled the action", () => {
|
it("doesn't crash if no navigator handled the action", () => {
|
||||||
const TestRouter = MockRouter;
|
const TestRouter = MockRouter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// eslint-disable-next-line import/no-cycle
|
||||||
import * as CommonActions from './CommonActions';
|
import * as CommonActions from './CommonActions';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
@@ -170,7 +171,10 @@ export type Router<
|
|||||||
* @param state State object to apply the action on.
|
* @param state State object to apply the action on.
|
||||||
* @param action Action object to apply.
|
* @param action Action object to apply.
|
||||||
*/
|
*/
|
||||||
getStateForAction(state: State, action: Action): State | null;
|
getStateForAction(
|
||||||
|
state: State,
|
||||||
|
action: Action
|
||||||
|
): State | PartialState<State> | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the action should also change focus in parent navigator
|
* Whether the action should also change focus in parent navigator
|
||||||
@@ -534,6 +538,7 @@ export type NavigationContainerRef =
|
|||||||
* @param state Navigation state object.
|
* @param state Navigation state object.
|
||||||
*/
|
*/
|
||||||
resetRoot(state: PartialState<NavigationState> | NavigationState): void;
|
resetRoot(state: PartialState<NavigationState> | NavigationState): void;
|
||||||
|
getRootState(): NavigationState;
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
| null;
|
| null;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import SceneView from './SceneView';
|
|||||||
import NavigationBuilderContext, {
|
import NavigationBuilderContext, {
|
||||||
ChildActionListener,
|
ChildActionListener,
|
||||||
FocusedNavigationListener,
|
FocusedNavigationListener,
|
||||||
|
NavigatorStateGetter,
|
||||||
} from './NavigationBuilderContext';
|
} from './NavigationBuilderContext';
|
||||||
import { NavigationEventEmitter } from './useEventEmitter';
|
import { NavigationEventEmitter } from './useEventEmitter';
|
||||||
import useNavigationCache from './useNavigationCache';
|
import useNavigationCache from './useNavigationCache';
|
||||||
@@ -35,6 +36,7 @@ type Options<State extends NavigationState, ScreenOptions extends object> = {
|
|||||||
setState: (state: State) => void;
|
setState: (state: State) => void;
|
||||||
addActionListener: (listener: ChildActionListener) => void;
|
addActionListener: (listener: ChildActionListener) => void;
|
||||||
addFocusedListener: (listener: FocusedNavigationListener) => void;
|
addFocusedListener: (listener: FocusedNavigationListener) => void;
|
||||||
|
addStateGetter: (key: string, getter: NavigatorStateGetter) => void;
|
||||||
onRouteFocus: (key: string) => void;
|
onRouteFocus: (key: string) => void;
|
||||||
router: Router<State, NavigationAction>;
|
router: Router<State, NavigationAction>;
|
||||||
emitter: NavigationEventEmitter;
|
emitter: NavigationEventEmitter;
|
||||||
@@ -61,6 +63,7 @@ export default function useDescriptors<
|
|||||||
setState,
|
setState,
|
||||||
addActionListener,
|
addActionListener,
|
||||||
addFocusedListener,
|
addFocusedListener,
|
||||||
|
addStateGetter,
|
||||||
onRouteFocus,
|
onRouteFocus,
|
||||||
router,
|
router,
|
||||||
emitter,
|
emitter,
|
||||||
@@ -74,6 +77,7 @@ export default function useDescriptors<
|
|||||||
onAction,
|
onAction,
|
||||||
addActionListener,
|
addActionListener,
|
||||||
addFocusedListener,
|
addFocusedListener,
|
||||||
|
addStateGetter,
|
||||||
onRouteFocus,
|
onRouteFocus,
|
||||||
trackAction,
|
trackAction,
|
||||||
}),
|
}),
|
||||||
@@ -83,6 +87,7 @@ export default function useDescriptors<
|
|||||||
addActionListener,
|
addActionListener,
|
||||||
addFocusedListener,
|
addFocusedListener,
|
||||||
onRouteFocus,
|
onRouteFocus,
|
||||||
|
addStateGetter,
|
||||||
trackAction,
|
trackAction,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type DevTools = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
namespace NodeJS {
|
namespace NodeJS {
|
||||||
interface Global {
|
interface Global {
|
||||||
__REDUX_DEVTOOLS_EXTENSION__:
|
__REDUX_DEVTOOLS_EXTENSION__:
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import {
|
|||||||
PrivateValueStore,
|
PrivateValueStore,
|
||||||
NavigationAction,
|
NavigationAction,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
import useStateGetters from './useStateGetters';
|
||||||
|
import useOnGetState from './useOnGetState';
|
||||||
|
|
||||||
// This is to make TypeScript compiler happy
|
// This is to make TypeScript compiler happy
|
||||||
// eslint-disable-next-line babel/no-unused-expressions
|
// eslint-disable-next-line babel/no-unused-expressions
|
||||||
@@ -227,6 +229,8 @@ export default function useNavigationBuilder<
|
|||||||
addListener: addFocusedListener,
|
addListener: addFocusedListener,
|
||||||
} = useFocusedListeners();
|
} = useFocusedListeners();
|
||||||
|
|
||||||
|
const { getStateForRoute, addStateGetter } = useStateGetters();
|
||||||
|
|
||||||
const onAction = useOnAction({
|
const onAction = useOnAction({
|
||||||
router,
|
router,
|
||||||
getState,
|
getState,
|
||||||
@@ -254,6 +258,11 @@ export default function useNavigationBuilder<
|
|||||||
focusedListeners,
|
focusedListeners,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useOnGetState({
|
||||||
|
getState,
|
||||||
|
getStateForRoute,
|
||||||
|
});
|
||||||
|
|
||||||
const descriptors = useDescriptors<State, ScreenOptions>({
|
const descriptors = useDescriptors<State, ScreenOptions>({
|
||||||
state,
|
state,
|
||||||
screens,
|
screens,
|
||||||
@@ -265,6 +274,7 @@ export default function useNavigationBuilder<
|
|||||||
onRouteFocus,
|
onRouteFocus,
|
||||||
addActionListener,
|
addActionListener,
|
||||||
addFocusedListener,
|
addFocusedListener,
|
||||||
|
addStateGetter,
|
||||||
router,
|
router,
|
||||||
emitter,
|
emitter,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,13 +2,18 @@ import * as React from 'react';
|
|||||||
import NavigationBuilderContext, {
|
import NavigationBuilderContext, {
|
||||||
ChildActionListener,
|
ChildActionListener,
|
||||||
} from './NavigationBuilderContext';
|
} from './NavigationBuilderContext';
|
||||||
import { NavigationAction, NavigationState, Router } from './types';
|
import {
|
||||||
|
NavigationAction,
|
||||||
|
NavigationState,
|
||||||
|
PartialState,
|
||||||
|
Router,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
router: Router<NavigationState, NavigationAction>;
|
router: Router<NavigationState, NavigationAction>;
|
||||||
key?: string;
|
key?: string;
|
||||||
getState: () => NavigationState;
|
getState: () => NavigationState;
|
||||||
setState: (state: NavigationState) => void;
|
setState: (state: NavigationState | PartialState<NavigationState>) => void;
|
||||||
listeners: ChildActionListener[];
|
listeners: ChildActionListener[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
31
packages/core/src/useOnGetState.tsx
Normal file
31
packages/core/src/useOnGetState.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import NavigationBuilderContext from './NavigationBuilderContext';
|
||||||
|
import { NavigationState } from './types';
|
||||||
|
import NavigationRouteContext from './NavigationRouteContext';
|
||||||
|
|
||||||
|
export default function useOnGetState({
|
||||||
|
getStateForRoute,
|
||||||
|
getState,
|
||||||
|
}: {
|
||||||
|
getStateForRoute: (routeName: string) => NavigationState | undefined;
|
||||||
|
getState: () => NavigationState;
|
||||||
|
}) {
|
||||||
|
const { addStateGetter } = React.useContext(NavigationBuilderContext);
|
||||||
|
const route = React.useContext(NavigationRouteContext);
|
||||||
|
const key = route ? route.key : 'root';
|
||||||
|
|
||||||
|
const getter = React.useCallback(() => {
|
||||||
|
const state = getState();
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
routes: state.routes.map(route => ({
|
||||||
|
...route,
|
||||||
|
state: getStateForRoute(route.key),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}, [getState, getStateForRoute]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
return addStateGetter && addStateGetter(key, getter);
|
||||||
|
}, [addStateGetter, getter, key]);
|
||||||
|
}
|
||||||
35
packages/core/src/useStateGetters.tsx
Normal file
35
packages/core/src/useStateGetters.tsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { NavigatorStateGetter } from './NavigationBuilderContext';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook which lets child navigators add getters to be called for obtaining rehydrated state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function useStateGetters() {
|
||||||
|
const stateGetters = React.useRef<Record<string, NavigatorStateGetter>>({});
|
||||||
|
|
||||||
|
const getStateForRoute = React.useCallback(
|
||||||
|
routeKey =>
|
||||||
|
stateGetters.current[routeKey] === undefined
|
||||||
|
? undefined
|
||||||
|
: stateGetters.current[routeKey](),
|
||||||
|
[stateGetters]
|
||||||
|
);
|
||||||
|
|
||||||
|
const addStateGetter = React.useCallback(
|
||||||
|
(key: string, getter: NavigatorStateGetter) => {
|
||||||
|
stateGetters.current[key] = getter;
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
// @ts-ignore
|
||||||
|
stateGetters.current[key] = undefined;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
getStateForRoute,
|
||||||
|
addStateGetter,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.11](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.10...@react-navigation/drawer@5.0.0-alpha.11) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.9...@react-navigation/drawer@5.0.0-alpha.10) (2019-09-27)
|
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.9...@react-navigation/drawer@5.0.0-alpha.10) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"drawer"
|
"drawer"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.10",
|
"version": "5.0.0-alpha.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,20 +34,20 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8",
|
"@react-navigation/routers": "^5.0.0-alpha.9",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "0.59.10",
|
||||||
"react-native-gesture-handler": "^1.3.0",
|
"react-native-gesture-handler": "^1.3.0",
|
||||||
"react-native-reanimated": "^1.1.0",
|
"react-native-reanimated": "^1.3.0",
|
||||||
"react-native-screens": "^1.0.0-alpha.22",
|
"react-native-screens": "^1.0.0-alpha.22",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -578,7 +578,6 @@ export default class DrawerView extends React.PureComponent<Props> {
|
|||||||
style={[
|
style={[
|
||||||
styles.container,
|
styles.container,
|
||||||
right ? { right: offset } : { left: offset },
|
right ? { right: offset } : { left: offset },
|
||||||
// eslint-disable-next-line react-native/no-inline-styles
|
|
||||||
{
|
{
|
||||||
transform: [{ translateX: drawerTranslateX }],
|
transform: [{ translateX: drawerTranslateX }],
|
||||||
opacity: this.drawerOpacity,
|
opacity: this.drawerOpacity,
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
|||||||
key={route.key}
|
key={route.key}
|
||||||
style={[
|
style={[
|
||||||
StyleSheet.absoluteFill,
|
StyleSheet.absoluteFill,
|
||||||
// eslint-disable-next-line react-native/no-inline-styles
|
|
||||||
{ opacity: isFocused ? 1 : 0 },
|
{ opacity: isFocused ? 1 : 0 },
|
||||||
]}
|
]}
|
||||||
isVisible={isFocused}
|
isVisible={isFocused}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.9](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.8...@react-navigation/example@5.0.0-alpha.9) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/example
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.7...@react-navigation/example@5.0.0-alpha.8) (2019-09-27)
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.7...@react-navigation/example@5.0.0-alpha.8) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable import/no-commonjs */
|
|
||||||
|
|
||||||
module.exports = function(api) {
|
module.exports = function(api) {
|
||||||
api.cache(true);
|
api.cache(true);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable import/no-commonjs, import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/example",
|
"name": "@react-navigation/example",
|
||||||
"description": "Demo app to showcase various functionality of React Navigation",
|
"description": "Demo app to showcase various functionality of React Navigation",
|
||||||
"version": "5.0.0-alpha.8",
|
"version": "5.0.0-alpha.9",
|
||||||
"private": true,
|
"private": true,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"nohoist": [
|
"nohoist": [
|
||||||
@@ -18,29 +18,29 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^10.0.0",
|
"@expo/vector-icons": "^10.0.0",
|
||||||
"@react-native-community/masked-view": "^0.1.1",
|
"@react-native-community/masked-view": "^0.1.1",
|
||||||
"expo": "^34.0.1",
|
"expo": "^35.0.0",
|
||||||
"expo-asset": "~6.0.0",
|
"expo-asset": "~7.0.0",
|
||||||
"query-string": "^6.8.3",
|
"query-string": "^6.8.3",
|
||||||
"react": "16.8.3",
|
"react": "^16.10.1",
|
||||||
"react-dom": "^16.8.3",
|
"react-dom": "^16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "^0.61.2",
|
||||||
"react-native-gesture-handler": "~1.3.0",
|
"react-native-gesture-handler": "~1.3.0",
|
||||||
"react-native-paper": "^3.0.0-alpha.3",
|
"react-native-paper": "^3.0.0-alpha.3",
|
||||||
"react-native-reanimated": "~1.1.0",
|
"react-native-reanimated": "~1.2.0",
|
||||||
"react-native-screens": "1.0.0-alpha.22",
|
"react-native-screens": "~1.0.0-alpha.23",
|
||||||
"react-native-tab-view": "2.7.1",
|
"react-native-tab-view": "2.10.0",
|
||||||
"react-native-unimodules": "~0.5.2",
|
"react-native-unimodules": "^0.7.0-rc.1",
|
||||||
"scheduler": "^0.14.0",
|
"scheduler": "^0.16.1",
|
||||||
"shortid": "^2.2.14",
|
"shortid": "^2.2.15",
|
||||||
"use-subscription": "^1.0.0"
|
"use-subscription": "^1.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.5.5",
|
"@babel/core": "^7.6.2",
|
||||||
"@types/react": "^16.8.23",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.57.65",
|
"@types/react-native": "^0.60.17",
|
||||||
"babel-preset-expo": "^6.0.0",
|
"babel-preset-expo": "^7.0.0",
|
||||||
"expo-cli": "^3.0.10",
|
"expo-cli": "^3.1.2",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"react-native-safe-area-view": "0.14.7"
|
"react-native-safe-area-view": "0.14.7"
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable import/namespace, import/default */
|
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default function Albums() {
|
|||||||
contentContainerStyle={styles.content}
|
contentContainerStyle={styles.content}
|
||||||
>
|
>
|
||||||
{COVERS.map((source, i) => (
|
{COVERS.map((source, i) => (
|
||||||
|
// eslint-disable-next-line react/no-array-index-key
|
||||||
<Image key={i} source={source} style={styles.cover} />
|
<Image key={i} source={source} style={styles.cover} />
|
||||||
))}
|
))}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function Chat() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
|
// eslint-disable-next-line react/no-array-index-key
|
||||||
key={i}
|
key={i}
|
||||||
style={[odd ? styles.odd : styles.even, styles.inverted]}
|
style={[odd ? styles.odd : styles.even, styles.inverted]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.9...@react-navigation/material-bottom-tabs@5.0.0-alpha.10) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.8...@react-navigation/material-bottom-tabs@5.0.0-alpha.9) (2019-09-27)
|
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.8...@react-navigation/material-bottom-tabs@5.0.0-alpha.9) (2019-09-27)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.9",
|
"version": "5.0.0-alpha.10",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,19 +34,19 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8"
|
"@react-navigation/routers": "^5.0.0-alpha.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"@types/react-native-vector-icons": "^6.4.1",
|
"@types/react-native-vector-icons": "^6.4.4",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "0.59.10",
|
||||||
"react-native-paper": "^3.0.0-alpha.3",
|
"react-native-paper": "^3.0.0-alpha.3",
|
||||||
"react-native-vector-icons": "^6.6.0",
|
"react-native-vector-icons": "^6.6.0",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.8...@react-navigation/material-top-tabs@5.0.0-alpha.9) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.7...@react-navigation/material-top-tabs@5.0.0-alpha.8) (2019-09-27)
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.7...@react-navigation/material-top-tabs@5.0.0-alpha.8) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.8",
|
"version": "5.0.0-alpha.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,19 +34,19 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8"
|
"@react-navigation/routers": "^5.0.0-alpha.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "^0.59.8",
|
"react-native": "^0.59.8",
|
||||||
"react-native-gesture-handler": "^1.3.0",
|
"react-native-gesture-handler": "^1.3.0",
|
||||||
"react-native-reanimated": "^1.1.0",
|
"react-native-reanimated": "^1.3.0",
|
||||||
"react-native-tab-view": "^2.10.0",
|
"react-native-tab-view": "^2.10.0",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.8...@react-navigation/native@5.0.0-alpha.9) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.7...@react-navigation/native@5.0.0-alpha.8) (2019-09-16)
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.7...@react-navigation/native@5.0.0-alpha.8) (2019-09-16)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"ios",
|
"ios",
|
||||||
"android"
|
"android"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.8",
|
"version": "5.0.0-alpha.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -31,12 +31,12 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "0.59.10",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0",
|
"@react-navigation/core": "^5.0.0-alpha.0",
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.8...@react-navigation/routers@5.0.0-alpha.9) (2019-10-03)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/routers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.7...@react-navigation/routers@5.0.0-alpha.8) (2019-09-27)
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.7...@react-navigation/routers@5.0.0-alpha.8) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation"
|
"react-navigation"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.8",
|
"version": "5.0.0-alpha.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -29,12 +29,12 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"shortid": "^2.2.14"
|
"shortid": "^2.2.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/core": "^5.0.0-alpha.0"
|
"@react-navigation/core": "^5.0.0-alpha.0"
|
||||||
|
|||||||
@@ -3,6 +3,19 @@
|
|||||||
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.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.21](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.20...@react-navigation/stack@5.0.0-alpha.21) (2019-10-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add missing React import ([ece6e38](https://github.com/react-navigation/navigation-ex/commit/ece6e38))
|
||||||
|
* fix header buttons not clickable on Android. fixes [#108](https://github.com/react-navigation/navigation-ex/issues/108) ([da944cc](https://github.com/react-navigation/navigation-ex/commit/da944cc))
|
||||||
|
* keep the routes we are closing or replacing ([bc3586a](https://github.com/react-navigation/navigation-ex/commit/bc3586a))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.20](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.19...@react-navigation/stack@5.0.0-alpha.20) (2019-09-27)
|
# [5.0.0-alpha.20](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.19...@react-navigation/stack@5.0.0-alpha.20) (2019-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"android",
|
"android",
|
||||||
"stack"
|
"stack"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.20",
|
"version": "5.0.0-alpha.21",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -33,21 +33,21 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.8",
|
"@react-navigation/routers": "^5.0.0-alpha.9",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
"@react-native-community/masked-view": "^0.1.1",
|
"@react-native-community/masked-view": "^0.1.1",
|
||||||
"@types/react": "^16.8.24",
|
"@types/react": "^16.9.4",
|
||||||
"@types/react-native": "^0.60.2",
|
"@types/react-native": "^0.60.17",
|
||||||
"del-cli": "^2.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "16.8.3",
|
"react": "16.8.3",
|
||||||
"react-native": "0.59.10",
|
"react-native": "0.59.10",
|
||||||
"react-native-gesture-handler": "^1.3.0",
|
"react-native-gesture-handler": "^1.3.0",
|
||||||
"react-native-reanimated": "^1.1.0",
|
"react-native-reanimated": "^1.3.0",
|
||||||
"react-native-screens": "^1.0.0-alpha.22",
|
"react-native-screens": "^1.0.0-alpha.22",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-native-community/masked-view": "^0.1.1",
|
"@react-native-community/masked-view": "^0.1.1",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactElement;
|
children: React.ReactElement;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -122,9 +122,8 @@ const {
|
|||||||
|
|
||||||
// We need to be prepared for both version of reanimated. With and w/out proc
|
// We need to be prepared for both version of reanimated. With and w/out proc
|
||||||
let memoizedSpring = spring;
|
let memoizedSpring = spring;
|
||||||
// @ts-ignore
|
|
||||||
if (Animated.proc) {
|
if (Animated.proc) {
|
||||||
// @ts-ignore
|
|
||||||
const springHelper = Animated.proc(
|
const springHelper = Animated.proc(
|
||||||
(
|
(
|
||||||
finished: Animated.Value<number>,
|
finished: Animated.Value<number>,
|
||||||
@@ -136,7 +135,7 @@ if (Animated.proc) {
|
|||||||
damping: Animated.Adaptable<number>,
|
damping: Animated.Adaptable<number>,
|
||||||
mass: Animated.Adaptable<number>,
|
mass: Animated.Adaptable<number>,
|
||||||
stiffness: Animated.Adaptable<number>,
|
stiffness: Animated.Adaptable<number>,
|
||||||
overshootClamping: Animated.Adaptable<boolean>,
|
overshootClamping: Animated.Adaptable<number>,
|
||||||
restSpeedThreshold: Animated.Adaptable<number>,
|
restSpeedThreshold: Animated.Adaptable<number>,
|
||||||
restDisplacementThreshold: Animated.Adaptable<number>,
|
restDisplacementThreshold: Animated.Adaptable<number>,
|
||||||
clock: Animated.Clock
|
clock: Animated.Clock
|
||||||
@@ -177,7 +176,7 @@ if (Animated.proc) {
|
|||||||
damping: Animated.Adaptable<number>;
|
damping: Animated.Adaptable<number>;
|
||||||
mass: Animated.Adaptable<number>;
|
mass: Animated.Adaptable<number>;
|
||||||
stiffness: Animated.Adaptable<number>;
|
stiffness: Animated.Adaptable<number>;
|
||||||
overshootClamping: Animated.Adaptable<boolean>;
|
overshootClamping: Animated.Adaptable<number>;
|
||||||
restSpeedThreshold: Animated.Adaptable<number>;
|
restSpeedThreshold: Animated.Adaptable<number>;
|
||||||
restDisplacementThreshold: Animated.Adaptable<number>;
|
restDisplacementThreshold: Animated.Adaptable<number>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { View, StyleSheet, Platform, StyleProp, ViewStyle } from 'react-native';
|
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||||
import Animated from 'react-native-reanimated';
|
import Animated from 'react-native-reanimated';
|
||||||
import { StackNavigationState } from '@react-navigation/routers';
|
import { StackNavigationState } from '@react-navigation/routers';
|
||||||
import { Route } from '@react-navigation/core';
|
import { Route } from '@react-navigation/core';
|
||||||
@@ -165,7 +165,6 @@ export default class StackItem extends React.PureComponent<Props> {
|
|||||||
state,
|
state,
|
||||||
getPreviousRoute,
|
getPreviousRoute,
|
||||||
styleInterpolator: headerStyleInterpolator,
|
styleInterpolator: headerStyleInterpolator,
|
||||||
style: styles.header,
|
|
||||||
})
|
})
|
||||||
: null}
|
: null}
|
||||||
</View>
|
</View>
|
||||||
@@ -182,8 +181,4 @@ const styles = StyleSheet.create({
|
|||||||
scene: {
|
scene: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
header: {
|
|
||||||
// This is needed to show elevation shadow
|
|
||||||
zIndex: Platform.OS === 'android' ? 1 : 0,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,10 +57,6 @@ class StackView extends React.Component<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!routes.length) {
|
|
||||||
throw new Error(`There should always be at least one route.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there was no change in routes, we don't need to compute anything
|
// If there was no change in routes, we don't need to compute anything
|
||||||
if (routes === state.routes || !state.routes.length) {
|
if (routes === state.routes || !state.routes.length) {
|
||||||
return {
|
return {
|
||||||
@@ -144,6 +140,20 @@ class StackView extends React.Component<Props, State> {
|
|||||||
// i.e. the currently focused route already existed and the previously focused route still exists
|
// i.e. the currently focused route already existed and the previously focused route still exists
|
||||||
// We don't know how to animate this
|
// We don't know how to animate this
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Keep the routes we are closing or replacing
|
||||||
|
routes = routes.slice();
|
||||||
|
routes.splice(
|
||||||
|
routes.length - 1,
|
||||||
|
0,
|
||||||
|
...state.routes.filter(
|
||||||
|
({ key }) => replacing.includes(key) || closing.includes(key)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routes.length) {
|
||||||
|
throw new Error(`There should always be at least one route.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const descriptors = routes.reduce(
|
const descriptors = routes.reduce(
|
||||||
|
|||||||
Reference in New Issue
Block a user