Compare commits

...

18 Commits

Author SHA1 Message Date
Satyajit Sahoo
f34ec46111 chore: publish
- react-navigation-animated-switch@0.5.12
 - @react-navigation/core@3.7.6
 - react-navigation-drawer@2.4.13
 - react-navigation-material-bottom-tabs@2.2.12
 - @react-navigation/native@3.7.13
 - react-navigation@4.3.9
 - react-navigation-stack@2.4.0
 - react-navigation-tabs@2.8.13
2020-05-01 01:45:52 +02:00
Satyajit Sahoo
8b79e9bee6 feat: sync latest stack 2020-05-01 01:45:10 +02:00
linzera
e09906a423 fix: change old docUrl to new docUrl due v5 2020-04-30 16:57:36 +02:00
Satyajit Sahoo
ed7ffb98f4 chore: publish
- react-navigation-animated-switch@0.5.11
 - react-navigation-drawer@2.4.12
 - react-navigation-material-bottom-tabs@2.2.11
 - @react-navigation/native@3.7.12
 - react-navigation@4.3.8
 - react-navigation-stack@2.3.13
 - react-navigation-tabs@2.8.12
2020-04-22 16:47:35 +02:00
Satyajit Sahoo
90eff6a5e2 chore: sync latest stack 2020-04-22 16:45:32 +02:00
Satyajit Sahoo
b4691d7de2 chore: update react-native-safe-area-view 2020-04-22 16:31:49 +02:00
Satyajit Sahoo
f99f523a37 chore: publish
- react-navigation-stack@2.3.12
2020-04-18 01:49:20 +02:00
Satyajit Sahoo
05b47dbb09 chore: sync latest stack 2020-04-18 01:48:06 +02:00
Alejandro
4c4e66f05c fix: stack peer warnings 2020-04-18 01:15:41 +02:00
Satyajit Sahoo
720d1f970d chore: publish
- react-navigation-animated-switch@0.5.10
 - @react-navigation/core@3.7.5
 - react-navigation-drawer@2.4.11
 - react-navigation-material-bottom-tabs@2.2.10
 - @react-navigation/native@3.7.11
 - react-navigation@4.3.7
 - react-navigation-stack@2.3.11
 - react-navigation-tabs@2.8.11
2020-04-02 12:30:56 +02:00
Satyajit Sahoo
66a4dbccd8 fix: emit refocus for child navigators 2020-04-02 12:29:54 +02:00
Satyajit Sahoo
7925f0c8a3 chore: publish
- react-navigation-animated-switch@0.5.9
 - @react-navigation/core@3.7.4
 - react-navigation-drawer@2.4.10
 - react-navigation-material-bottom-tabs@2.2.9
 - @react-navigation/native@3.7.10
 - react-navigation@4.3.6
 - react-navigation-stack@2.3.10
 - react-navigation-tabs@2.8.10
2020-03-31 18:19:11 +02:00
Satyajit Sahoo
b3d77b79b7 chore: update typescript 2020-03-31 18:15:29 +02:00
Satyajit Sahoo
1d527ce16a chore: sync latest stack 2020-03-31 18:07:52 +02:00
Satyajit Sahoo
3bec1c964a fix: remove isTransitioning from SwitchRouter state 2020-03-31 17:38:42 +02:00
osdnk
a7e0c193cd chore: publish
- react-navigation-animated-switch@0.5.8
 - @react-navigation/core@3.7.3
 - react-navigation-drawer@2.4.9
 - react-navigation-material-bottom-tabs@2.2.8
 - @react-navigation/native@3.7.9
 - react-navigation@4.3.5
 - react-navigation-stack@2.3.9
 - react-navigation-tabs@2.8.9
2020-03-28 22:34:14 +01:00
Satyajit Sahoo
ac98c0a668 fix: always emit didFocus/didBlur for root navigator 2020-03-28 17:20:33 +01:00
Satyajit Sahoo
14a6538cc8 fix: emit didFocus and didBlur events based on parent's transition 2020-03-28 16:04:06 +01:00
48 changed files with 1603 additions and 837 deletions

View File

