mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-15 09:42:27 +08:00
Compare commits
8 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85e9376302 | ||
|
|
a67b49477e | ||
|
|
225cb298b6 | ||
|
|
c8ea4199f4 | ||
|
|
f16700812f | ||
|
|
240ce01822 | ||
|
|
c7dd3a58b1 | ||
|
|
125bd70e49 |
@@ -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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.6...@react-navigation/bottom-tabs@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.5...@react-navigation/bottom-tabs@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.5...@react-navigation/bottom-tabs@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/bottom-tabs",
|
"name": "@react-navigation/bottom-tabs",
|
||||||
"description": "Bottom tab navigator following iOS design guidelines",
|
"description": "Bottom tab navigator following iOS design guidelines",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.60.30",
|
||||||
|
|||||||
@@ -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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.6...@react-navigation/compat@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/compat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.5...@react-navigation/compat@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.5...@react-navigation/compat@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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.6",
|
"version": "5.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
|
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
|
|||||||
@@ -3,6 +3,18 @@
|
|||||||
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.1.6](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.5...@react-navigation/core@5.1.6) (2020-02-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* avoid emitting focus events twice ([f167008](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/f16700812f3757713b04ca3a860209795b4a6c44)), closes [#6749](https://github.com/react-navigation/react-navigation/tree/master/packages/core/issues/6749)
|
||||||
|
* preserve screen order with numeric names ([125bd70](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/125bd70e49b708d936a2eee72ba5cb92eacf26a9)), closes [#6900](https://github.com/react-navigation/react-navigation/tree/master/packages/core/issues/6900)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.5](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.4...@react-navigation/core@5.1.5) (2020-02-19)
|
## [5.1.5](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.4...@react-navigation/core@5.1.5) (2020-02-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/core",
|
"name": "@react-navigation/core",
|
||||||
"description": "Core utilities for building navigators",
|
"description": "Core utilities for building navigators",
|
||||||
"version": "5.1.5",
|
"version": "5.1.6",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.1",
|
"@react-navigation/routers": "^5.0.2",
|
||||||
"escape-string-regexp": "^2.0.0",
|
"escape-string-regexp": "^2.0.0",
|
||||||
"query-string": "^6.10.1",
|
"query-string": "^6.10.1",
|
||||||
"react-is": "^16.12.0",
|
"react-is": "^16.12.0",
|
||||||
|
|||||||
@@ -772,6 +772,60 @@ it('gives access to internal state', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('preserves order of screens in state with non-numeric names', () => {
|
||||||
|
const TestNavigator = (props: any): any => {
|
||||||
|
useNavigationBuilder(MockRouter, props);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const navigation = React.createRef<NavigationContainerRef>();
|
||||||
|
|
||||||
|
const root = (
|
||||||
|
<BaseNavigationContainer ref={navigation}>
|
||||||
|
<TestNavigator>
|
||||||
|
<Screen name="foo" component={jest.fn()} />
|
||||||
|
<Screen name="bar" component={jest.fn()} />
|
||||||
|
<Screen name="baz" component={jest.fn()} />
|
||||||
|
</TestNavigator>
|
||||||
|
</BaseNavigationContainer>
|
||||||
|
);
|
||||||
|
|
||||||
|
render(root);
|
||||||
|
|
||||||
|
expect(navigation.current?.getRootState().routeNames).toEqual([
|
||||||
|
'foo',
|
||||||
|
'bar',
|
||||||
|
'baz',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preserves order of screens in state with numeric names', () => {
|
||||||
|
const TestNavigator = (props: any): any => {
|
||||||
|
useNavigationBuilder(MockRouter, props);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const navigation = React.createRef<NavigationContainerRef>();
|
||||||
|
|
||||||
|
const root = (
|
||||||
|
<BaseNavigationContainer ref={navigation}>
|
||||||
|
<TestNavigator>
|
||||||
|
<Screen name="4" component={jest.fn()} />
|
||||||
|
<Screen name="7" component={jest.fn()} />
|
||||||
|
<Screen name="1" component={jest.fn()} />
|
||||||
|
</TestNavigator>
|
||||||
|
</BaseNavigationContainer>
|
||||||
|
);
|
||||||
|
|
||||||
|
render(root);
|
||||||
|
|
||||||
|
expect(navigation.current?.getRootState().routeNames).toEqual([
|
||||||
|
'4',
|
||||||
|
'7',
|
||||||
|
'1',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("throws if navigator doesn't have any screens", () => {
|
it("throws if navigator doesn't have any screens", () => {
|
||||||
const TestNavigator = (props: any) => {
|
const TestNavigator = (props: any) => {
|
||||||
useNavigationBuilder(MockRouter, props);
|
useNavigationBuilder(MockRouter, props);
|
||||||
|
|||||||
@@ -188,10 +188,12 @@ it('fires focus and blur events in nested navigator', () => {
|
|||||||
|
|
||||||
expect(thirdFocusCallback).toBeCalledTimes(0);
|
expect(thirdFocusCallback).toBeCalledTimes(0);
|
||||||
expect(secondFocusCallback).toBeCalledTimes(1);
|
expect(secondFocusCallback).toBeCalledTimes(1);
|
||||||
|
expect(fourthBlurCallback).toBeCalledTimes(0);
|
||||||
|
|
||||||
act(() => parent.current.navigate('nested'));
|
act(() => parent.current.navigate('nested'));
|
||||||
|
|
||||||
expect(firstBlurCallback).toBeCalledTimes(1);
|
expect(firstBlurCallback).toBeCalledTimes(1);
|
||||||
|
expect(secondBlurCallback).toBeCalledTimes(1);
|
||||||
expect(thirdFocusCallback).toBeCalledTimes(0);
|
expect(thirdFocusCallback).toBeCalledTimes(0);
|
||||||
expect(fourthFocusCallback).toBeCalledTimes(1);
|
expect(fourthFocusCallback).toBeCalledTimes(1);
|
||||||
|
|
||||||
@@ -199,6 +201,35 @@ it('fires focus and blur events in nested navigator', () => {
|
|||||||
|
|
||||||
expect(fourthBlurCallback).toBeCalledTimes(1);
|
expect(fourthBlurCallback).toBeCalledTimes(1);
|
||||||
expect(thirdFocusCallback).toBeCalledTimes(1);
|
expect(thirdFocusCallback).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
act(() => parent.current.navigate('first'));
|
||||||
|
|
||||||
|
expect(firstFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(thirdBlurCallback).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
act(() => parent.current.navigate('nested', { screen: 'fourth' }));
|
||||||
|
|
||||||
|
expect(fourthFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(thirdBlurCallback).toBeCalledTimes(1);
|
||||||
|
expect(firstBlurCallback).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
act(() => parent.current.navigate('nested', { screen: 'third' }));
|
||||||
|
|
||||||
|
expect(thirdFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(fourthBlurCallback).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
// Make sure nothing else has changed
|
||||||
|
expect(firstFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(firstBlurCallback).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
expect(secondFocusCallback).toBeCalledTimes(1);
|
||||||
|
expect(secondBlurCallback).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
expect(thirdFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(thirdBlurCallback).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
expect(fourthFocusCallback).toBeCalledTimes(2);
|
||||||
|
expect(fourthBlurCallback).toBeCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fires blur event when a route is removed with a delay', async () => {
|
it('fires blur event when a route is removed with a delay', async () => {
|
||||||
|
|||||||
@@ -21,17 +21,19 @@ export default function useFocusEvents({ state, emitter }: Options) {
|
|||||||
// Coz the child screen can't be focused if the parent screen is out of focus
|
// Coz the child screen can't be focused if the parent screen is out of focus
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
() =>
|
() =>
|
||||||
navigation?.addListener('focus', () =>
|
navigation?.addListener('focus', () => {
|
||||||
emitter.emit({ type: 'focus', target: currentFocusedKey })
|
lastFocusedKeyRef.current = currentFocusedKey;
|
||||||
),
|
emitter.emit({ type: 'focus', target: currentFocusedKey });
|
||||||
|
}),
|
||||||
[currentFocusedKey, emitter, navigation]
|
[currentFocusedKey, emitter, navigation]
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
() =>
|
() =>
|
||||||
navigation?.addListener('blur', () =>
|
navigation?.addListener('blur', () => {
|
||||||
emitter.emit({ type: 'blur', target: currentFocusedKey })
|
lastFocusedKeyRef.current = undefined;
|
||||||
),
|
emitter.emit({ type: 'blur', target: currentFocusedKey });
|
||||||
|
}),
|
||||||
[currentFocusedKey, emitter, navigation]
|
[currentFocusedKey, emitter, navigation]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -60,14 +62,7 @@ export default function useFocusEvents({ state, emitter }: Options) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.emit({
|
emitter.emit({ type: 'focus', target: currentFocusedKey });
|
||||||
type: 'focus',
|
emitter.emit({ type: 'blur', target: lastFocusedKey });
|
||||||
target: currentFocusedKey,
|
|
||||||
});
|
|
||||||
|
|
||||||
emitter.emit({
|
|
||||||
type: 'blur',
|
|
||||||
target: lastFocusedKey,
|
|
||||||
});
|
|
||||||
}, [currentFocusedKey, emitter, navigation]);
|
}, [currentFocusedKey, emitter, navigation]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,20 +177,21 @@ export default function useNavigationBuilder<
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const screens = getRouteConfigsFromChildren<ScreenOptions>(children).reduce<
|
const routeConfigs = getRouteConfigsFromChildren<ScreenOptions>(children);
|
||||||
|
const screens = routeConfigs.reduce<
|
||||||
Record<string, RouteConfig<ParamListBase, string, ScreenOptions>>
|
Record<string, RouteConfig<ParamListBase, string, ScreenOptions>>
|
||||||
>((acc, curr) => {
|
>((acc, config) => {
|
||||||
if (curr.name in acc) {
|
if (config.name in acc) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${curr.name}')`
|
`A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config.name}')`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
acc[curr.name] = curr;
|
acc[config.name] = config;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const routeNames = Object.keys(screens);
|
const routeNames = routeConfigs.map(config => config.name);
|
||||||
const routeParamList = routeNames.reduce<Record<string, object | undefined>>(
|
const routeParamList = routeNames.reduce<Record<string, object | undefined>>(
|
||||||
(acc, curr) => {
|
(acc, curr) => {
|
||||||
const { initialParams } = screens[curr];
|
const { initialParams } = screens[curr];
|
||||||
|
|||||||
@@ -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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.6...@react-navigation/drawer@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.5...@react-navigation/drawer@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.5...@react-navigation/drawer@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/drawer",
|
"name": "@react-navigation/drawer",
|
||||||
"description": "Drawer navigator component with animated transitions and gesturess",
|
"description": "Drawer navigator component with animated transitions and gesturess",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.60.30",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.6...@react-navigation/material-bottom-tabs@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.5...@react-navigation/material-bottom-tabs@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.5...@react-navigation/material-bottom-tabs@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-bottom-tabs",
|
"name": "@react-navigation/material-bottom-tabs",
|
||||||
"description": "Integration for bottom navigation component from react-native-paper",
|
"description": "Integration for bottom navigation component from react-native-paper",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.60.30",
|
||||||
"@types/react-native-vector-icons": "^6.4.5",
|
"@types/react-native-vector-icons": "^6.4.5",
|
||||||
|
|||||||
@@ -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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.6...@react-navigation/material-top-tabs@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.5...@react-navigation/material-top-tabs@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.5...@react-navigation/material-top-tabs@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-top-tabs",
|
"name": "@react-navigation/material-top-tabs",
|
||||||
"description": "Integration for the animated tab view component from react-native-tab-view",
|
"description": "Integration for the animated tab view component from react-native-tab-view",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.60.30",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.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.7](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.6...@react-navigation/native@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.5...@react-navigation/native@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.5...@react-navigation/native@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/native
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/native",
|
"name": "@react-navigation/native",
|
||||||
"description": "React Native integration for React Navigation",
|
"description": "React Native integration for React Navigation",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation",
|
"react-navigation",
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/core": "^5.1.5"
|
"@react-navigation/core": "^5.1.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
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.2](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.0.1...@react-navigation/routers@5.0.2) (2020-02-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* tweak error message for navigate ([c8ea419](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/commit/c8ea4199f4b19a58d5e409cfcc96e587fe354a9a))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.0.0-alpha.33...@react-navigation/routers@5.0.1) (2020-02-10)
|
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.0.0-alpha.33...@react-navigation/routers@5.0.1) (2020-02-10)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/routers",
|
"name": "@react-navigation/routers",
|
||||||
"description": "Routers to help build custom navigators",
|
"description": "Routers to help build custom navigators",
|
||||||
"version": "5.0.1",
|
"version": "5.0.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export function navigate(...args: any): Action {
|
|||||||
|
|
||||||
if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
|
if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'While calling navigate with an object as the argument, you need to specify name or key'
|
'You need to specify name or key when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions.html#navigate for usage.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import * as CommonActions from '../CommonActions';
|
|||||||
it('throws if NAVIGATE is called without key or name', () => {
|
it('throws if NAVIGATE is called without key or name', () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(() => CommonActions.navigate({})).toThrowError(
|
expect(() => CommonActions.navigate({})).toThrowError(
|
||||||
'While calling navigate with an object as the argument, you need to specify name or key'
|
'You need to specify name or key when calling navigate with an object as the argument.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,29 @@
|
|||||||
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.8](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.7...@react-navigation/stack@5.0.8) (2020-02-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix transparent header on Android ([a67b494](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/a67b49477eb500c81fedcd73bbd8102901a95170))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [5.0.7](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.6...@react-navigation/stack@5.0.7) (2020-02-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* debounce back button by default in stack header ([c7dd3a5](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/c7dd3a58b18d7a267d94009d459944c251ea74c1))
|
||||||
|
* make sure header is visibile to accessibility tools on iOS ([240ce01](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/240ce01822febac2c1aa324c01e43fdc88a235a0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.5...@react-navigation/stack@5.0.6) (2020-02-19)
|
## [5.0.6](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.5...@react-navigation/stack@5.0.6) (2020-02-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/stack",
|
"name": "@react-navigation/stack",
|
||||||
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
||||||
"version": "5.0.6",
|
"version": "5.0.8",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.9.3",
|
||||||
"@react-native-community/masked-view": "^0.1.6",
|
"@react-native-community/masked-view": "^0.1.6",
|
||||||
"@react-navigation/native": "^5.0.6",
|
"@react-navigation/native": "^5.0.7",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.19",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.60.30",
|
||||||
|
|||||||
17
packages/stack/src/utils/debounce.tsx
Normal file
17
packages/stack/src/utils/debounce.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export default function debounce<T extends (...args: any[]) => void>(
|
||||||
|
func: T,
|
||||||
|
duration: number
|
||||||
|
): T {
|
||||||
|
let timeout: NodeJS.Timeout | number | undefined;
|
||||||
|
|
||||||
|
return function(this: any, ...args) {
|
||||||
|
if (!timeout) {
|
||||||
|
// eslint-disable-next-line babel/no-invalid-this
|
||||||
|
func.apply(this, args);
|
||||||
|
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
timeout = undefined;
|
||||||
|
}, duration);
|
||||||
|
}
|
||||||
|
} as T;
|
||||||
|
}
|
||||||
@@ -2,8 +2,9 @@ import * as React from 'react';
|
|||||||
import { StackActions } from '@react-navigation/native';
|
import { StackActions } from '@react-navigation/native';
|
||||||
|
|
||||||
import HeaderSegment from './HeaderSegment';
|
import HeaderSegment from './HeaderSegment';
|
||||||
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
|
||||||
import HeaderTitle from './HeaderTitle';
|
import HeaderTitle from './HeaderTitle';
|
||||||
|
import debounce from '../../utils/debounce';
|
||||||
|
import { StackHeaderProps, StackHeaderTitleProps } from '../../types';
|
||||||
|
|
||||||
export default React.memo(function Header(props: StackHeaderProps) {
|
export default React.memo(function Header(props: StackHeaderProps) {
|
||||||
const {
|
const {
|
||||||
@@ -40,6 +41,18 @@ export default React.memo(function Header(props: StackHeaderProps) {
|
|||||||
: previous.route.name;
|
: previous.route.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goBack = React.useCallback(
|
||||||
|
debounce(() => {
|
||||||
|
if (navigation.canGoBack()) {
|
||||||
|
navigation.dispatch({
|
||||||
|
...StackActions.pop(),
|
||||||
|
source: scene.route.key,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 50),
|
||||||
|
[navigation, scene.route.key]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeaderSegment
|
<HeaderSegment
|
||||||
{...options}
|
{...options}
|
||||||
@@ -53,18 +66,7 @@ export default React.memo(function Header(props: StackHeaderProps) {
|
|||||||
? (props: StackHeaderTitleProps) => <HeaderTitle {...props} />
|
? (props: StackHeaderTitleProps) => <HeaderTitle {...props} />
|
||||||
: options.headerTitle
|
: options.headerTitle
|
||||||
}
|
}
|
||||||
onGoBack={
|
onGoBack={previous ? goBack : undefined}
|
||||||
previous
|
|
||||||
? () => {
|
|
||||||
if (navigation.canGoBack()) {
|
|
||||||
navigation.dispatch({
|
|
||||||
...StackActions.pop(),
|
|
||||||
source: scene.route.key,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
styleInterpolator={styleInterpolator}
|
styleInterpolator={styleInterpolator}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -137,7 +137,9 @@ export default function HeaderContainer({
|
|||||||
isFocused ? 'auto' : 'no-hide-descendants'
|
isFocused ? 'auto' : 'no-hide-descendants'
|
||||||
}
|
}
|
||||||
style={
|
style={
|
||||||
mode === 'float' || options.headerTransparent
|
// Avoid positioning the focused header absolutely
|
||||||
|
// Otherwise accessibility tools don't seem to be able to find it
|
||||||
|
(mode === 'float' && !isFocused) || options.headerTransparent
|
||||||
? styles.header
|
? styles.header
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user