@@ -41,7 +41,7 @@ import StackWithTranslucentHeader from './src/StackWithTranslucentHeader';
import SwitchWithStacks from './src/SwitchWithStacks';
import TabsInDrawer from './src/TabsInDrawer';
import DragLimitedToModal from './src/DragLimitedToModal';
import EventsStack from './src/EventsStack';
import FocusEvents from './src/FocusEvents';
import FullScreen from './src/FullScreen';
import GestureInteraction from './src/GestureInteraction';
import {
@@ -144,7 +144,7 @@ const ExampleInfo = {
name: 'Drag limited to modal',
screen: DragLimitedToModal,
},
EventsStack: { name: 'Events Stack', screen: EventsStack },
EventsStack: { name: 'Focus Events', screen: FocusEvents },
FullScreen: { name: 'Fullscreen Stack', screen: FullScreen },
GestureInteraction: {
name: 'Gesture interaction',

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { Button, ScrollView, View, Text } from 'react-native';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import {
createStackNavigator,
NavigationStackProp,
@@ -22,24 +23,36 @@ class FocusTag extends React.Component<NavigationStackScreenProps> {
state = { mode: 'didBlur' };
componentDidMount() {
this.props.navigation.addListener('willFocus', () => {
this.setMode('willFocus');
this._willFocusSub = this.props.navigation.addListener('willFocus', () => {
this._handleEvent('willFocus');
});
this.props.navigation.addListener('willBlur', () => {
this.setMode('willBlur');
this._willBlurSub = this.props.navigation.addListener('willBlur', () => {
this._handleEvent('willBlur');
});
this.props.navigation.addListener('didFocus', () => {
this.setMode('didFocus');
this._didFocusSub = this.props.navigation.addListener('didFocus', () => {
this._handleEvent('didFocus');
});
this.props.navigation.addListener('didBlur', () => {
this.setMode('didBlur');
this._didBlurSub = this.props.navigation.addListener('didBlur', () => {
this._handleEvent('didBlur');
});
}
setMode = (mode: string) => {
componentWillUnmount() {
this._willFocusSub?.remove();
this._willBlurSub?.remove();
this._didFocusSub?.remove();
this._didBlurSub?.remove();
}
_willFocusSub: { remove: () => void } | undefined;
_willBlurSub: { remove: () => void } | undefined;
_didFocusSub: { remove: () => void } | undefined;
_didBlurSub: { remove: () => void } | undefined;
_handleEvent = (mode: string) => {
this.setState({ mode });
};
@@ -119,18 +132,19 @@ class SampleScreen extends React.Component<NavigationStackScreenProps> {
}
}
const SimpleStack = createStackNavigator(
const Stack = createStackNavigator(
{
PageOne: {
screen: SampleScreen,
},
PageTwo: {
screen: SampleScreen,
},
PageOne: SampleScreen,
PageTwo: SampleScreen,
},
{
initialRouteName: 'PageOne',
}
);
export default SimpleStack;
const Tabs = createBottomTabNavigator({
A: Stack,
B: Stack,
});
export default Tabs;

View File

@@ -18,7 +18,7 @@
"author": "Adam Miskiewicz <adam@sk3vy.com>, Eric Vicenti <ericvicenti@gmail.com>, Brent Vatne <brent@expo.io>, Satyajit Sahoo <satyajit.happy@gmail.com>",
"scripts": {
"lint": "eslint --ext '.js,.ts,.tsx' .",
"typescript": "tsc --noEmit",
"typescript": "tsc --noEmit --composite false",
"test": "jest",
"prerelease": "yarn lerna run clean",
"release": "yarn lerna publish",
@@ -42,7 +42,7 @@
"jest": "^25.1.0",
"lerna": "^3.20.2",
"prettier": "^2.0.1",
"typescript": "~3.7.5"
"typescript": "~3.8.3"
},
"resolutions": {
"react": "~16.9.0",

View File

@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.5.12](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.11...react-navigation-animated-switch@0.5.12) (2020-04-30)
**Note:** Version bump only for package react-navigation-animated-switch
## [0.5.11](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.10...react-navigation-animated-switch@0.5.11) (2020-04-22)
**Note:** Version bump only for package react-navigation-animated-switch
## [0.5.10](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.9...react-navigation-animated-switch@0.5.10) (2020-04-02)
**Note:** Version bump only for package react-navigation-animated-switch
## [0.5.9](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.8...react-navigation-animated-switch@0.5.9) (2020-03-31)
**Note:** Version bump only for package react-navigation-animated-switch
## [0.5.8](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.6...react-navigation-animated-switch@0.5.8) (2020-03-28)
**Note:** Version bump only for package react-navigation-animated-switch
## [0.5.7](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.6...react-navigation-animated-switch@0.5.7) (2020-03-27)
**Note:** Version bump only for package react-navigation-animated-switch

View File

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

View File

@@ -3,6 +3,53 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.7.6](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.5...@react-navigation/core@3.7.6) (2020-04-30)
### Bug Fixes
* change old docUrl to new docUrl due v5 ([e09906a](https://github.com/react-navigation/react-navigation-core/commit/e09906a4235a0fca09140923ebe7af34b50b491a))
## [3.7.5](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.4...@react-navigation/core@3.7.5) (2020-04-02)
### Bug Fixes
* emit refocus for child navigators ([66a4dbc](https://github.com/react-navigation/react-navigation-core/commit/66a4dbccd8e7b3cda51a1d9c7e9397dfc58d6b9e))
## [3.7.4](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.3...@react-navigation/core@3.7.4) (2020-03-31)
### Bug Fixes
* remove isTransitioning from SwitchRouter state ([3bec1c9](https://github.com/react-navigation/react-navigation-core/commit/3bec1c964a49136c0ead8e8ba8a8c66c556bbcba))
## [3.7.3](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.1...@react-navigation/core@3.7.3) (2020-03-28)
### Bug Fixes
* always emit didFocus/didBlur for root navigator ([ac98c0a](https://github.com/react-navigation/react-navigation-core/commit/ac98c0a668fe21200d0c6f62ae3043f92cc5aa7e))
* don't handle prune if there's only one route ([d2433f0](https://github.com/react-navigation/react-navigation-core/commit/d2433f0ab8f9791df8169de4ddfdeed9bc699e3e))
* emit didFocus and didBlur events based on parent's transition ([14a6538](https://github.com/react-navigation/react-navigation-core/commit/14a6538cc8e12c50d5d10722d75c9395a0a281ec))
* rework focus and blur events to make them more reliable ([cd08338](https://github.com/react-navigation/react-navigation-core/commit/cd083381866506a192f1ec842ac169f2b4277ca5)), closes [#4867](https://github.com/react-navigation/react-navigation-core/issues/4867) [#6187](https://github.com/react-navigation/react-navigation-core/issues/6187) [#6451](https://github.com/react-navigation/react-navigation-core/issues/6451) [#7628](https://github.com/react-navigation/react-navigation-core/issues/7628) [#7749](https://github.com/react-navigation/react-navigation-core/issues/7749)
## [3.7.2](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.1...@react-navigation/core@3.7.2) (2020-03-27)

View File

@@ -1,6 +1,6 @@
{
"name": "@react-navigation/core",
"version": "3.7.2",
"version": "3.7.6",
"description": "Core utilities for the react-navigation framework",
"main": "lib/commonjs/index.js",
"react-native": "lib/module/index.js",

View File

@@ -128,8 +128,8 @@ export default (routeConfigs, config = {}) => {
const initialState = {
routes,
index: initialRouteIndex,
isTransitioning: false,
};
if (backBehavior === 'history') {
const initialKey = routes[initialRouteIndex].key;
initialState['routeKeyHistory'] = [initialKey];

View File

@@ -26,7 +26,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
],
isTransitioning: false,
};
expect(state).toEqual(expectedState);
const state2 = router.getStateForAction(
@@ -39,7 +38,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
],
isTransitioning: false,
};
expect(state2).toEqual(expectedState2);
expect(router.getComponentForState(expectedState)).toEqual(ScreenA);
@@ -65,7 +63,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
],
isTransitioning: false,
};
expect(state).toEqual(expectedState);
const state2 = router.getStateForAction(
@@ -78,7 +75,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
],
isTransitioning: false,
};
expect(state2).toEqual(expectedState2);
expect(router.getComponentForState(expectedState)).toEqual(ScreenA);
@@ -102,7 +98,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
],
isTransitioning: false,
});
});
@@ -118,7 +113,6 @@ describe('TabRouter', () => {
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar', params: { name: 'Qux' } },
],
isTransitioning: false,
});
});
@@ -230,7 +224,7 @@ describe('TabRouter', () => {
const state = router.getStateForAction(navAction);
expect(state).toEqual({
index: 1,
isTransitioning: false,
routes: [
{
key: 'Foo',
@@ -238,7 +232,7 @@ describe('TabRouter', () => {
},
{
index: 1,
isTransitioning: false,
key: 'Baz',
routeName: 'Baz',
params: { foo: '42' },
@@ -281,14 +275,14 @@ describe('TabRouter', () => {
let state = router.getStateForAction(navAction);
expect(state).toEqual({
index: 1,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{
index: 0,
key: 'Baz',
routeName: 'Baz',
isTransitioning: false,
routes: [
{ key: 'Boo', routeName: 'Boo' },
{ key: 'Bar', routeName: 'Bar' },
@@ -308,7 +302,7 @@ describe('TabRouter', () => {
);
expect(state && state.routes[1]).toEqual({
index: 0,
isTransitioning: false,
key: 'Baz',
routeName: 'Baz',
routes: [
@@ -335,14 +329,14 @@ describe('TabRouter', () => {
});
expect(state).toEqual({
index: 1,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{
index: 1,
key: 'Baz',
routeName: 'Baz',
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
@@ -357,14 +351,14 @@ describe('TabRouter', () => {
);
expect(state2).toEqual({
index: 1,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{
index: 0,
key: 'Baz',
routeName: 'Baz',
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
@@ -403,19 +397,19 @@ describe('TabRouter', () => {
const state = router.getStateForAction(INIT_ACTION);
expect(state).toEqual({
index: 0,
isTransitioning: false,
routes: [
{
index: 0,
key: 'Foo',
routeName: 'Foo',
isTransitioning: false,
routes: [
{
index: 0,
key: 'Fee',
routeName: 'Fee',
isTransitioning: false,
routes: [
{ key: 'Boo', routeName: 'Boo' },
{ key: 'Baz', routeName: 'Baz' },
@@ -425,7 +419,7 @@ describe('TabRouter', () => {
index: 0,
key: 'Bar',
routeName: 'Bar',
isTransitioning: false,
routes: [
{ key: 'Zoo', routeName: 'Zoo' },
{ key: 'Zap', routeName: 'Zap' },
@@ -442,19 +436,19 @@ describe('TabRouter', () => {
);
expect(state2).toEqual({
index: 0,
isTransitioning: false,
routes: [
{
index: 1,
key: 'Foo',
routeName: 'Foo',
isTransitioning: false,
routes: [
{
index: 0,
key: 'Fee',
routeName: 'Fee',
isTransitioning: false,
routes: [
{ key: 'Boo', routeName: 'Boo' },
{ key: 'Baz', routeName: 'Baz' },
@@ -464,7 +458,7 @@ describe('TabRouter', () => {
index: 1,
key: 'Bar',
routeName: 'Bar',
isTransitioning: false,
routes: [
{ key: 'Zoo', routeName: 'Zoo' },
{ key: 'Zap', routeName: 'Zap' },
@@ -494,19 +488,19 @@ describe('TabRouter', () => {
});
expect(state4).toEqual({
index: 0,
isTransitioning: false,
routes: [
{
index: 1,
key: 'Foo',
routeName: 'Foo',
isTransitioning: false,
routes: [
{
index: 0,
key: 'Fee',
routeName: 'Fee',
isTransitioning: false,
routes: [
{ key: 'Boo', routeName: 'Boo' },
{ key: 'Baz', routeName: 'Baz' },
@@ -516,7 +510,7 @@ describe('TabRouter', () => {
index: 1,
key: 'Bar',
routeName: 'Bar',
isTransitioning: false,
routes: [
{ key: 'Zoo', routeName: 'Zoo' },
{ key: 'Zap', routeName: 'Zap' },
@@ -557,7 +551,7 @@ describe('TabRouter', () => {
const state = router.getStateForAction({ type: NavigationActions.INIT });
const expectedState = {
index: 0,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo' },
{ key: 'Bar', routeName: 'Bar' },
@@ -567,7 +561,7 @@ describe('TabRouter', () => {
const state2 = router.getStateForAction(expectedAction, state);
const expectedState2 = {
index: 1,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo', params: undefined },
{
@@ -628,13 +622,13 @@ describe('TabRouter', () => {
const state = {
index: 0,
isTransitioning: false,
routes: [
{
index: 1,
key: 'Foo',
routeName: 'Foo',
isTransitioning: false,
routes: [
{ key: 'Boo', routeName: 'Boo' },
{ key: 'Baz', routeName: 'Baz' },
@@ -660,7 +654,7 @@ describe('TabRouter', () => {
expect(state0).toEqual({
index: 0,
isTransitioning: false,
routes: [
{ key: 'a', routeName: 'a' },
{ key: 'b', routeName: 'b' },
@@ -676,7 +670,7 @@ describe('TabRouter', () => {
expect(state1).toEqual({
index: 1,
isTransitioning: false,
routes: [
{ key: 'a', routeName: 'a' },
{ key: 'b', routeName: 'b', params },
@@ -765,13 +759,13 @@ describe('TabRouter', () => {
const screenApreState = {
index: 0,
key: 'Foo',
isTransitioning: false,
routeName: 'Foo',
routes: [{ key: 'Bar', routeName: 'Bar' }],
};
const preState = {
index: 0,
isTransitioning: false,
routes: [screenApreState],
};

View File

@@ -1,3 +1,3 @@
export default function docsUrl(path: string) {
return `https://reactnavigation.org/docs/${path}`;
return `https://reactnavigation.org/docs/4.x/${path}`;
}

View File

@@ -51,12 +51,30 @@ export default class NavigationEventManager extends React.Component {
'willBlur',
this._handleWillBlur
);
this._didFocusSubscription = navigation.addListener(
'didFocus',
this._handleDidFocus
);
this._didBlurSubscription = navigation.addListener(
'didBlur',
this._handleDidBlur
);
this._refocusSubscription = navigation.addListener(
'refocus',
this._handleRefocus
);
}
componentWillUnmount() {
this._actionSubscription?.remove();
this._willFocusSubscription?.remove();
this._willBlurSubscription?.remove();
this._didFocusSubscription?.remove();
this._didBlurSubscription?.remove();
this._refocusSubscription?.remove();
}
/**
@@ -74,6 +92,21 @@ export default class NavigationEventManager extends React.Component {
*/
_willBlurSubscription;
/**
* @type {{ remove(): void } | undefined}
*/
_didFocusSubscription;
/**
* @type {{ remove(): void } | undefined}
*/
_didBlurSubscription;
/**
* @type {{ remove(): void } | undefined}
*/
_refocusSubscription;
/**
* @type {string | undefined}
*/
@@ -84,6 +117,16 @@ export default class NavigationEventManager extends React.Component {
*/
_lastWillFocusKey;
/**
* @type {string | undefined}
*/
_lastDidBlurKey;
/**
* @type {string | undefined}
*/
_lastDidFocusKey;
/**
* The 'action' event will fire when navigation state changes.
* Detect if the focused route changed here and emit appropriate events.
@@ -113,10 +156,10 @@ export default class NavigationEventManager extends React.Component {
};
if (previous?.key !== current.key) {
this._emitFocus(current.key, payload);
this._emitWillFocus(current.key, payload);
if (previous?.key) {
this._emitBlur(previous.key, payload);
this._emitWillBlur(previous.key, payload);
}
}
@@ -125,11 +168,11 @@ export default class NavigationEventManager extends React.Component {
state.isTransitioning === false
) {
if (this._lastWillBlurKey) {
onEvent(this._lastWillBlurKey, 'didBlur', payload);
this._emitDidBlur(this._lastWillBlurKey, payload);
}
if (this._lastWillFocusKey) {
onEvent(this._lastWillFocusKey, 'didFocus', payload);
this._emitDidFocus(this._lastWillFocusKey, payload);
}
}
@@ -143,7 +186,7 @@ export default class NavigationEventManager extends React.Component {
const { navigation } = this.props;
const route = navigation.state.routes[navigation.state.index];
this._emitFocus(route.key, {
this._emitWillFocus(route.key, {
context: `${route.key}:${action.type}_${context || 'Root'}`,
state: route,
lastState: lastState?.routes?.find((r) => r.key === route.key),
@@ -159,7 +202,7 @@ export default class NavigationEventManager extends React.Component {
const { navigation } = this.props;
const route = navigation.state.routes[navigation.state.index];
this._emitBlur(route.key, {
this._emitWillBlur(route.key, {
context: `${route.key}:${action.type}_${context || 'Root'}`,
state: route,
lastState: lastState?.routes?.find((r) => r.key === route.key),
@@ -168,11 +211,64 @@ export default class NavigationEventManager extends React.Component {
});
};
/**
* @param {ParentPayload} payload
*/
_handleDidFocus = ({ lastState, action, context, type }) => {
const { navigation } = this.props;
if (this._lastWillFocusKey) {
const route = navigation.state.routes.find(
(r) => r.key === this._lastWillFocusKey
);
if (route) {
this._emitDidFocus(route.key, {
context: `${route.key}:${action.type}_${context || 'Root'}`,
state: route,
lastState: lastState?.routes?.find((r) => r.key === route.key),
action,
type,
});
}
}
};
/**
* @param {ParentPayload} payload
*/
_handleDidBlur = ({ lastState, action, context, type }) => {
const { navigation } = this.props;
if (this._lastWillBlurKey) {
const route = navigation.state.routes.find(
(r) => r.key === this._lastWillBlurKey
);
if (route) {
this._emitDidBlur(route.key, {
context: `${route.key}:${action.type}_${context || 'Root'}`,
state: route,
lastState: lastState?.routes?.find((r) => r.key === route.key),
action,
type,
});
}
}
};
_handleRefocus = () => {
const { onEvent, navigation } = this.props;
const route = navigation.state.routes[navigation.state.index];
onEvent(route.key, 'refocus');
};
/**
* @param {string} target
* @param {Payload} payload
*/
_emitFocus = (target, payload) => {
_emitWillFocus = (target, payload) => {
if (this._lastWillBlurKey === target) {
this._lastWillBlurKey = undefined;
}
@@ -181,14 +277,19 @@ export default class NavigationEventManager extends React.Component {
return;
}
this._lastDidFocusKey = undefined;
this._lastWillFocusKey = target;
const { navigation, onEvent } = this.props;
onEvent(target, 'willFocus', payload);
if (typeof navigation.state.isTransitioning !== 'boolean') {
onEvent(target, 'didFocus', payload);
if (
typeof navigation.state.isTransitioning !== 'boolean' ||
(navigation.state.isTransitioning !== true &&
!navigation.dangerouslyGetParent())
) {
this._emitDidFocus(target, payload);
}
};
@@ -196,7 +297,7 @@ export default class NavigationEventManager extends React.Component {
* @param {string} target
* @param {Payload} payload
*/
_emitBlur = (target, payload) => {
_emitWillBlur = (target, payload) => {
if (this._lastWillFocusKey === target) {
this._lastWillFocusKey = undefined;
}
@@ -205,17 +306,54 @@ export default class NavigationEventManager extends React.Component {
return;
}
this._lastDidBlurKey = undefined;
this._lastWillBlurKey = target;
const { navigation, onEvent } = this.props;
onEvent(target, 'willBlur', payload);
if (typeof navigation.state.isTransitioning !== 'boolean') {
onEvent(target, 'didBlur', payload);
if (
typeof navigation.state.isTransitioning !== 'boolean' ||
(navigation.state.isTransitioning !== true &&
!navigation.dangerouslyGetParent())
) {
this._emitDidBlur(target, payload);
}
};
/**
* @param {string} target
* @param {Payload} payload
*/
_emitDidFocus = (target, payload) => {
if (this._lastWillFocusKey !== target || this._lastDidFocusKey === target) {
return;
}
this._lastDidFocusKey = target;
const { onEvent } = this.props;
onEvent(target, 'didFocus', payload);
};
/**
* @param {string} target
* @param {Payload} payload
*/
_emitDidBlur = (target, payload) => {
if (this._lastWillBlurKey !== target || this._lastDidBlurKey === target) {
return;
}
this._lastDidBlurKey = target;
const { onEvent } = this.props;
onEvent(target, 'didBlur', payload);
};
render() {
return null;
}

View File

@@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.4.13](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.12...react-navigation-drawer@2.4.13) (2020-04-30)
**Note:** Version bump only for package react-navigation-drawer
## [2.4.12](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.11...react-navigation-drawer@2.4.12) (2020-04-22)
**Note:** Version bump only for package react-navigation-drawer
## [2.4.11](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.10...react-navigation-drawer@2.4.11) (2020-04-02)
**Note:** Version bump only for package react-navigation-drawer
## [2.4.10](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.9...react-navigation-drawer@2.4.10) (2020-03-31)
### Bug Fixes
* remove isTransitioning from SwitchRouter state ([3bec1c9](https://github.com/react-navigation/drawer/commit/3bec1c964a49136c0ead8e8ba8a8c66c556bbcba))
## [2.4.9](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.7...react-navigation-drawer@2.4.9) (2020-03-28)
**Note:** Version bump only for package react-navigation-drawer
## [2.4.8](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.7...react-navigation-drawer@2.4.8) (2020-03-27)
**Note:** Version bump only for package react-navigation-drawer

View File

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

View File

@@ -18,7 +18,7 @@ it('handles basic drawer logic and fires close on switch', () => {
const state = router.getStateForAction(INIT_ACTION);
const expectedState = {
index: 0,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo', params: undefined },
{ key: 'Bar', routeName: 'Bar', params: undefined },
@@ -32,7 +32,7 @@ it('handles basic drawer logic and fires close on switch', () => {
);
const expectedState2 = {
index: 1,
isTransitioning: false,
routes: [
{ key: 'Foo', routeName: 'Foo', params: undefined },
{ key: 'Bar', routeName: 'Bar', params: undefined },
@@ -65,7 +65,7 @@ it('handles initial route navigation', () => {
expect(state).toEqual({
index: 0,
isDrawerOpen: false,
isTransitioning: false,
routes: [
{
key: 'Foo',

View File

@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.2.12](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.11...react-navigation-material-bottom-tabs@2.2.12) (2020-04-30)
**Note:** Version bump only for package react-navigation-material-bottom-tabs
## [2.2.11](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.10...react-navigation-material-bottom-tabs@2.2.11) (2020-04-22)
**Note:** Version bump only for package react-navigation-material-bottom-tabs
## [2.2.10](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.9...react-navigation-material-bottom-tabs@2.2.10) (2020-04-02)
**Note:** Version bump only for package react-navigation-material-bottom-tabs
## [2.2.9](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.8...react-navigation-material-bottom-tabs@2.2.9) (2020-03-31)
**Note:** Version bump only for package react-navigation-material-bottom-tabs
## [2.2.8](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.6...react-navigation-material-bottom-tabs@2.2.8) (2020-03-28)
**Note:** Version bump only for package react-navigation-material-bottom-tabs
## [2.2.7](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.6...react-navigation-material-bottom-tabs@2.2.7) (2020-03-27)
**Note:** Version bump only for package react-navigation-material-bottom-tabs

View File

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

View File

@@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.7.13](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.12...@react-navigation/native@3.7.13) (2020-04-30)
**Note:** Version bump only for package @react-navigation/native
## [3.7.12](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.11...@react-navigation/native@3.7.12) (2020-04-22)
**Note:** Version bump only for package @react-navigation/native
## [3.7.11](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.10...@react-navigation/native@3.7.11) (2020-04-02)
**Note:** Version bump only for package @react-navigation/native
## [3.7.10](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.9...@react-navigation/native@3.7.10) (2020-03-31)
**Note:** Version bump only for package @react-navigation/native
## [3.7.9](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.7...@react-navigation/native@3.7.9) (2020-03-28)
### Bug Fixes
* rework focus and blur events to make them more reliable ([cd08338](https://github.com/react-navigation/react-navigation-native/commit/cd083381866506a192f1ec842ac169f2b4277ca5)), closes [#4867](https://github.com/react-navigation/react-navigation-native/issues/4867) [#6187](https://github.com/react-navigation/react-navigation-native/issues/6187) [#6451](https://github.com/react-navigation/react-navigation-native/issues/6451) [#7628](https://github.com/react-navigation/react-navigation-native/issues/7628) [#7749](https://github.com/react-navigation/react-navigation-native/issues/7749)
## [3.7.8](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.7...@react-navigation/native@3.7.8) (2020-03-27)

View File

@@ -1,6 +1,6 @@
{
"name": "@react-navigation/native",
"version": "3.7.8",
"version": "3.7.13",
"description": "React Native support for React Navigation",
"main": "lib/commonjs/index.js",
"react-native": "lib/module/index.js",
@@ -36,11 +36,11 @@
"homepage": "https://github.com/react-navigation/react-navigation-native#readme",
"dependencies": {
"hoist-non-react-statics": "^3.3.2",
"react-native-safe-area-view": "^0.14.8"
"react-native-safe-area-view": "^0.14.9"
},
"devDependencies": {
"@react-native-community/bob": "^0.10.0",
"@react-navigation/core": "^3.7.2",
"@react-navigation/core": "^3.7.6",
"@types/react-test-renderer": "^16.9.2",
"del-cli": "^3.0.0",
"react": "~16.9.0",

View File

@@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [4.3.9](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.8...react-navigation@4.3.9) (2020-04-30)
### Bug Fixes
* change old docUrl to new docUrl due v5 ([e09906a](https://github.com/react-navigation/react-navigation/commit/e09906a4235a0fca09140923ebe7af34b50b491a))
## [4.3.8](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.7...react-navigation@4.3.8) (2020-04-22)
**Note:** Version bump only for package react-navigation
## [4.3.7](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.6...react-navigation@4.3.7) (2020-04-02)
**Note:** Version bump only for package react-navigation
## [4.3.6](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.5...react-navigation@4.3.6) (2020-03-31)
**Note:** Version bump only for package react-navigation
## [4.3.5](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.3...react-navigation@4.3.5) (2020-03-28)
**Note:** Version bump only for package react-navigation
## [4.3.4](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.3...react-navigation@4.3.4) (2020-03-27)
**Note:** Version bump only for package react-navigation

View File

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

View File

@@ -1,3 +1,3 @@
export default function docsUrl(path) {
return `https://reactnavigation.org/docs/${path}`;
return `https://reactnavigation.org/docs/4.x/${path}`;
}

View File

@@ -3,6 +3,64 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.4.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.13...react-navigation-stack@2.4.0) (2020-04-30)
### Features
* sync latest stack ([8b79e9b](https://github.com/react-navigation/react-navigation-stack/commit/8b79e9bee65c3ba6a788ca76771379319168f117))
## [2.3.13](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.12...react-navigation-stack@2.3.13) (2020-04-22)
**Note:** Version bump only for package react-navigation-stack
## [2.3.12](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.11...react-navigation-stack@2.3.12) (2020-04-17)
### Bug Fixes
* stack peer warnings ([4c4e66f](https://github.com/react-navigation/react-navigation-stack/commit/4c4e66f05cd4d694f512f4cc38827f3fbf0f70de))
## [2.3.11](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.10...react-navigation-stack@2.3.11) (2020-04-02)
**Note:** Version bump only for package react-navigation-stack
## [2.3.10](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.9...react-navigation-stack@2.3.10) (2020-03-31)
**Note:** Version bump only for package react-navigation-stack
## [2.3.9](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.7...react-navigation-stack@2.3.9) (2020-03-28)
### Bug Fixes
* emit didFocus and didBlur events based on parent's transition ([14a6538](https://github.com/react-navigation/react-navigation-stack/commit/14a6538cc8e12c50d5d10722d75c9395a0a281ec))
* rework focus and blur events to make them more reliable ([cd08338](https://github.com/react-navigation/react-navigation-stack/commit/cd083381866506a192f1ec842ac169f2b4277ca5)), closes [#4867](https://github.com/react-navigation/react-navigation-stack/issues/4867) [#6187](https://github.com/react-navigation/react-navigation-stack/issues/6187) [#6451](https://github.com/react-navigation/react-navigation-stack/issues/6451) [#7628](https://github.com/react-navigation/react-navigation-stack/issues/7628) [#7749](https://github.com/react-navigation/react-navigation-stack/issues/7749)
## [2.3.8](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.7...react-navigation-stack@2.3.8) (2020-03-27)

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-stack",
"version": "2.3.8",
"version": "2.4.0",
"description": "Stack navigator component for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
@@ -45,7 +45,7 @@
"devDependencies": {
"@react-native-community/bob": "^0.10.0",
"@react-native-community/masked-view": "^0.1.7",
"@react-navigation/stack": "^5.2.8",
"@react-navigation/stack": "^5.2.16",
"@types/color": "^3.0.1",
"@types/react": "^16.9.23",
"@types/react-native": "^0.61.22",
@@ -56,16 +56,16 @@
"react-native-gesture-handler": "^1.6.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.3.0",
"react-navigation": "^4.3.4",
"react-navigation": "^4.3.9",
"react-test-renderer": "~16.9.0",
"typescript": "~3.7.5"
"typescript": "~3.8.3"
},
"peerDependencies": {
"@react-native-community/masked-view": "^0.1.1",
"@react-native-community/masked-view": ">=0.1.0",
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^1.5.0",
"react-native-safe-area-context": "^0.6.0",
"react-native-gesture-handler": ">= 1.5.0",
"react-native-safe-area-context": ">= 0.6.0",
"react-native-screens": ">=1.0.0 || >= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0",
"react-navigation": "^4.1.1"
},

View File

@@ -1,6 +1,6 @@
diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/index.tsx
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/index.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/index.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -3,11 +3,6 @@
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
@@ -13,25 +13,25 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
export const Assets = [
// eslint-disable-next-line import/no-commonjs
require('./views/assets/back-icon.png'),
@@ -49,9 +44,10 @@
@@ -49,8 +44,10 @@
* Types
*/
export {
export type {
- StackNavigationOptions,
- StackNavigationProp,
- StackHeaderProps,
+ NavigationStackState,
+ StackNavigationProp as NavigationStackProp,
+ StackNavigationOptions as NavigationStackOptions,
+ StackNavigationConfig as NavigationStackConfig,
StackHeaderProps,
StackHeaderLeftButtonProps,
StackHeaderTitleProps,
StackCardInterpolatedStyle,
diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx src/vendor/navigators/createStackNavigator.tsx
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-03-23 11:43:17.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
@@ -1,81 +0,0 @@
@@ -1,96 +0,0 @@
-import * as React from 'react';
-import { Platform } from 'react-native';
-import {
- useNavigationBuilder,
- createNavigatorFactory,
@@ -59,6 +59,11 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
- screenOptions,
- ...rest
-}: Props) {
- const defaultOptions = {
- gestureEnabled: Platform.OS === 'ios',
- animationEnabled: Platform.OS !== 'web',
- };
-
- const { state, descriptors, navigation } = useNavigationBuilder<
- StackNavigationState,
- StackRouterOptions,
@@ -67,7 +72,16 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
- >(StackRouter, {
- initialRouteName,
- children,
- screenOptions,
- screenOptions:
- typeof screenOptions === 'function'
- ? (...args) => ({
- ...defaultOptions,
- ...screenOptions(...args),
- })
- : {
- ...defaultOptions,
- ...screenOptions,
- },
- });
-
- React.useEffect(
@@ -113,8 +127,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
- typeof StackNavigator
->(StackNavigator);
diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/types.tsx
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/types.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/types.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -8,14 +8,28 @@
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
@@ -230,7 +244,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
export type StackNavigationOptions = StackHeaderOptions &
Partial<TransitionPreset> & {
/**
@@ -317,6 +341,8 @@
@@ -320,6 +344,8 @@
bottom?: number;
left?: number;
};
@@ -240,8 +254,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
export type StackNavigationConfig = {
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx src/vendor/views/Header/Header.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/Header.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/Header.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -1,12 +1,14 @@
import * as React from 'react';
-import { StackActions } from '@react-navigation/native';
@@ -321,22 +335,22 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
+
+export default Header;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-05-01 01:33:40.000000000 +0200
@@ -8,9 +8,9 @@
StyleSheet,
LayoutChangeEvent,
} from 'react-native';
-import { useTheme } from '@react-navigation/native';
import MaskedView from '../MaskedView';
import TouchableItem from '../TouchableItem';
import { TouchableItem } from '../TouchableItem';
+import useTheme from '../../../utils/useTheme';
import { StackHeaderLeftButtonProps } from '../../types';
type Props = StackHeaderLeftButtonProps;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx src/vendor/views/Header/HeaderBackground.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Animated, StyleSheet, Platform, ViewProps } from 'react-native';
@@ -346,8 +360,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
type Props = ViewProps & {
children?: React.ReactNode;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx src/vendor/views/Header/HeaderContainer.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -1,11 +1,6 @@
import * as React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
@@ -399,8 +413,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
);
})}
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx src/vendor/views/Header/HeaderSegment.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -8,7 +8,7 @@
ViewStyle,
} from 'react-native';
@@ -420,8 +434,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSeg
};
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx src/vendor/views/Header/HeaderTitle.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-03-23 11:43:59.000000000 +0100
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Animated, StyleSheet, Platform } from 'react-native';
@@ -431,9 +445,9 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTit
type Props = React.ComponentProps<typeof Animated.Text> & {
tintColor?: string;
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx src/vendor/views/Stack/Card.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Stack/Card.tsx 2020-03-23 11:43:59.000000000 +0100
@@ -138,7 +138,7 @@
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Stack/Card.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -140,7 +140,7 @@
private interactionHandle: number | undefined;
@@ -443,28 +457,26 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx s
private animate = ({
closing,
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx src/vendor/views/Stack/CardContainer.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Stack/CardContainer.tsx 2020-03-27 14:41:20.000000000 +0100
@@ -1,10 +1,16 @@
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Stack/CardContainer.tsx 2020-05-01 01:34:25.000000000 +0200
@@ -1,14 +1,14 @@
import * as React from 'react';
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
-import { Route, useTheme } from '@react-navigation/native';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import Card from './Card';
import HeaderHeightContext from '../../utils/HeaderHeightContext';
-import { Scene, Layout, StackHeaderMode, TransitionPreset } from '../../types';
+import useTheme from '../../../utils/useTheme';
+import {
import {
+ Route,
+ Scene,
+ Layout,
+ StackHeaderMode,
+ TransitionPreset,
+} from '../../types';
Scene,
Layout,
StackHeaderMode,
- StackCardMode,
TransitionPreset,
} from '../../types';
type Props = TransitionPreset & {
index: number;
@@ -183,7 +189,7 @@
@@ -192,7 +192,7 @@
? { marginTop: headerHeight }
: null
}
@@ -474,20 +486,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
>
<View style={styles.container}>
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx src/vendor/views/Stack/CardStack.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Stack/CardStack.tsx 2020-03-27 14:41:20.000000000 +0100
@@ -9,9 +9,8 @@
ViewProps,
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Stack/CardStack.tsx 2020-05-01 01:32:40.000000000 +0200
@@ -7,7 +7,7 @@
Platform,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
-// eslint-disable-next-line import/no-unresolved
import { ScreenContainer, Screen, screensEnabled } from 'react-native-screens'; // Import with * as to prevent getters being called
-import { Route, StackNavigationState } from '@react-navigation/native';
+import { NavigationState as StackNavigationState } from 'react-navigation';
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
@@ -24,6 +23,7 @@
@@ -21,6 +21,7 @@
import { forNoAnimation as forNoAnimationCard } from '../../TransitionConfigs/CardStyleInterpolators';
import getDistanceForDirection from '../../utils/getDistanceForDirection';
import {
@@ -496,22 +506,23 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.
StackHeaderMode,
StackCardMode,
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx src/vendor/views/Stack/StackView.tsx
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-03-23 11:43:17.000000000 +0100
+++ src/vendor/views/Stack/StackView.tsx 2020-03-27 14:41:20.000000000 +0100
@@ -4,9 +4,9 @@
import { GestureHandlerRootView } from 'react-native-gesture-handler';
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-05-01 01:29:42.000000000 +0200
+++ src/vendor/views/Stack/StackView.tsx 2020-05-01 01:37:12.000000000 +0200
@@ -4,9 +4,10 @@
import {
NavigationHelpersContext,
StackActions,
- StackNavigationState,
- Route,
-} from '@react-navigation/native';
+ NavigationState as StackNavigationState,
+ NavigationActions,
+ SceneView,
+} from 'react-navigation';
import { GestureHandlerRootView } from '../GestureHandler';
import CardStack from './CardStack';
import KeyboardManager from '../KeyboardManager';
@@ -15,6 +15,7 @@
@@ -16,6 +17,7 @@
} from '../Header/HeaderContainer';
import SafeAreaProviderCompat from '../SafeAreaProviderCompat';
import {
@@ -519,7 +530,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
StackNavigationHelpers,
StackNavigationConfig,
StackDescriptorMap,
@@ -24,6 +25,7 @@
@@ -25,6 +27,7 @@
state: StackNavigationState;
navigation: StackNavigationHelpers;
descriptors: StackDescriptorMap;
@@ -527,7 +538,18 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
};
type State = {
@@ -290,14 +292,37 @@
@@ -293,7 +296,9 @@
return false;
}
- return gestureEnabled !== false;
+ return gestureEnabled !== undefined
+ ? gestureEnabled
+ : Platform.OS !== 'android';
}
return false;
@@ -321,24 +326,47 @@
return null;
}
@@ -548,25 +570,37 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
return <HeaderContainer {...props} />;
};
+ private handleTransitionComplete = ({ route }: { route: Route<string> }) => {
+ private handleTransitionComplete = () => {
+ const { state, navigation } = this.props;
+
+ if (state.isTransitioning) {
+ navigation.dispatch(
+ StackActions.completeTransition({
+ key: navigation.state.key,
+ toChildKey: route.key,
+ toChildKey: state.routes[state.index].key,
+ })
+ );
+ }
+ };
+
private handleOpenRoute = ({ route }: { route: Route<string> }) => {
+ this.handleTransitionComplete({ route });
this.setState((state) => ({
routes: state.replacingRouteKeys.length
? state.routes.filter((r) => !state.replacingRouteKeys.includes(r.key))
@@ -319,12 +344,17 @@
const { state, navigation } = this.props;
+ this.handleTransitionComplete();
+
if (
this.state.replacingRouteKeys.every((key) => key !== route.key) &&
- state.routeNames.includes(route.name) &&
!state.routes.some((r) => r.key === route.key)
) {
// If route isn't present in current state, assume that a close animation was cancelled
// So we need to add this route back to the state
- navigation.navigate(route);
+ navigation.dispatch(NavigationActions.navigate(route));
} else {
this.setState((state) => ({
routes: state.replacingRouteKeys.length
@@ -364,12 +392,11 @@
// If a route exists in state, trigger a pop
// This will happen in when the route was closed from the card component
// e.g. When the close animation triggered from a gesture ends
@@ -578,18 +612,12 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
+ // @ts-ignore
+ navigation.dispatch(StackActions.pop({ key: route.key, prune: false }));
} else {
+ // While closing route we need to point to the previous one assuming that
+ // this previous one in routes array
+ const index = this.state.routes.findIndex((r) => r.key === route.key);
+
+ this.handleTransitionComplete({
+ route: this.state.routes[Math.max(index - 1, 0)],
+ });
+ this.handleTransitionComplete();
+
// We need to clean up any state tracking the route and pop it immediately
this.setState((state) => ({
routes: state.routes.filter((r) => r.key !== route.key),
@@ -341,22 +371,24 @@
@@ -386,22 +413,24 @@
private handleTransitionStart = (
{ route }: { route: Route<string> },
closing: boolean

View File

@@ -8,7 +8,7 @@ export { default as createStackNavigator } from './navigators/createStackNavigat
/**
* Types
*/
export {
export type {
NavigationStackScreenComponent,
NavigationStackScreenProps,
} from './types';

View File

@@ -115,7 +115,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
pointerEvents="none"
style={
Object {
"backgroundColor": "#fff",
"backgroundColor": "rgb(242, 242, 242)",
"bottom": 0,
"left": 0,
"position": "absolute",
@@ -276,7 +276,7 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
pointerEvents="none"
style={
Object {
"backgroundColor": "#fff",
"backgroundColor": "rgb(242, 242, 242)",
"bottom": 0,
"left": 0,
"position": "absolute",

View File

@@ -115,7 +115,7 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
pointerEvents="none"
style={
Object {
"backgroundColor": "#fff",
"backgroundColor": "rgb(242, 242, 242)",
"bottom": 0,
"left": 0,
"position": "absolute",
@@ -412,7 +412,7 @@ exports[`StackNavigator renders successfully 1`] = `
pointerEvents="none"
style={
Object {
"backgroundColor": "#fff",
"backgroundColor": "rgb(242, 242, 242)",
"bottom": 0,
"left": 0,
"position": "absolute",

View File

@@ -164,6 +164,7 @@ export function forModalPresentationIOS({
borderTopLeftRadius: borderRadius,
borderTopRightRadius: borderRadius,
marginTop: index === 0 ? 0 : statusBarHeight,
marginBottom: index === 0 ? 0 : topOffset,
transform: [{ translateY }, { scale }],
},
overlayStyle: { opacity: overlayOpacity },

View File

@@ -43,11 +43,12 @@ export { default as useGestureHandlerRef } from './utils/useGestureHandlerRef';
/**
* Types
*/
export {
export type {
NavigationStackState,
StackNavigationProp as NavigationStackProp,
StackNavigationOptions as NavigationStackOptions,
StackNavigationConfig as NavigationStackConfig,
StackHeaderProps,
StackHeaderLeftButtonProps,
StackHeaderTitleProps,
StackCardInterpolatedStyle,

View File

@@ -300,7 +300,8 @@ export type StackNavigationOptions = StackHeaderOptions &
cardStyle?: StyleProp<ViewStyle>;
/**
* Whether transition animation should be enabled the screen.
* If you set it to `false`, the screen won't animate when pushing or popping. Defaults to `true`.
* If you set it to `false`, the screen won't animate when pushing or popping.
* Defaults to `true` on Android and iOS, `false` on Web.
*/
animationEnabled?: boolean;
/**
@@ -310,10 +311,12 @@ export type StackNavigationOptions = StackHeaderOptions &
animationTypeForReplace?: 'push' | 'pop';
/**
* Whether you can use gestures to dismiss this screen. Defaults to `true` on iOS, `false` on Android.
* Not supported on Web.
*/
gestureEnabled?: boolean;
/**
* Object to override the distance of touch start from the edge of the screen to recognize gestures.
* Not supported on Web.
*/
gestureResponseDistance?: {
/**
@@ -326,8 +329,8 @@ export type StackNavigationOptions = StackHeaderOptions &
horizontal?: number;
};
/**
* Number which determines the relevance of velocity for the gesture.
* Defaults to 0.3.
* Number which determines the relevance of velocity for the gesture. Defaults to 0.3.
* Not supported on Web.
*/
gestureVelocityImpact?: number;
/**

View File

@@ -1,6 +1,5 @@
import * as React from 'react';
import { PanGestureHandler } from 'react-native-gesture-handler';
export default React.createContext<React.Ref<PanGestureHandler> | undefined>(
undefined
);
export default React.createContext<React.Ref<
import('react-native-gesture-handler').PanGestureHandler
> | null>(null);

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import {
PanGestureHandler as PanGestureHandlerNative,
PanGestureHandlerProperties,
} from 'react-native-gesture-handler';
import GestureHandlerRefContext from '../utils/GestureHandlerRefContext';
export function PanGestureHandler(props: PanGestureHandlerProperties) {
const gestureRef = React.useRef<PanGestureHandlerNative>(null);
return (
<GestureHandlerRefContext.Provider value={gestureRef}>
<PanGestureHandlerNative {...props} />
</GestureHandlerRefContext.Provider>
);
}
export {
GestureHandlerRootView,
State as GestureState,
PanGestureHandlerGestureEvent,
} from 'react-native-gesture-handler';

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import { View } from 'react-native';
import type { PanGestureHandlerProperties } from 'react-native-gesture-handler';
const Dummy: any = ({ children }: { children: React.ReactNode }) => (
<>{children}</>
);
export const PanGestureHandler = Dummy as React.ComponentType<
PanGestureHandlerProperties
>;
export const GestureHandlerRootView = View;
export const GestureState = {
UNDETERMINED: 0,
FAILED: 1,
BEGAN: 2,
CANCELLED: 3,
ACTIVE: 4,
END: 5,
};
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';

View File

@@ -9,7 +9,7 @@ import {
LayoutChangeEvent,
} from 'react-native';
import MaskedView from '../MaskedView';
import TouchableItem from '../TouchableItem';
import { TouchableItem } from '../TouchableItem';
import useTheme from '../../../utils/useTheme';
import { StackHeaderLeftButtonProps } from '../../types';

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { TextInput } from 'react-native';
import { TextInput, Platform, Keyboard } from 'react-native';
type Props = {
enabled: boolean;
@@ -56,7 +56,9 @@ export default class KeyboardManager extends React.Component<Props> {
const input = this.previouslyFocusedTextInput;
if (input) {
if (Platform.OS === 'android') {
Keyboard.dismiss();
} else if (input) {
TextInput.State.blurTextInput(input);
}

View File

@@ -1,17 +1,26 @@
import * as React from 'react';
import { UIManager } from 'react-native';
import RNCMaskedView from '@react-native-community/masked-view';
type Props = React.ComponentProps<typeof RNCMaskedView> & {
type MaskedViewType = typeof import('@react-native-community/masked-view').default;
type Props = React.ComponentProps<MaskedViewType> & {
children: React.ReactElement;
};
let RNCMaskedView: MaskedViewType | undefined;
try {
RNCMaskedView = require('@react-native-community/masked-view').default;
} catch (e) {
// Ignore
}
const isMaskedViewAvailable =
// @ts-ignore
UIManager.getViewManagerConfig('RNCMaskedView') != null;
export default function MaskedView({ children, ...rest }: Props) {
if (isMaskedViewAvailable) {
if (isMaskedViewAvailable && RNCMaskedView) {
return <RNCMaskedView {...rest}>{children}</RNCMaskedView>;
}

View File

@@ -0,0 +1,71 @@
import * as React from 'react';
import { Animated, View, Platform, ViewProps } from 'react-native';
let Screens: typeof import('react-native-screens') | undefined;
try {
Screens = require('react-native-screens');
} catch (e) {
// Ignore
}
// The web implementation in react-native-screens seems buggy.
// The view doesn't become visible after coming back in some cases.
// So we use our custom implementation.
class WebScreen extends React.Component<
ViewProps & {
active: number;
children: React.ReactNode;
}
> {
render() {
const { active, style, ...rest } = this.props;
return (
<View
// @ts-ignore
hidden={!active}
style={[style, { display: active ? 'flex' : 'none' }]}
{...rest}
/>
);
}
}
const AnimatedWebScreen = Animated.createAnimatedComponent(WebScreen);
export const MaybeScreenContainer = ({
enabled,
...rest
}: ViewProps & {
enabled: boolean;
children: React.ReactNode;
}) => {
if (enabled && Platform.OS !== 'web' && Screens && Screens.screensEnabled()) {
return <Screens.ScreenContainer {...rest} />;
}
return <View {...rest} />;
};
export const MaybeScreen = ({
enabled,
active,
...rest
}: ViewProps & {
enabled: boolean;
active: number | Animated.AnimatedInterpolation;
children: React.ReactNode;
}) => {
if (enabled && Platform.OS === 'web') {
// @ts-ignore
return <AnimatedWebScreen active={active} {...rest} />;
}
if (enabled && Screens && Screens.screensEnabled()) {
// @ts-ignore
return <Screens.Screen active={active} {...rest} />;
}
return <View {...rest} />;
};

View File

@@ -9,14 +9,15 @@ import {
Platform,
InteractionManager,
} from 'react-native';
import {
PanGestureHandler,
State as GestureState,
PanGestureHandlerGestureEvent,
} from 'react-native-gesture-handler';
import { EdgeInsets } from 'react-native-safe-area-context';
import Color from 'color';
import StackGestureRefContext from '../../utils/GestureHandlerRefContext';
import CardSheet from './CardSheet';
import {
PanGestureHandler,
GestureState,
PanGestureHandlerGestureEvent,
} from '../GestureHandler';
import CardAnimationContext from '../../utils/CardAnimationContext';
import getDistanceForDirection from '../../utils/getDistanceForDirection';
import getInvertedMultiplier from '../../utils/getInvertedMultiplier';
@@ -36,6 +37,7 @@ type Props = ViewProps & {
gesture: Animated.Value;
layout: Layout;
insets: EdgeInsets;
pageOverflowEnabled: boolean;
gestureDirection: GestureDirection;
onOpen: () => void;
onClose: () => void;
@@ -246,11 +248,21 @@ export default class Card extends React.Component<Props> {
this.handleStartInteraction();
onGestureBegin?.();
break;
case GestureState.CANCELLED:
case GestureState.CANCELLED: {
this.isSwiping.setValue(FALSE);
this.handleEndInteraction();
const velocity =
gestureDirection === 'vertical' ||
gestureDirection === 'vertical-inverted'
? nativeEvent.velocityY
: nativeEvent.velocityX;
this.animate({ closing: this.props.closing, velocity });
onGestureCanceled?.();
break;
}
case GestureState.END: {
this.isSwiping.setValue(FALSE);
@@ -276,7 +288,7 @@ export default class Card extends React.Component<Props> {
getInvertedMultiplier(gestureDirection) >
distance / 2
? velocity !== 0 || translation !== 0
: false;
: this.props.closing;
this.animate({ closing, velocity });
@@ -402,8 +414,6 @@ export default class Card extends React.Component<Props> {
}
}
private gestureRef = React.createRef<PanGestureHandler>();
private contentRef = React.createRef<View>();
render() {
@@ -420,6 +430,7 @@ export default class Card extends React.Component<Props> {
shadowEnabled,
gestureEnabled,
gestureDirection,
pageOverflowEnabled,
children,
containerStyle: customContainerStyle,
contentStyle,
@@ -489,7 +500,6 @@ export default class Card extends React.Component<Props> {
pointerEvents="box-none"
>
<PanGestureHandler
ref={this.gestureRef}
enabled={layout.width !== 0 && gestureEnabled}
onGestureEvent={handleGestureEvent}
onHandlerStateChange={this.handleGestureStateChange}
@@ -507,19 +517,20 @@ export default class Card extends React.Component<Props> {
: gestureDirection === 'vertical'
? [styles.shadowVertical, styles.shadowTop]
: [styles.shadowVertical, styles.shadowBottom],
{ backgroundColor },
shadowStyle,
]}
pointerEvents="none"
/>
) : null}
<View
<CardSheet
ref={this.contentRef}
style={[styles.content, contentStyle]}
enabled={pageOverflowEnabled}
layout={layout}
style={contentStyle}
>
<StackGestureRefContext.Provider value={this.gestureRef}>
{children}
</StackGestureRefContext.Provider>
</View>
{children}
</CardSheet>
</Animated.View>
</PanGestureHandler>
</Animated.View>
@@ -533,17 +544,12 @@ const styles = StyleSheet.create({
container: {
flex: 1,
},
content: {
flex: 1,
overflow: 'hidden',
},
overlay: {
flex: 1,
backgroundColor: '#000',
},
shadow: {
position: 'absolute',
backgroundColor: '#fff',
shadowRadius: 5,
shadowColor: '#000',
shadowOpacity: 0.3,

View File

@@ -8,6 +8,7 @@ import {
Route,
Scene,
Layout,
StackCardMode,
StackHeaderMode,
TransitionPreset,
} from '../../types';
@@ -51,6 +52,7 @@ type Props = TransitionPreset & {
horizontal?: number;
};
gestureVelocityImpact?: number;
mode: StackCardMode;
headerMode: StackHeaderMode;
headerShown?: boolean;
headerTransparent?: boolean;
@@ -79,6 +81,7 @@ function CardContainer({
gestureVelocityImpact,
getPreviousRoute,
getFocusedRoute,
mode,
headerMode,
headerShown,
headerStyleInterpolator,
@@ -184,6 +187,7 @@ function CardContainer({
accessibilityElementsHidden={!focused}
importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
pointerEvents={active ? 'box-none' : pointerEvents}
pageOverflowEnabled={headerMode === 'screen' && mode === 'card'}
containerStyle={
headerMode === 'float' && !headerTransparent && headerShown !== false
? { marginTop: headerHeight }

View File

@@ -0,0 +1,49 @@
import * as React from 'react';
import { View, ViewProps, StyleSheet } from 'react-native';
type Props = ViewProps & {
enabled: boolean;
layout: { width: number; height: number };
children: React.ReactNode;
};
// This component will render a page which overflows the screen
// if the container fills the body by comparing the size
// This lets the document.body handle scrolling of the content
// It's necessary for mobile browsers to be able to hide address bar on scroll
export default React.forwardRef<View, Props>(function CardSheet(
{ enabled, layout, style, ...rest },
ref
) {
const [fill, setFill] = React.useState(false);
React.useEffect(() => {
if (typeof document === 'undefined' || !document.body) {
// Only run when DOM is available
return;
}
const width = document.body.clientWidth;
const height = document.body.clientHeight;
setFill(width === layout.width && height === layout.height);
}, [layout.height, layout.width]);
return (
<View
{...rest}
ref={ref}
style={[enabled && fill ? styles.page : styles.card, style]}
/>
);
});
const styles = StyleSheet.create({
page: {
minHeight: '100%',
},
card: {
flex: 1,
overflow: 'hidden',
},
});

View File

@@ -1,17 +1,15 @@
import * as React from 'react';
import {
Animated,
View,
StyleSheet,
LayoutChangeEvent,
Dimensions,
Platform,
ViewProps,
} from 'react-native';
import { EdgeInsets } from 'react-native-safe-area-context';
import { ScreenContainer, Screen, screensEnabled } from 'react-native-screens'; // Import with * as to prevent getters being called
import { NavigationState as StackNavigationState } from 'react-navigation';
import { MaybeScreenContainer, MaybeScreen } from '../Screens';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import CardContainer from './CardContainer';
@@ -75,37 +73,6 @@ type State = {
const EPSILON = 0.01;
const MaybeScreenContainer = ({
enabled,
...rest
}: ViewProps & {
enabled: boolean;
children: React.ReactNode;
}) => {
if (enabled && screensEnabled()) {
return <ScreenContainer {...rest} />;
}
return <View {...rest} />;
};
const MaybeScreen = ({
enabled,
active,
...rest
}: ViewProps & {
enabled: boolean;
active: number | Animated.AnimatedInterpolation;
children: React.ReactNode;
}) => {
if (enabled && screensEnabled()) {
// @ts-ignore
return <Screen active={active} {...rest} />;
}
return <View {...rest} />;
};
const FALLBACK_DESCRIPTOR = Object.freeze({ options: {} });
const getHeaderHeights = (
@@ -415,7 +382,7 @@ export default class CardStack extends React.Component<Props, State> {
// Screens is buggy on iOS and web, so we only enable it on Android
// For modals, usually we want the screen underneath to be visible, so also disable it there
const isScreensEnabled = Platform.OS === 'android' && mode !== 'modal';
const isScreensEnabled = Platform.OS !== 'ios' && mode !== 'modal';
return (
<React.Fragment>
@@ -553,6 +520,7 @@ export default class CardStack extends React.Component<Props, State> {
onHeaderHeightChange={this.handleHeaderLayout}
getPreviousRoute={getPreviousRoute}
getFocusedRoute={this.getFocusedRoute}
mode={mode}
headerMode={headerMode}
headerShown={headerShown}
headerTransparent={headerTransparent}
@@ -598,7 +566,6 @@ export default class CardStack extends React.Component<Props, State> {
const styles = StyleSheet.create({
container: {
flex: 1,
overflow: 'hidden',
},
floating: {
position: 'absolute',

View File

@@ -1,13 +1,14 @@
import * as React from 'react';
import { View, Platform, StyleSheet } from 'react-native';
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import {
StackActions,
NavigationState as StackNavigationState,
NavigationActions,
SceneView,
} from 'react-navigation';
import { GestureHandlerRootView } from '../GestureHandler';
import CardStack from './CardStack';
import KeyboardManager from '../KeyboardManager';
import HeaderContainer, {
@@ -48,31 +49,63 @@ type State = {
const GestureHandlerWrapper = GestureHandlerRootView ?? View;
/**
* Compare two arrays with primitive values as the content.
* We need to make sure that both values and order match.
*/
const isArrayEqual = (a: any[], b: any[]) =>
a.length === b.length && a.every((it, index) => it === b[index]);
export default class StackView extends React.Component<Props, State> {
static getDerivedStateFromProps(
props: Readonly<Props>,
state: Readonly<State>
) {
// If there was no change in routes, we don't need to compute anything
if (props.state.routes === state.previousRoutes && state.routes.length) {
if (props.descriptors !== state.previousDescriptors) {
const descriptors = state.routes.reduce<StackDescriptorMap>(
(acc, route) => {
acc[route.key] =
props.descriptors[route.key] || state.descriptors[route.key];
if (
(props.state.routes === state.previousRoutes ||
isArrayEqual(
props.state.routes.map((r) => r.key),
state.previousRoutes.map((r) => r.key)
)) &&
state.routes.length
) {
let routes = state.routes;
let previousRoutes = state.previousRoutes;
let descriptors = props.descriptors;
let previousDescriptors = state.previousDescriptors;
if (props.descriptors !== state.previousDescriptors) {
descriptors = state.routes.reduce<StackDescriptorMap>((acc, route) => {
acc[route.key] =
props.descriptors[route.key] || state.descriptors[route.key];
return acc;
}, {});
previousDescriptors = props.descriptors;
}
if (props.state.routes !== state.previousRoutes) {
// if any route objects have changed, we should update them
const map = props.state.routes.reduce<Record<string, Route<string>>>(
(acc, route) => {
acc[route.key] = route;
return acc;
},
{}
);
return {
previousDescriptors: props.descriptors,
descriptors,
};
routes = state.routes.map((route) => map[route.key] || route);
previousRoutes = props.state.routes;
}
return null;
return {
routes,
previousRoutes,
descriptors,
previousDescriptors,
};
}
// Here we determine which routes were added or removed to animate them
@@ -117,7 +150,7 @@ export default class StackView extends React.Component<Props, State> {
// We only need to animate routes if the focused route changed
// Animating previous routes won't be visible coz the focused route is on top of everything
if (!previousRoutes.find((r) => r.key === nextFocusedRoute.key)) {
if (!previousRoutes.some((r) => r.key === nextFocusedRoute.key)) {
// A new route has come to the focus, we treat this as a push
// A replace can also trigger this, the animation should look like push
@@ -136,7 +169,7 @@ export default class StackView extends React.Component<Props, State> {
(key) => key !== nextFocusedRoute.key
);
if (!routes.find((r) => r.key === previousFocusedRoute.key)) {
if (!routes.some((r) => r.key === previousFocusedRoute.key)) {
// The previous focused route isn't present in state, we treat this as a replace
openingRouteKeys = openingRouteKeys.filter(
@@ -176,7 +209,7 @@ export default class StackView extends React.Component<Props, State> {
}
}
}
} else if (!routes.find((r) => r.key === previousFocusedRoute.key)) {
} else if (!routes.some((r) => r.key === previousFocusedRoute.key)) {
// The previously focused route was removed, we treat this as a pop
if (
@@ -308,52 +341,60 @@ export default class StackView extends React.Component<Props, State> {
return <HeaderContainer {...props} />;
};
private handleTransitionComplete = ({ route }: { route: Route<string> }) => {
private handleTransitionComplete = () => {
const { state, navigation } = this.props;
if (state.isTransitioning) {
navigation.dispatch(
StackActions.completeTransition({
key: navigation.state.key,
toChildKey: route.key,
toChildKey: state.routes[state.index].key,
})
);
}
};
private handleOpenRoute = ({ route }: { route: Route<string> }) => {
this.handleTransitionComplete({ route });
this.setState((state) => ({
routes: state.replacingRouteKeys.length
? state.routes.filter((r) => !state.replacingRouteKeys.includes(r.key))
: state.routes,
openingRouteKeys: state.openingRouteKeys.filter(
(key) => key !== route.key
),
closingRouteKeys: state.closingRouteKeys.filter(
(key) => key !== route.key
),
replacingRouteKeys: [],
}));
const { state, navigation } = this.props;
this.handleTransitionComplete();
if (
this.state.replacingRouteKeys.every((key) => key !== route.key) &&
!state.routes.some((r) => r.key === route.key)
) {
// If route isn't present in current state, assume that a close animation was cancelled
// So we need to add this route back to the state
navigation.dispatch(NavigationActions.navigate(route));
} else {
this.setState((state) => ({
routes: state.replacingRouteKeys.length
? state.routes.filter(
(r) => !state.replacingRouteKeys.includes(r.key)
)
: state.routes,
openingRouteKeys: state.openingRouteKeys.filter(
(key) => key !== route.key
),
closingRouteKeys: state.closingRouteKeys.filter(
(key) => key !== route.key
),
replacingRouteKeys: [],
}));
}
};
private handleCloseRoute = ({ route }: { route: Route<string> }) => {
const { state, navigation } = this.props;
if (state.routes.find((r) => r.key === route.key)) {
if (state.routes.some((r) => r.key === route.key)) {
// If a route exists in state, trigger a pop
// This will happen in when the route was closed from the card component
// e.g. When the close animation triggered from a gesture ends
// @ts-ignore
navigation.dispatch(StackActions.pop({ key: route.key, prune: false }));
} else {
// While closing route we need to point to the previous one assuming that
// this previous one in routes array
const index = this.state.routes.findIndex((r) => r.key === route.key);
this.handleTransitionComplete({
route: this.state.routes[Math.max(index - 1, 0)],
});
this.handleTransitionComplete();
// We need to clean up any state tracking the route and pop it immediately
this.setState((state) => ({
@@ -408,41 +449,43 @@ export default class StackView extends React.Component<Props, State> {
} = this.state;
const headerMode =
mode !== 'modal' && Platform.OS === 'ios' ? 'float' : 'screen';
mode === 'card' && Platform.OS === 'ios' ? 'float' : 'screen';
return (
<GestureHandlerWrapper style={styles.container}>
<SafeAreaProviderCompat>
<SafeAreaConsumer>
{(insets) => (
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
{(props) => (
<CardStack
mode={mode}
insets={insets as EdgeInsets}
getPreviousRoute={this.getPreviousRoute}
getGesturesEnabled={this.getGesturesEnabled}
routes={routes}
openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys}
onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute}
onTransitionStart={this.handleTransitionStart}
onTransitionEnd={this.handleTransitionEnd}
renderHeader={this.renderHeader}
renderScene={this.renderScene}
headerMode={headerMode}
state={state}
descriptors={descriptors}
{...rest}
{...props}
/>
)}
</KeyboardManager>
)}
</SafeAreaConsumer>
</SafeAreaProviderCompat>
</GestureHandlerWrapper>
<>
<GestureHandlerWrapper style={styles.container}>
<SafeAreaProviderCompat>
<SafeAreaConsumer>
{(insets) => (
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
{(props) => (
<CardStack
mode={mode}
insets={insets as EdgeInsets}
getPreviousRoute={this.getPreviousRoute}
getGesturesEnabled={this.getGesturesEnabled}
routes={routes}
openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys}
onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute}
onTransitionStart={this.handleTransitionStart}
onTransitionEnd={this.handleTransitionEnd}
renderHeader={this.renderHeader}
renderScene={this.renderScene}
headerMode={headerMode}
state={state}
descriptors={descriptors}
{...rest}
{...props}
/>
)}
</KeyboardManager>
)}
</SafeAreaConsumer>
</SafeAreaProviderCompat>
</GestureHandlerWrapper>
</>
);
}
}

View File

@@ -0,0 +1,81 @@
/**
* TouchableItem renders a touchable that looks native on both iOS and Android.
*
* It provides an abstraction on top of TouchableNativeFeedback and
* TouchableOpacity.
*
* On iOS you can pass the props of TouchableOpacity, on Android pass the props
* of TouchableNativeFeedback.
*/
import * as React from 'react';
import {
Platform,
TouchableNativeFeedback,
TouchableOpacity,
View,
ViewProps,
} from 'react-native';
import BorderlessButton from './BorderlessButton';
export type Props = ViewProps & {
pressColor: string;
disabled?: boolean;
borderless?: boolean;
delayPressIn?: number;
onPress?: () => void;
children: React.ReactNode;
};
const ANDROID_VERSION_LOLLIPOP = 21;
export class TouchableItem extends React.Component<Props> {
static defaultProps = {
borderless: false,
pressColor: 'rgba(0, 0, 0, .32)',
};
render() {
/*
* TouchableNativeFeedback.Ripple causes a crash on old Android versions,
* therefore only enable it on Android Lollipop and above.
*
* All touchables on Android should have the ripple effect according to
* platform design guidelines.
* We need to pass the background prop to specify a borderless ripple effect.
*/
if (
Platform.OS === 'android' &&
Platform.Version >= ANDROID_VERSION_LOLLIPOP
) {
const { style, pressColor, borderless, children, ...rest } = this.props;
return (
<TouchableNativeFeedback
{...rest}
useForeground={TouchableNativeFeedback.canUseNativeForeground()}
background={TouchableNativeFeedback.Ripple(pressColor, borderless)}
>
<View style={style}>{React.Children.only(children)}</View>
</TouchableNativeFeedback>
);
} else if (Platform.OS === 'ios') {
return (
<BorderlessButton
hitSlop={{ top: 10, bottom: 10, right: 10, left: 10 }}
disallowInterruption
enabled={!this.props.disabled}
{...this.props}
>
{this.props.children}
</BorderlessButton>
);
} else {
return (
<TouchableOpacity {...this.props}>
{this.props.children}
</TouchableOpacity>
);
}
}
}

View File

@@ -1,80 +1,3 @@
/**
* TouchableItem renders a touchable that looks native on both iOS and Android.
*
* It provides an abstraction on top of TouchableNativeFeedback and
* TouchableOpacity.
*
* On iOS you can pass the props of TouchableOpacity, on Android pass the props
* of TouchableNativeFeedback.
*/
import * as React from 'react';
import {
Platform,
TouchableNativeFeedback,
TouchableOpacity,
View,
ViewProps,
} from 'react-native';
import { TouchableOpacity } from 'react-native';
import BorderlessButton from './BorderlessButton';
type Props = ViewProps & {
pressColor: string;
disabled?: boolean;
borderless?: boolean;
delayPressIn?: number;
onPress?: () => void;
};
const ANDROID_VERSION_LOLLIPOP = 21;
export default class TouchableItem extends React.Component<Props> {
static defaultProps = {
borderless: false,
pressColor: 'rgba(0, 0, 0, .32)',
};
render() {
/*
* TouchableNativeFeedback.Ripple causes a crash on old Android versions,
* therefore only enable it on Android Lollipop and above.
*
* All touchables on Android should have the ripple effect according to
* platform design guidelines.
* We need to pass the background prop to specify a borderless ripple effect.
*/
if (
Platform.OS === 'android' &&
Platform.Version >= ANDROID_VERSION_LOLLIPOP
) {
const { style, pressColor, borderless, children, ...rest } = this.props;
return (
<TouchableNativeFeedback
{...rest}
useForeground={TouchableNativeFeedback.canUseNativeForeground()}
background={TouchableNativeFeedback.Ripple(pressColor, borderless)}
>
<View style={style}>{React.Children.only(children)}</View>
</TouchableNativeFeedback>
);
} else if (Platform.OS === 'ios') {
return (
<BorderlessButton
hitSlop={{ top: 10, bottom: 10, right: 10, left: 10 }}
disallowInterruption
enabled={!this.props.disabled}
{...this.props}
>
{this.props.children}
</BorderlessButton>
);
} else {
return (
<TouchableOpacity {...this.props}>
{this.props.children}
</TouchableOpacity>
);
}
}
}
export const TouchableItem = (TouchableOpacity as any) as typeof import('./TouchableItem.native').TouchableItem;

View File

@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.8.13](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.12...react-navigation-tabs@2.8.13) (2020-04-30)
**Note:** Version bump only for package react-navigation-tabs
## [2.8.12](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.11...react-navigation-tabs@2.8.12) (2020-04-22)
**Note:** Version bump only for package react-navigation-tabs
## [2.8.11](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.10...react-navigation-tabs@2.8.11) (2020-04-02)
**Note:** Version bump only for package react-navigation-tabs
## [2.8.10](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.9...react-navigation-tabs@2.8.10) (2020-03-31)
**Note:** Version bump only for package react-navigation-tabs
## [2.8.9](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.7...react-navigation-tabs@2.8.9) (2020-03-28)
**Note:** Version bump only for package react-navigation-tabs
## [2.8.8](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.7...react-navigation-tabs@2.8.8) (2020-03-27)
**Note:** Version bump only for package react-navigation-tabs

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-tabs",
"version": "2.8.8",
"version": "2.8.13",
"description": "Tab Navigation components for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
@@ -42,7 +42,7 @@
"dependencies": {
"hoist-non-react-statics": "^3.3.2",
"react-lifecycles-compat": "^3.0.4",
"react-native-safe-area-view": "^0.14.8",
"react-native-safe-area-view": "^0.14.9",
"react-native-tab-view": "^2.11.0"
},
"devDependencies": {
@@ -56,8 +56,8 @@
"react-native-gesture-handler": "^1.6.0",
"react-native-reanimated": "^1.2.0",
"react-native-tab-view": "^2.13.0",
"react-navigation": "^4.3.4",
"typescript": "~3.7.5"
"react-navigation": "^4.3.9",
"typescript": "~3.8.3"
},
"peerDependencies": {
"react": "*",

View File

@@ -17,7 +17,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["esnext"],
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,

903
yarn.lock

File diff suppressed because it is too large Load Diff