mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-13 09:30:30 +08:00
Compare commits
8 Commits
@react-nav
...
react-navi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66374db859 | ||
|
|
8dbe0299a8 | ||
|
|
e4bc6dd506 | ||
|
|
4bac3bfc1a | ||
|
|
7656b35ee8 | ||
|
|
597aa51fad | ||
|
|
a929933bde | ||
|
|
911d6bb2f4 |
@@ -335,7 +335,7 @@ class MainScreen extends React.Component<any, State> {
|
||||
}}
|
||||
>
|
||||
{(Object.keys(ExampleInfo) as (keyof typeof ExampleInfo)[]).map(
|
||||
routeName => (
|
||||
(routeName) => (
|
||||
<RectButton
|
||||
key={routeName}
|
||||
underlayColor="#ccc"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = function(api) {
|
||||
module.exports = function (api) {
|
||||
api.cache(true);
|
||||
return {
|
||||
presets: ['babel-preset-expo'],
|
||||
|
||||
@@ -11,8 +11,8 @@ const modules = ['@expo/vector-icons']
|
||||
// List all packages under `packages/`
|
||||
.readdirSync(packages)
|
||||
// Ignore hidden files such as .DS_Store
|
||||
.filter(p => !p.startsWith('.'))
|
||||
.map(p => {
|
||||
.filter((p) => !p.startsWith('.'))
|
||||
.map((p) => {
|
||||
const pak = JSON.parse(
|
||||
fs.readFileSync(path.join(packages, p, 'package.json'), 'utf8')
|
||||
);
|
||||
@@ -50,7 +50,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
server: {
|
||||
enhanceMiddleware: middleware => {
|
||||
enhanceMiddleware: (middleware) => {
|
||||
return (req, res, next) => {
|
||||
// When an asset is imported outside the project root, it has wrong path on Android
|
||||
// This happens for the back button in stack, so we fix the path to correct one
|
||||
|
||||
@@ -62,7 +62,7 @@ const CustomTabBar = ({
|
||||
const { routes } = navigation.state;
|
||||
return (
|
||||
<SafeAreaView style={styles.tabContainer}>
|
||||
{routes.map(route => (
|
||||
{routes.map((route) => (
|
||||
<BorderlessButton
|
||||
onPress={() => navigation.navigate(route.routeName)}
|
||||
style={styles.tab}
|
||||
|
||||
@@ -44,7 +44,7 @@ const ContainerWithButtons = withNavigation(
|
||||
const MapScreen = () => (
|
||||
<ContainerWithButtons>
|
||||
<DrawerGestureContext.Consumer>
|
||||
{ref => (
|
||||
{(ref) => (
|
||||
<NativeViewGestureHandler waitFor={ref}>
|
||||
<MapView style={{ flex: 1 }} />
|
||||
</NativeViewGestureHandler>
|
||||
@@ -60,7 +60,7 @@ MapScreen.navigationOptions = {
|
||||
const WebViewScreen = () => (
|
||||
<ContainerWithButtons>
|
||||
<DrawerGestureContext.Consumer>
|
||||
{ref => (
|
||||
{(ref) => (
|
||||
<NativeViewGestureHandler waitFor={ref}>
|
||||
<WebView
|
||||
style={{ flex: 1 }}
|
||||
|
||||
@@ -33,7 +33,7 @@ const BarCodeScreenBase = (
|
||||
<BarCodeScanner
|
||||
onBarCodeScanned={
|
||||
props.isFocused
|
||||
? data => {
|
||||
? (data) => {
|
||||
console.log('scanned...');
|
||||
props.navigation.navigate('Info', { data });
|
||||
}
|
||||
@@ -51,7 +51,7 @@ BarCodeScreenBase.navigationOptions = {
|
||||
|
||||
const BarCodeScreen = withNavigationFocus(BarCodeScreenBase);
|
||||
|
||||
const InfoScreen: NavigationStackScreenComponent = props => {
|
||||
const InfoScreen: NavigationStackScreenComponent = (props) => {
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Text>{JSON.stringify(props.navigation.getParam('data'))}</Text>
|
||||
|
||||
@@ -82,7 +82,7 @@ class ListScreen extends React.Component<
|
||||
state = { isInverted: false };
|
||||
|
||||
onSwitch = () =>
|
||||
this.setState(prevState => ({ isInverted: !prevState.isInverted }));
|
||||
this.setState((prevState) => ({ isInverted: !prevState.isInverted }));
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -158,7 +158,7 @@ const DrawerContents = ({
|
||||
<Animated.View style={{ transform: [{ translateX }] }}>
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
{navigation.state.routes.map(route => (
|
||||
{navigation.state.routes.map((route) => (
|
||||
<DrawerItem
|
||||
key={route.key}
|
||||
navigation={descriptors[route.key].navigation}
|
||||
|
||||
@@ -32,7 +32,7 @@ class RightDrawer extends Component<DrawerContentComponentProps> {
|
||||
<ScrollView
|
||||
style={{ height: '100%', width: '100%', backgroundColor: '#333333' }}
|
||||
>
|
||||
{this.state.categories.map(key => {
|
||||
{this.state.categories.map((key) => {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={key.n}
|
||||
|
||||
@@ -59,7 +59,7 @@ export default function PhotoGrid({ id }: { id: string }) {
|
||||
|
||||
return (
|
||||
<NavigationAwareScrollView contentContainerStyle={styles.content}>
|
||||
{PHOTOS.map(uri => (
|
||||
{PHOTOS.map((uri) => (
|
||||
<View key={uri} style={styles.item}>
|
||||
<Image source={{ uri }} style={styles.photo} />
|
||||
</View>
|
||||
|
||||
@@ -25,7 +25,7 @@ const ListScreen = (props: NavigationStackScreenProps) => (
|
||||
|
||||
const AnotherScreen = () => (
|
||||
<CardAnimationContext.Consumer>
|
||||
{value => {
|
||||
{(value) => {
|
||||
const scale = value
|
||||
? value.current.progress.interpolate({
|
||||
inputRange: [0, 1],
|
||||
@@ -67,7 +67,7 @@ const YetAnotherScreen = () => (
|
||||
}}
|
||||
>
|
||||
<CardAnimationContext.Consumer>
|
||||
{value => (
|
||||
{(value) => (
|
||||
<Animated.Text
|
||||
style={{
|
||||
fontSize: 24,
|
||||
@@ -84,7 +84,7 @@ const YetAnotherScreen = () => (
|
||||
)}
|
||||
</CardAnimationContext.Consumer>
|
||||
<CardAnimationContext.Consumer>
|
||||
{value => (
|
||||
{(value) => (
|
||||
<Animated.Text
|
||||
style={{
|
||||
fontSize: 24,
|
||||
|
||||
@@ -59,7 +59,7 @@ const Drawer = createDrawerNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
contentComponent: props => <Menu {...props} />,
|
||||
contentComponent: (props) => <Menu {...props} />,
|
||||
navigationOptions: { title: 'Example' },
|
||||
}
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NavigationStackScreenComponent,
|
||||
} from 'react-navigation-stack';
|
||||
|
||||
const ListScreen: NavigationStackScreenComponent = function(props) {
|
||||
const ListScreen: NavigationStackScreenComponent = function (props) {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -29,7 +29,7 @@ const ListScreen: NavigationStackScreenComponent = function(props) {
|
||||
);
|
||||
};
|
||||
|
||||
const ModalDialogScreen: NavigationStackScreenComponent = function(props) {
|
||||
const ModalDialogScreen: NavigationStackScreenComponent = function (props) {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"husky": "^4.2.1",
|
||||
"jest": "^25.1.0",
|
||||
"lerna": "^3.20.2",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier": "^2.0.1",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
"resolutions": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.5.6](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.5...react-navigation-animated-switch@0.5.6) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.5.5](https://github.com/react-navigation/react-navigation/compare/react-navigation-animated-switch@0.5.4...react-navigation-animated-switch@0.5.5) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-animated-switch
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-animated-switch",
|
||||
"version": "0.5.5",
|
||||
"version": "0.5.6",
|
||||
"description": "Animated switch for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -28,7 +28,7 @@
|
||||
"react": "~16.9.0",
|
||||
"react-native": "~0.61.5",
|
||||
"react-native-reanimated": "~1.7.0",
|
||||
"react-navigation": "^4.3.2",
|
||||
"react-navigation": "^4.3.3",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.7.1](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.7.0...@react-navigation/core@3.7.1) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [3.7.0](https://github.com/react-navigation/react-navigation-core/compare/@react-navigation/core@3.6.1...@react-navigation/core@3.7.0) (2020-03-16)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@react-navigation/core",
|
||||
"version": "3.7.0",
|
||||
"version": "3.7.1",
|
||||
"description": "Core utilities for the react-navigation framework",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -15,7 +15,8 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
"access": "public",
|
||||
"tag": "4.x"
|
||||
},
|
||||
"keywords": [
|
||||
"react-navigation",
|
||||
|
||||
@@ -13,7 +13,7 @@ const StateUtils = {
|
||||
* Gets a route by key. If the route isn't found, returns `null`.
|
||||
*/
|
||||
get(state, key) {
|
||||
return state.routes.find(route => route.key === key) || null;
|
||||
return state.routes.find((route) => route.key === key) || null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ const StateUtils = {
|
||||
* routes of the navigation state, or -1 if it is not present.
|
||||
*/
|
||||
indexOf(state, key) {
|
||||
return state.routes.findIndex(route => route.key === key);
|
||||
return state.routes.findIndex((route) => route.key === key);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ const StateUtils = {
|
||||
* routes of the navigation state.
|
||||
*/
|
||||
has(state, key) {
|
||||
return !!state.routes.some(route => route.key === key);
|
||||
return !!state.routes.some((route) => route.key === key);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@ import getChildEventSubscriber from '../getChildEventSubscriber';
|
||||
|
||||
it('child action events only flow when focused', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitParentAction = (payload) => {
|
||||
parentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -52,8 +52,8 @@ it('child action events only flow when focused', () => {
|
||||
|
||||
it('grandchildren subscription', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitGrandParentAction = (payload) => {
|
||||
grandParentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -119,8 +119,8 @@ it('grandchildren subscription', () => {
|
||||
|
||||
it('grandchildren transitions', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitGrandParentAction = (payload) => {
|
||||
grandParentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -212,8 +212,8 @@ it('grandchildren transitions', () => {
|
||||
|
||||
it('grandchildren pass through transitions', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitGrandParentAction = (payload) => {
|
||||
grandParentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -305,8 +305,8 @@ it('grandchildren pass through transitions', () => {
|
||||
|
||||
it('child focus with transition', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitParentAction = (payload) => {
|
||||
parentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -398,8 +398,8 @@ it('child focus with transition', () => {
|
||||
|
||||
it('child focus with immediate transition', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitParentAction = (payload) => {
|
||||
parentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
@@ -461,8 +461,8 @@ it('child focus with immediate transition', () => {
|
||||
|
||||
const setupEventTest = (subscriptionKey, initialLastFocusEvent) => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitEvent = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
const emitEvent = (payload) => {
|
||||
parentSubscriber.mock.calls.forEach((subs) => {
|
||||
if (subs[0] === payload.type) {
|
||||
subs[1](payload);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ it('getNavigation provides default action helpers', () => {
|
||||
it.skip('getNavigation provides router action helpers', () => {
|
||||
const router = {
|
||||
getActionCreators: () => ({
|
||||
foo: bar => ({ type: 'FooBarAction', bar }),
|
||||
foo: (bar) => ({ type: 'FooBarAction', bar }),
|
||||
}),
|
||||
getStateForAction(action, lastState = {}) {
|
||||
return lastState;
|
||||
|
||||
@@ -24,12 +24,12 @@ export default function getChildEventSubscriber(
|
||||
willBlurSubscribers,
|
||||
didBlurSubscribers,
|
||||
refocusSubscribers,
|
||||
].forEach(set => set.clear());
|
||||
].forEach((set) => set.clear());
|
||||
|
||||
upstreamSubscribers.forEach(subs => subs && subs.remove());
|
||||
upstreamSubscribers.forEach((subs) => subs && subs.remove());
|
||||
};
|
||||
|
||||
const getChildSubscribers = evtName => {
|
||||
const getChildSubscribers = (evtName) => {
|
||||
switch (evtName) {
|
||||
case 'action':
|
||||
return actionSubscribers;
|
||||
@@ -52,7 +52,7 @@ export default function getChildEventSubscriber(
|
||||
const payloadWithType = { ...payload, type };
|
||||
const subscribers = getChildSubscribers(type);
|
||||
subscribers &&
|
||||
subscribers.forEach(subs => {
|
||||
subscribers.forEach((subs) => {
|
||||
subs(payloadWithType);
|
||||
});
|
||||
};
|
||||
@@ -72,8 +72,8 @@ export default function getChildEventSubscriber(
|
||||
'action',
|
||||
];
|
||||
|
||||
const upstreamSubscribers = upstreamEvents.map(eventName =>
|
||||
addListener(eventName, payload => {
|
||||
const upstreamSubscribers = upstreamEvents.map((eventName) =>
|
||||
addListener(eventName, (payload) => {
|
||||
if (eventName === 'refocus') {
|
||||
emit(eventName, payload);
|
||||
return;
|
||||
@@ -89,8 +89,8 @@ export default function getChildEventSubscriber(
|
||||
|
||||
const isChildFocused = focusKey === key;
|
||||
const lastRoute =
|
||||
lastRoutes && lastRoutes.find(route => route.key === key);
|
||||
const newRoute = routes && routes.find(route => route.key === key);
|
||||
lastRoutes && lastRoutes.find((route) => route.key === key);
|
||||
const newRoute = routes && routes.find((route) => route.key === key);
|
||||
const childPayload = {
|
||||
context: `${key}:${action.type}_${payload.context || 'Root'}`,
|
||||
state: newRoute,
|
||||
|
||||
@@ -3,7 +3,7 @@ import getChildRouter from './getChildRouter';
|
||||
import getNavigationActionCreators from './routers/getNavigationActionCreators';
|
||||
import getChildrenNavigationCache from './getChildrenNavigationCache';
|
||||
|
||||
const createParamGetter = route => (paramName, defaultValue) => {
|
||||
const createParamGetter = (route) => (paramName, defaultValue) => {
|
||||
const params = route.params;
|
||||
|
||||
if (params && paramName in params) {
|
||||
@@ -15,7 +15,7 @@ const createParamGetter = route => (paramName, defaultValue) => {
|
||||
|
||||
function getChildNavigation(navigation, childKey, getCurrentParentNavigation) {
|
||||
const children = getChildrenNavigationCache(navigation);
|
||||
const childRoute = navigation.state.routes.find(r => r.key === childKey);
|
||||
const childRoute = navigation.state.routes.find((r) => r.key === childKey);
|
||||
|
||||
if (!childRoute) {
|
||||
return null;
|
||||
@@ -47,7 +47,7 @@ function getChildNavigation(navigation, childKey, getCurrentParentNavigation) {
|
||||
};
|
||||
|
||||
const actionHelpers = {};
|
||||
Object.keys(actionCreators).forEach(actionName => {
|
||||
Object.keys(actionCreators).forEach((actionName) => {
|
||||
actionHelpers[actionName] = (...args) => {
|
||||
const actionCreator = actionCreators[actionName];
|
||||
const action = actionCreator(...args);
|
||||
@@ -91,7 +91,7 @@ function getChildNavigation(navigation, childKey, getCurrentParentNavigation) {
|
||||
actions: actionCreators,
|
||||
getParam: createParamGetter(childRoute),
|
||||
|
||||
getChildNavigation: grandChildKey =>
|
||||
getChildNavigation: (grandChildKey) =>
|
||||
getChildNavigation(children[childKey], grandChildKey, () => {
|
||||
const nav = getCurrentParentNavigation();
|
||||
return nav && nav.getChildNavigation(childKey);
|
||||
|
||||
@@ -5,8 +5,8 @@ export default function getChildrenNavigationCache(navigation) {
|
||||
|
||||
let childrenNavigationCache =
|
||||
navigation._childrenNavigation || (navigation._childrenNavigation = {});
|
||||
let childKeys = navigation.state.routes.map(route => route.key);
|
||||
Object.keys(childrenNavigationCache).forEach(cacheKey => {
|
||||
let childKeys = navigation.state.routes.map((route) => route.key);
|
||||
Object.keys(childrenNavigationCache).forEach((cacheKey) => {
|
||||
if (!childKeys.includes(cacheKey) && !navigation.state.isTransitioning) {
|
||||
delete childrenNavigationCache[cacheKey];
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ export default function getNavigation(
|
||||
state,
|
||||
dispatch,
|
||||
getScreenProps,
|
||||
getChildNavigation: childKey =>
|
||||
getChildNavigation: (childKey) =>
|
||||
getChildNavigation(navigation, childKey, getCurrentNavigation),
|
||||
isFocused: childKey => {
|
||||
isFocused: (childKey) => {
|
||||
const { routes, index } = getCurrentNavigation().state;
|
||||
if (childKey == null || routes[index].key === childKey) {
|
||||
return true;
|
||||
@@ -48,7 +48,7 @@ export default function getNavigation(
|
||||
...actions,
|
||||
};
|
||||
|
||||
Object.keys(actionCreators).forEach(actionName => {
|
||||
Object.keys(actionCreators).forEach((actionName) => {
|
||||
navigation[actionName] = (...args) =>
|
||||
navigation.dispatch(actionCreators[actionName](...args));
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ import { render, fireEvent } from 'react-native-testing-library';
|
||||
import { createAppContainer } from '@react-navigation/native';
|
||||
import createSwitchNavigator from '../createSwitchNavigator';
|
||||
|
||||
const getActiveRouteName = state => state.routes[state.index].routeName;
|
||||
const createScreen = (routeName, nextRouteName) => props => (
|
||||
const getActiveRouteName = (state) => state.routes[state.index].routeName;
|
||||
const createScreen = (routeName, nextRouteName) => (props) => (
|
||||
<View>
|
||||
<Text testID="title">{routeName}</Text>
|
||||
<Text testID={routeName + '-isFirstRoute'}>
|
||||
|
||||
@@ -5,33 +5,33 @@ export const RESET = 'Navigation/RESET';
|
||||
export const REPLACE = 'Navigation/REPLACE';
|
||||
export const COMPLETE_TRANSITION = 'Navigation/COMPLETE_TRANSITION';
|
||||
|
||||
export const pop = payload => ({
|
||||
export const pop = (payload) => ({
|
||||
type: POP,
|
||||
...payload,
|
||||
});
|
||||
|
||||
export const popToTop = payload => ({
|
||||
export const popToTop = (payload) => ({
|
||||
type: POP_TO_TOP,
|
||||
...payload,
|
||||
});
|
||||
|
||||
export const push = payload => ({
|
||||
export const push = (payload) => ({
|
||||
type: PUSH,
|
||||
...payload,
|
||||
});
|
||||
|
||||
export const reset = payload => ({
|
||||
export const reset = (payload) => ({
|
||||
type: RESET,
|
||||
key: null,
|
||||
...payload,
|
||||
});
|
||||
|
||||
export const replace = payload => ({
|
||||
export const replace = (payload) => ({
|
||||
type: REPLACE,
|
||||
...payload,
|
||||
});
|
||||
|
||||
export const completeTransition = payload => ({
|
||||
export const completeTransition = (payload) => ({
|
||||
type: COMPLETE_TRANSITION,
|
||||
preserveFocus: true,
|
||||
...payload,
|
||||
|
||||
@@ -29,7 +29,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
const routeNames = Object.keys(routeConfigs);
|
||||
|
||||
// Loop through routes and find child routers
|
||||
routeNames.forEach(routeName => {
|
||||
routeNames.forEach((routeName) => {
|
||||
// We're not using `getScreenForRouteName` here to preserve the lazy loading
|
||||
// behaviour of routes. This means that routes with child routers must be
|
||||
// defined using a component directly or with an object with a screen prop.
|
||||
@@ -152,7 +152,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
n,
|
||||
...params,
|
||||
}),
|
||||
popToTop: params => StackActions.popToTop(params),
|
||||
popToTop: (params) => StackActions.popToTop(params),
|
||||
push: (routeName, params, action) =>
|
||||
StackActions.push({
|
||||
routeName,
|
||||
@@ -280,7 +280,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
|
||||
// Before pushing a new route we first try to find one in the existing route stack
|
||||
// More information on this: https://github.com/react-navigation/rfcs/blob/master/text/0004-less-pushy-navigate.md
|
||||
const lastRouteIndex = state.routes.findIndex(r => {
|
||||
const lastRouteIndex = state.routes.findIndex((r) => {
|
||||
if (action.key) {
|
||||
return r.key === action.key;
|
||||
} else {
|
||||
@@ -425,7 +425,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
if (action.key === undefined && state.routes.length) {
|
||||
routeIndex = state.routes.length - 1;
|
||||
} else {
|
||||
routeIndex = state.routes.findIndex(r => r.key === action.key);
|
||||
routeIndex = state.routes.findIndex((r) => r.key === action.key);
|
||||
}
|
||||
|
||||
// Only replace if the key matches one of our routes
|
||||
@@ -467,7 +467,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
|
||||
if (action.type === NavigationActions.SET_PARAMS) {
|
||||
const key = action.key;
|
||||
const lastRoute = state.routes.find(route => route.key === key);
|
||||
const lastRoute = state.routes.find((route) => route.key === key);
|
||||
if (lastRoute) {
|
||||
const params = {
|
||||
...lastRoute.params,
|
||||
@@ -496,7 +496,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
routes: newStackActions.map(newStackAction => {
|
||||
routes: newStackActions.map((newStackAction) => {
|
||||
const router = childRouters[newStackAction.routeName];
|
||||
|
||||
let childState = {};
|
||||
@@ -535,7 +535,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
const { key, n, immediate, prune } = action;
|
||||
|
||||
if (action.type === StackActions.POP && prune === false && key) {
|
||||
const index = state.routes.findIndex(r => r.key === key);
|
||||
const index = state.routes.findIndex((r) => r.key === key);
|
||||
const count = Math.max(index - (n == null ? 1 : n) + 1, 1);
|
||||
const routes = state.routes
|
||||
.slice(0, count)
|
||||
@@ -557,7 +557,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
// back from state.index, as if it were a normal "BACK" action
|
||||
backRouteIndex = Math.max(1, state.index - n + 1);
|
||||
} else if (key) {
|
||||
const backRoute = state.routes.find(route => route.key === key);
|
||||
const backRoute = state.routes.find((route) => route.key === key);
|
||||
backRouteIndex = state.routes.indexOf(backRoute);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ export default (routeConfigs, config = {}) => {
|
||||
if (initialRouteIndex === -1) {
|
||||
throw new Error(
|
||||
`Invalid initialRouteName '${initialRouteName}'.` +
|
||||
`Should be one of ${order.map(n => `"${n}"`).join(', ')}`
|
||||
`Should be one of ${order.map((n) => `"${n}"`).join(', ')}`
|
||||
);
|
||||
}
|
||||
|
||||
const childRouters = {};
|
||||
order.forEach(routeName => {
|
||||
order.forEach((routeName) => {
|
||||
childRouters[routeName] = null;
|
||||
const screen = getScreenForRouteName(routeConfigs, routeName);
|
||||
if (screen.router) {
|
||||
@@ -93,7 +93,7 @@ export default (routeConfigs, config = {}) => {
|
||||
if (action.type === NavigationActions.NAVIGATE) {
|
||||
nextRouteKeyHistory = [...nextRouteKeyHistory]; // copy
|
||||
const keyToAdd = nextState.routes[nextState.index].key;
|
||||
nextRouteKeyHistory = nextRouteKeyHistory.filter(k => k !== keyToAdd); // dedup
|
||||
nextRouteKeyHistory = nextRouteKeyHistory.filter((k) => k !== keyToAdd); // dedup
|
||||
nextRouteKeyHistory.push(keyToAdd);
|
||||
} else if (action.type === NavigationActions.BACK) {
|
||||
nextRouteKeyHistory = [...nextRouteKeyHistory]; // copy
|
||||
@@ -156,7 +156,7 @@ export default (routeConfigs, config = {}) => {
|
||||
// Merge any params from the action into all the child routes
|
||||
const { params } = action;
|
||||
if (params) {
|
||||
state.routes = state.routes.map(route => ({
|
||||
state.routes = state.routes.map((route) => ({
|
||||
...route,
|
||||
params: {
|
||||
...route.params,
|
||||
@@ -175,14 +175,14 @@ export default (routeConfigs, config = {}) => {
|
||||
) {
|
||||
const { params } = action;
|
||||
const index = state.routes.findIndex(
|
||||
route => route.routeName === action.routeName
|
||||
(route) => route.routeName === action.routeName
|
||||
);
|
||||
|
||||
if (index === -1) {
|
||||
throw new Error(
|
||||
`There is no route named '${action.routeName}' in the navigator with the key '${action.key}'.\n` +
|
||||
`Must be one of: ${state.routes
|
||||
.map(route => `'${route.routeName}'`)
|
||||
.map((route) => `'${route.routeName}'`)
|
||||
.join(',')}`
|
||||
);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ export default (routeConfigs, config = {}) => {
|
||||
|
||||
if (action.type === NavigationActions.SET_PARAMS) {
|
||||
const key = action.key;
|
||||
const lastRoute = state.routes.find(route => route.key === key);
|
||||
const lastRoute = state.routes.find((route) => route.key === key);
|
||||
if (lastRoute) {
|
||||
const params = {
|
||||
...lastRoute.params,
|
||||
|
||||
@@ -12,7 +12,7 @@ beforeEach(() => {
|
||||
_TESTING_ONLY_normalize_keys();
|
||||
});
|
||||
|
||||
const performRouterTest = createTestRouter => {
|
||||
const performRouterTest = (createTestRouter) => {
|
||||
const ListScreen = () => <div />;
|
||||
|
||||
const ProfileNavigator = () => <div />;
|
||||
@@ -584,7 +584,7 @@ it('Handles nested switch routers', () => {
|
||||
expect(action.action.routeName).toEqual('B');
|
||||
});
|
||||
|
||||
const performRouteNameAsPathDisabledTest = createTestRouter => {
|
||||
const performRouteNameAsPathDisabledTest = (createTestRouter) => {
|
||||
const BScreen = () => <div />;
|
||||
const NestedNavigator = () => <div />;
|
||||
NestedNavigator.router = createTestRouter({
|
||||
|
||||
@@ -24,7 +24,7 @@ const dummyEventSubscriber = () => ({
|
||||
remove: () => {},
|
||||
});
|
||||
|
||||
Object.keys(ROUTERS).forEach(routerName => {
|
||||
Object.keys(ROUTERS).forEach((routerName) => {
|
||||
const Router = ROUTERS[routerName];
|
||||
|
||||
describe(`General router features - ${routerName}`, () => {
|
||||
@@ -441,7 +441,7 @@ it('Inner actions are only unpacked if the current tab matches', () => {
|
||||
routes: [screenApreState],
|
||||
};
|
||||
|
||||
const comparable = state => {
|
||||
const comparable = (state) => {
|
||||
let result = {};
|
||||
if (typeof state.routeName === 'string') {
|
||||
result = { ...result, routeName: state.routeName };
|
||||
|
||||
@@ -775,7 +775,7 @@ describe('TabRouter', () => {
|
||||
routes: [screenApreState],
|
||||
};
|
||||
|
||||
const comparable = state => {
|
||||
const comparable = (state) => {
|
||||
let result = {};
|
||||
if (typeof state.routeName === 'string') {
|
||||
result = { ...result, routeName: state.routeName };
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getRouterTestHelper = (router, options = defaultOptions) => {
|
||||
? undefined
|
||||
: router.getStateForAction({ type: NavigationActions.INIT });
|
||||
|
||||
const applyAction = action => {
|
||||
const applyAction = (action) => {
|
||||
state = router.getStateForAction(action, state);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ export const getRouterTestHelper = (router, options = defaultOptions) => {
|
||||
...otherActionAttributes,
|
||||
});
|
||||
|
||||
const back = key =>
|
||||
const back = (key) =>
|
||||
applyAction({
|
||||
type: NavigationActions.BACK,
|
||||
key,
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function getScreenForRouteName(routeConfigs, routeName) {
|
||||
throw new Error(
|
||||
`There is no route defined for key ${routeName}.\n` +
|
||||
`Must be one of: ${Object.keys(routeConfigs)
|
||||
.map(a => `'${a}'`)
|
||||
.map((a) => `'${a}'`)
|
||||
.join(',')}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export const getParamsFromPath = (inputParams, pathMatch, pathMatchKeys) => {
|
||||
return params;
|
||||
};
|
||||
const getRestOfPath = (pathMatch, pathMatchKeys) => {
|
||||
const rest = pathMatch[pathMatchKeys.findIndex(k => k.asterisk) + 1];
|
||||
const rest = pathMatch[pathMatchKeys.findIndex((k) => k.asterisk) + 1];
|
||||
return rest;
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ export const createPathParser = (
|
||||
let paths = [];
|
||||
|
||||
// Build pathsByRouteNames, which includes a regex to match paths for each route. Keep in mind, the regex will pass for the route and all child routes. The code that uses pathsByRouteNames will need to also verify that the child router produces an action, in the case of isPathMatchable false (a null path).
|
||||
Object.keys(childRouters).forEach(routeName => {
|
||||
Object.keys(childRouters).forEach((routeName) => {
|
||||
let pathPattern;
|
||||
|
||||
// First check for paths on the router, then check the route config
|
||||
@@ -189,7 +189,7 @@ export const createPathParser = (
|
||||
|
||||
return null;
|
||||
};
|
||||
const getPathAndParamsForRoute = route => {
|
||||
const getPathAndParamsForRoute = (route) => {
|
||||
const { routeName, params } = route;
|
||||
const childRouter = childRouters[routeName];
|
||||
const { toPath, exactReKeys } = pathsByRouteNames[routeName];
|
||||
@@ -197,8 +197,8 @@ export const createPathParser = (
|
||||
const nonPathParams = {};
|
||||
if (params) {
|
||||
Object.keys(params)
|
||||
.filter(paramName => !exactReKeys.find(k => k.name === paramName))
|
||||
.forEach(paramName => {
|
||||
.filter((paramName) => !exactReKeys.find((k) => k.name === paramName))
|
||||
.forEach((paramName) => {
|
||||
nonPathParams[paramName] = params[paramName];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function validateRouteConfigMap(routeConfigs) {
|
||||
'Please specify at least one route when configuring a navigator.'
|
||||
);
|
||||
|
||||
routeNames.forEach(routeName => {
|
||||
routeNames.forEach((routeName) => {
|
||||
const routeConfig = routeConfigs[routeName];
|
||||
const screenComponent = getScreenComponent(routeConfig);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const deprecatedKeys = ['tabBar'];
|
||||
export default (screenOptions, route) => {
|
||||
const keys = Object.keys(screenOptions);
|
||||
|
||||
const deprecatedKey = keys.find(key => deprecatedKeys.includes(key));
|
||||
const deprecatedKey = keys.find((key) => deprecatedKeys.includes(key));
|
||||
|
||||
if (typeof screenOptions.title === 'function') {
|
||||
throw new Error(
|
||||
@@ -54,7 +54,7 @@ export default (screenOptions, route) => {
|
||||
'{',
|
||||
` ${deprecatedKey}: {`,
|
||||
...Object.keys(screenOptions[deprecatedKey]).map(
|
||||
key => ` ${key}: ...,`
|
||||
(key) => ` ${key}: ...,`
|
||||
),
|
||||
' },',
|
||||
'}',
|
||||
@@ -62,7 +62,7 @@ export default (screenOptions, route) => {
|
||||
'with:',
|
||||
'{',
|
||||
...Object.keys(screenOptions[deprecatedKey]).map(
|
||||
key =>
|
||||
(key) =>
|
||||
` ${deprecatedKey + key[0].toUpperCase() + key.slice(1)}: ...,`
|
||||
),
|
||||
'}',
|
||||
|
||||
@@ -5,8 +5,10 @@ function getSceneIndicesForInterpolationInputRange(props) {
|
||||
const isBack = !scenes[lastSceneIndexInScenes].isActive;
|
||||
|
||||
if (isBack) {
|
||||
const currentSceneIndexInScenes = scenes.findIndex(item => item === scene);
|
||||
const targetSceneIndexInScenes = scenes.findIndex(item => item.isActive);
|
||||
const currentSceneIndexInScenes = scenes.findIndex(
|
||||
(item) => item === scene
|
||||
);
|
||||
const targetSceneIndexInScenes = scenes.findIndex((item) => item.isActive);
|
||||
const targetSceneIndex = scenes[targetSceneIndexInScenes].index;
|
||||
const lastSceneIndex = scenes[lastSceneIndexInScenes].index;
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
* will remain to ensure logic does not differ in production.
|
||||
*/
|
||||
|
||||
let validateFormat: (format?: string) => void = function() {};
|
||||
let validateFormat: (format?: string) => void = function () {};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateFormat = function(format?: string) {
|
||||
validateFormat = function (format?: string) {
|
||||
if (format === undefined) {
|
||||
throw new Error('invariant requires an error message argument');
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class NavigationEvents extends React.Component {
|
||||
// We register all navigation listeners on mount to ensure listener stability across re-render
|
||||
// A former implementation was replacing (removing/adding) listeners on all update (if prop provided)
|
||||
// but there were issues (see https://github.com/react-navigation/react-navigation/issues/5058)
|
||||
EventNames.forEach(eventName => {
|
||||
EventNames.forEach((eventName) => {
|
||||
this.subscriptions[eventName] = this.props.navigation.addListener(
|
||||
eventName,
|
||||
(...args) => {
|
||||
@@ -29,12 +29,12 @@ class NavigationEvents extends React.Component {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
EventNames.forEach(eventName => {
|
||||
EventNames.forEach((eventName) => {
|
||||
this.subscriptions[eventName].remove();
|
||||
});
|
||||
}
|
||||
|
||||
getPropListener = eventName => this.props[EventNameToPropName[eventName]];
|
||||
getPropListener = (eventName) => this.props[EventNameToPropName[eventName]];
|
||||
|
||||
render() {
|
||||
return null;
|
||||
|
||||
@@ -26,13 +26,15 @@ const createTestNavigationAndHelpers = () => {
|
||||
listeners[eventName].push(handler);
|
||||
},
|
||||
remove: (eventName, handler) => {
|
||||
listeners[eventName] = listeners[eventName].filter(h => h !== handler);
|
||||
listeners[eventName] = listeners[eventName].filter(
|
||||
(h) => h !== handler
|
||||
);
|
||||
},
|
||||
get: eventName => {
|
||||
get: (eventName) => {
|
||||
return listeners[eventName];
|
||||
},
|
||||
call: eventName => {
|
||||
listeners[eventName].forEach(listener => listener());
|
||||
call: (eventName) => {
|
||||
listeners[eventName].forEach((listener) => listener());
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -8,14 +8,15 @@ export default function withNavigation(
|
||||
config = { forwardRef: true }
|
||||
) {
|
||||
class ComponentWithNavigation extends React.Component {
|
||||
static displayName = `withNavigation(${Component.displayName ||
|
||||
Component.name})`;
|
||||
static displayName = `withNavigation(${
|
||||
Component.displayName || Component.name
|
||||
})`;
|
||||
|
||||
render() {
|
||||
const navigationProp = this.props.navigation;
|
||||
return (
|
||||
<NavigationContext.Consumer>
|
||||
{navigationContext => {
|
||||
{(navigationContext) => {
|
||||
const navigation = navigationProp || navigationContext;
|
||||
invariant(
|
||||
!!navigation,
|
||||
|
||||
@@ -4,8 +4,9 @@ import withNavigation from './withNavigation';
|
||||
|
||||
export default function withNavigationFocus(Component) {
|
||||
class ComponentWithNavigationFocus extends React.Component {
|
||||
static displayName = `withNavigationFocus(${Component.displayName ||
|
||||
Component.name})`;
|
||||
static displayName = `withNavigationFocus(${
|
||||
Component.displayName || Component.name
|
||||
})`;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -25,7 +26,7 @@ export default function withNavigationFocus(Component) {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscriptions.forEach(sub => sub.remove());
|
||||
this.subscriptions.forEach((sub) => sub.remove());
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.4.7](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.6...react-navigation-drawer@2.4.7) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.4.6](https://github.com/react-navigation/drawer/compare/react-navigation-drawer@2.4.5...react-navigation-drawer@2.4.6) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-drawer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-drawer",
|
||||
"version": "2.4.6",
|
||||
"version": "2.4.7",
|
||||
"description": "Drawer navigator component for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -49,7 +49,7 @@
|
||||
"react-native-reanimated": "^1.2.0",
|
||||
"react-native-screens": "^2.3.0",
|
||||
"react-native-testing-library": "^1.12.0",
|
||||
"react-navigation": "^4.3.2",
|
||||
"react-navigation": "^4.3.3",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.2.6](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.5...react-navigation-material-bottom-tabs@2.2.6) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.5](https://github.com/react-navigation/react-navigation-material-bottom-tabs/compare/react-navigation-material-bottom-tabs@2.2.4...react-navigation-material-bottom-tabs@2.2.5) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-material-bottom-tabs
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-material-bottom-tabs",
|
||||
"version": "2.2.5",
|
||||
"version": "2.2.6",
|
||||
"description": "Material Bottom Tab Navigation component for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"module": "lib/module/index.js",
|
||||
@@ -48,7 +48,7 @@
|
||||
"react-native-gesture-handler": "^1.6.0",
|
||||
"react-native-paper": "^3.1.1",
|
||||
"react-native-reanimated": "^1.2.0",
|
||||
"react-navigation": "^4.3.2",
|
||||
"react-navigation": "^4.3.3",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.7.7](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.6...@react-navigation/native@3.7.7) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.7.6](https://github.com/react-navigation/react-navigation-native/compare/@react-navigation/native@3.7.5...@react-navigation/native@3.7.6) (2020-03-20)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@react-navigation/native",
|
||||
"version": "3.7.6",
|
||||
"version": "3.7.7",
|
||||
"description": "React Native support for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "lib/module/index.js",
|
||||
@@ -15,7 +15,8 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
"access": "public",
|
||||
"tag": "4.x"
|
||||
},
|
||||
"keywords": [
|
||||
"react-native",
|
||||
@@ -39,7 +40,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.10.0",
|
||||
"@react-navigation/core": "^3.7.0",
|
||||
"@react-navigation/core": "^3.7.1",
|
||||
"@types/react-test-renderer": "^16.9.2",
|
||||
"del-cli": "^3.0.0",
|
||||
"react": "~16.9.0",
|
||||
|
||||
@@ -52,7 +52,7 @@ const WrappedFlatList = React.forwardRef((props, ref) => (
|
||||
<FlatList
|
||||
ref={ref}
|
||||
{...props}
|
||||
renderScrollComponent={props => (
|
||||
renderScrollComponent={(props) => (
|
||||
<WrappedScrollView {...propsMaybeWithRefreshControl(props)} />
|
||||
)}
|
||||
/>
|
||||
@@ -62,7 +62,7 @@ const WrappedSectionList = React.forwardRef((props, ref) => (
|
||||
<SectionList
|
||||
ref={ref}
|
||||
{...props}
|
||||
renderScrollComponent={props => (
|
||||
renderScrollComponent={(props) => (
|
||||
<WrappedScrollView {...propsMaybeWithRefreshControl(props)} />
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -274,7 +274,7 @@ describe('NavigationContainer', () => {
|
||||
});
|
||||
|
||||
// https://github.com/facebook/jest/issues/2157#issuecomment-279171856
|
||||
const flushPromises = () => new Promise(resolve => setImmediate(resolve));
|
||||
const flushPromises = () => new Promise((resolve) => setImmediate(resolve));
|
||||
|
||||
describe('state persistence', () => {
|
||||
async function createPersistenceEnabledContainer(
|
||||
|
||||
@@ -266,7 +266,7 @@ export default function createNavigationContainer(Component) {
|
||||
}
|
||||
|
||||
const dispatchActions = () =>
|
||||
this._actionEventSubscribers.forEach(subscriber =>
|
||||
this._actionEventSubscribers.forEach((subscriber) =>
|
||||
subscriber({
|
||||
type: 'action',
|
||||
action,
|
||||
@@ -316,7 +316,7 @@ export default function createNavigationContainer(Component) {
|
||||
}
|
||||
}
|
||||
|
||||
_persistNavigationState = async nav => {
|
||||
_persistNavigationState = async (nav) => {
|
||||
const { persistNavigationState } = this.props;
|
||||
if (persistNavigationState) {
|
||||
try {
|
||||
@@ -341,7 +341,7 @@ export default function createNavigationContainer(Component) {
|
||||
|
||||
// Per-tick temporary storage for state.nav
|
||||
|
||||
dispatch = action => {
|
||||
dispatch = (action) => {
|
||||
if (this.props.navigation) {
|
||||
return this.props.navigation.dispatch(action);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ export default function createNavigationContainer(Component) {
|
||||
const navState = reducedState === null ? lastNavState : reducedState;
|
||||
|
||||
const dispatchActionEvents = () => {
|
||||
this._actionEventSubscribers.forEach(subscriber =>
|
||||
this._actionEventSubscribers.forEach((subscriber) =>
|
||||
subscriber({
|
||||
type: 'action',
|
||||
action,
|
||||
|
||||
@@ -5,8 +5,9 @@ import { withNavigation } from '@react-navigation/core';
|
||||
export default function createNavigationAwareScrollable(Component) {
|
||||
const ComponentWithNavigationScrolling = withNavigation(
|
||||
class extends React.PureComponent<any> {
|
||||
static displayName = `withNavigationScrolling(${Component.displayName ||
|
||||
Component.name})`;
|
||||
static displayName = `withNavigationScrolling(${
|
||||
Component.displayName || Component.name
|
||||
})`;
|
||||
|
||||
componentDidMount() {
|
||||
this._subscription = this.props.navigation.addListener(
|
||||
@@ -49,7 +50,7 @@ export default function createNavigationAwareScrollable(Component) {
|
||||
render() {
|
||||
return (
|
||||
<Component
|
||||
ref={view => {
|
||||
ref={(view) => {
|
||||
this._scrollRef = view;
|
||||
}}
|
||||
{...this.props}
|
||||
@@ -60,10 +61,11 @@ export default function createNavigationAwareScrollable(Component) {
|
||||
);
|
||||
|
||||
class NavigationAwareScrollable extends React.PureComponent<any> {
|
||||
static displayName = `NavigationAwareScrollable(${Component.displayName ||
|
||||
Component.name})`;
|
||||
static displayName = `NavigationAwareScrollable(${
|
||||
Component.displayName || Component.name
|
||||
})`;
|
||||
|
||||
_captureRef = view => {
|
||||
_captureRef = (view) => {
|
||||
this._innerRef = view;
|
||||
this.props.onRef && this.props.onRef(view);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function() {
|
||||
export default function () {
|
||||
throw new Error(
|
||||
"This version of '@react-navigation/native' is not compatible with React Navigation 5. Make sure you install 5.x version of '@react-navigation/native'."
|
||||
);
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
* will remain to ensure logic does not differ in production.
|
||||
*/
|
||||
|
||||
var validateFormat = function() {};
|
||||
var validateFormat = function () {};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateFormat = function(format) {
|
||||
validateFormat = function (format) {
|
||||
if (format === undefined) {
|
||||
throw new Error('invariant requires an error message argument');
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export default function invariant(condition, format, a, b, c, d, e, f) {
|
||||
var args = [a, b, c, d, e, f];
|
||||
var argIndex = 0;
|
||||
error = new Error(
|
||||
format.replace(/%s/g, function() {
|
||||
format.replace(/%s/g, function () {
|
||||
return args[argIndex++];
|
||||
})
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ import hoistNonReactStatic from 'hoist-non-react-statics';
|
||||
|
||||
export const isOrientationLandscape = ({ width, height }) => width > height;
|
||||
|
||||
export default function(WrappedComponent) {
|
||||
export default function (WrappedComponent) {
|
||||
class withOrientation extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [4.3.3](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.2...react-navigation@4.3.3) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.3.2](https://github.com/react-navigation/react-navigation/compare/react-navigation@4.3.1...react-navigation@4.3.2) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation",
|
||||
"version": "4.3.2",
|
||||
"version": "4.3.3",
|
||||
"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.0",
|
||||
"@react-navigation/native": "^3.7.6"
|
||||
"@react-navigation/core": "^3.7.1",
|
||||
"@react-navigation/native": "^3.7.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.9.23",
|
||||
|
||||
@@ -3,6 +3,30 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.3.7](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.6...react-navigation-stack@2.3.7) (2020-03-27)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.6](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.5...react-navigation-stack@2.3.6) (2020-03-23)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.5](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.4...react-navigation-stack@2.3.5) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.4](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.3.3...react-navigation-stack@2.3.4) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-stack
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-stack",
|
||||
"version": "2.3.4",
|
||||
"version": "2.3.7",
|
||||
"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.3",
|
||||
"@react-navigation/stack": "^5.2.7",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.23",
|
||||
"@types/react-native": "^0.61.22",
|
||||
@@ -56,7 +56,7 @@
|
||||
"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.2",
|
||||
"react-navigation": "^4.3.3",
|
||||
"react-test-renderer": "~16.9.0",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
|
||||
@@ -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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/index.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/index.tsx 2020-03-23 00:04:37.000000000 +0100
|
||||
@@ -3,11 +3,6 @@
|
||||
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
||||
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
|
||||
@@ -28,7 +28,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
|
||||
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-19 20:09:01.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
|
||||
@@ -1,81 +0,0 @@
|
||||
-import * as React from 'react';
|
||||
@@ -73,7 +73,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
- React.useEffect(
|
||||
- () =>
|
||||
- navigation.addListener &&
|
||||
- navigation.addListener('tabPress', e => {
|
||||
- navigation.addListener('tabPress', (e) => {
|
||||
- const isFocused = navigation.isFocused();
|
||||
-
|
||||
- // Run the operation in the next frame so we're sure all listeners have been run
|
||||
@@ -113,8 +113,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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/types.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/types.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -8,14 +8,28 @@
|
||||
} from 'react-native';
|
||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
||||
@@ -240,8 +240,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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -1,12 +1,14 @@
|
||||
import * as React from 'react';
|
||||
-import { StackActions } from '@react-navigation/native';
|
||||
@@ -321,8 +321,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
||||
+
|
||||
+export default Header;
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-03-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -8,9 +8,9 @@
|
||||
StyleSheet,
|
||||
LayoutChangeEvent,
|
||||
@@ -335,8 +335,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
|
||||
|
||||
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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, StyleSheet, Platform, ViewProps } from 'react-native';
|
||||
@@ -346,8 +346,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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -1,11 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
@@ -399,8 +399,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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -8,7 +8,7 @@
|
||||
ViewStyle,
|
||||
} from 'react-native';
|
||||
@@ -420,8 +420,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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, StyleSheet, Platform } from 'react-native';
|
||||
@@ -431,8 +431,8 @@ 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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
private interactionHandle: number | undefined;
|
||||
@@ -443,8 +443,8 @@ 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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -1,10 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
@@ -500,8 +500,8 @@ 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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-03-23 00:04:40.000000000 +0100
|
||||
@@ -9,9 +9,8 @@
|
||||
ViewProps,
|
||||
} from 'react-native';
|
||||
@@ -546,8 +546,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.
|
||||
onTransitionEnd={onTransitionEnd}
|
||||
gestureEnabled={index !== 0 && getGesturesEnabled({ route })}
|
||||
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-19 20:09:01.000000000 +0100
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-03-19 20:09:16.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-03-23 00:04:17.000000000 +0100
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-03-23 00:07:11.000000000 +0100
|
||||
@@ -4,9 +4,9 @@
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import {
|
||||
@@ -613,10 +613,10 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
+
|
||||
private handleOpenRoute = ({ route }: { route: Route<string> }) => {
|
||||
+ this.handleTransitionComplete({ route });
|
||||
this.setState(state => ({
|
||||
this.setState((state) => ({
|
||||
routes: state.replacingRouteKeys.length
|
||||
? state.routes.filter(r => !state.replacingRouteKeys.includes(r.key))
|
||||
@@ -315,12 +340,17 @@
|
||||
? state.routes.filter((r) => !state.replacingRouteKeys.includes(r.key))
|
||||
@@ -319,12 +344,17 @@
|
||||
// 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
|
||||
@@ -630,16 +630,16 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
} 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);
|
||||
+ const index = this.state.routes.findIndex((r) => r.key === route.key);
|
||||
+
|
||||
+ this.handleTransitionComplete({
|
||||
+ route: this.state.routes[Math.max(index - 1, 0)],
|
||||
+ });
|
||||
+
|
||||
// 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),
|
||||
@@ -337,22 +367,24 @@
|
||||
this.setState((state) => ({
|
||||
routes: state.routes.filter((r) => r.key !== route.key),
|
||||
@@ -341,22 +371,24 @@
|
||||
private handleTransitionStart = (
|
||||
{ route }: { route: Route<string> },
|
||||
closing: boolean
|
||||
@@ -676,7 +676,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.
|
||||
|
||||
render() {
|
||||
const {
|
||||
@@ -391,6 +423,7 @@
|
||||
@@ -395,6 +427,7 @@
|
||||
closingRouteKeys={closingRouteKeys}
|
||||
onOpenRoute={this.handleOpenRoute}
|
||||
onCloseRoute={this.handleCloseRoute}
|
||||
|
||||
@@ -30,7 +30,7 @@ function createStackNavigator(
|
||||
return createNavigator(
|
||||
// TODO: don't have time to fix it right now
|
||||
// @ts-ignore
|
||||
navigatorProps => <StackView {...navigatorProps} />,
|
||||
(navigatorProps) => <StackView {...navigatorProps} />,
|
||||
router,
|
||||
stackConfig
|
||||
);
|
||||
|
||||
@@ -58,7 +58,7 @@ export default function validateDeprecatedConfig(
|
||||
) {
|
||||
let result = options;
|
||||
|
||||
Object.keys(validations).forEach(name => {
|
||||
Object.keys(validations).forEach((name) => {
|
||||
if (name in config) {
|
||||
const { compat, message } = validations[name];
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ const shownWarnings: string[] = [];
|
||||
|
||||
const validations: Validation[] = [
|
||||
{
|
||||
check: o => typeof o.headerForceInset === 'object',
|
||||
check: (o) => typeof o.headerForceInset === 'object',
|
||||
deprecated: 'headerForceInset',
|
||||
updated: 'safeAreaInsets',
|
||||
compat: o => {
|
||||
compat: (o) => {
|
||||
const { headerForceInset, ...rest } = o;
|
||||
|
||||
let safeAreaInsets: Partial<EdgeInsets> | undefined = {
|
||||
@@ -55,20 +55,20 @@ const validations: Validation[] = [
|
||||
},
|
||||
},
|
||||
{
|
||||
check: o => o.gesturesEnabled !== undefined,
|
||||
check: (o) => o.gesturesEnabled !== undefined,
|
||||
deprecated: 'gesturesEnabled',
|
||||
updated: 'gestureEnabled',
|
||||
compat: o => {
|
||||
compat: (o) => {
|
||||
const { gesturesEnabled, ...rest } = o;
|
||||
|
||||
return { ...rest, gestureEnabled: gesturesEnabled };
|
||||
},
|
||||
},
|
||||
{
|
||||
check: o => o.header === null,
|
||||
check: (o) => o.header === null,
|
||||
deprecated: 'header: null',
|
||||
updated: 'headerShown: false',
|
||||
compat: o => {
|
||||
compat: (o) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { header, ...rest } = o;
|
||||
|
||||
@@ -76,26 +76,26 @@ const validations: Validation[] = [
|
||||
},
|
||||
},
|
||||
{
|
||||
check: o => o.header != null && typeof o.header !== 'function',
|
||||
check: (o) => o.header != null && typeof o.header !== 'function',
|
||||
deprecated: 'header: <SomeElement />',
|
||||
updated: 'header: () => <SomeElement />',
|
||||
compat: o => ({ ...o, header: () => o.header }),
|
||||
compat: (o) => ({ ...o, header: () => o.header }),
|
||||
},
|
||||
{
|
||||
check: o =>
|
||||
check: (o) =>
|
||||
o.headerTitle !== undefined &&
|
||||
typeof o.headerTitle !== 'string' &&
|
||||
typeof o.headerTitle !== 'function',
|
||||
deprecated: 'headerTitle: <SomeElement />',
|
||||
updated: 'headerTitle: () => <SomeElement />',
|
||||
compat: o => ({ ...o, headerTitle: () => o.headerTitle }),
|
||||
compat: (o) => ({ ...o, headerTitle: () => o.headerTitle }),
|
||||
},
|
||||
...['headerLeft', 'headerRight', 'headerBackground', 'headerBackImage'].map(
|
||||
(p): Validation => ({
|
||||
check: (o: any) => o[p] !== undefined && typeof o[p] !== 'function',
|
||||
deprecated: `${p}: <SomeElement />`,
|
||||
updated: `${p}: () => <SomeElement />`,
|
||||
compat: o => ({ ...o, [p]: () => o[p] }),
|
||||
compat: (o) => ({ ...o, [p]: () => o[p] }),
|
||||
})
|
||||
),
|
||||
];
|
||||
@@ -108,7 +108,7 @@ export default function validateDeprecatedOptions(
|
||||
const warnings: Validation[] = [];
|
||||
|
||||
// Validate options to show warnings for deprecations
|
||||
validations.forEach(v => {
|
||||
validations.forEach((v) => {
|
||||
if (v.check(options)) {
|
||||
result = v.compat(result);
|
||||
|
||||
@@ -127,7 +127,7 @@ export default function validateDeprecatedOptions(
|
||||
console.warn(
|
||||
`Deprecation in 'navigationOptions':\n${warnings
|
||||
.map(
|
||||
v =>
|
||||
(v) =>
|
||||
`- '${v.deprecated}' will be removed in a future version. Use '${v.updated}' instead`
|
||||
)
|
||||
.join('\n')}`
|
||||
|
||||
2
packages/stack/src/vendor/utils/debounce.tsx
vendored
2
packages/stack/src/vendor/utils/debounce.tsx
vendored
@@ -4,7 +4,7 @@ export default function debounce<T extends (...args: any[]) => void>(
|
||||
): T {
|
||||
let timeout: NodeJS.Timeout | number | undefined;
|
||||
|
||||
return function(this: any, ...args) {
|
||||
return function (this: any, ...args) {
|
||||
if (!timeout) {
|
||||
// eslint-disable-next-line babel/no-invalid-this
|
||||
func.apply(this, args);
|
||||
|
||||
@@ -118,7 +118,7 @@ export default function HeaderContainer({
|
||||
<View
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
? e =>
|
||||
? (e) =>
|
||||
onContentHeightChange({
|
||||
route: scene.route,
|
||||
height: e.nativeEvent.layout.height,
|
||||
|
||||
@@ -38,7 +38,7 @@ type State = {
|
||||
};
|
||||
|
||||
const warnIfHeaderStylesDefined = (styles: Record<string, any>) => {
|
||||
Object.keys(styles).forEach(styleProp => {
|
||||
Object.keys(styles).forEach((styleProp) => {
|
||||
const value = styles[styleProp];
|
||||
|
||||
if (styleProp === 'position' && value === 'absolute') {
|
||||
|
||||
@@ -30,7 +30,7 @@ type Props = {
|
||||
export default function SafeAreaProviderCompat({ children }: Props) {
|
||||
return (
|
||||
<SafeAreaConsumer>
|
||||
{insets => {
|
||||
{(insets) => {
|
||||
if (insets) {
|
||||
// If we already have insets, don't wrap the stack in another safe area provider
|
||||
// This avoids an issue with updates at the cost of potentially incorrect values
|
||||
|
||||
11
packages/stack/src/vendor/views/Stack/Card.tsx
vendored
11
packages/stack/src/vendor/views/Stack/Card.tsx
vendored
@@ -271,14 +271,9 @@ export default class Card extends React.Component<Props> {
|
||||
velocity = nativeEvent.velocityX;
|
||||
}
|
||||
|
||||
const gestureDirectionFactor =
|
||||
gestureDirection === 'horizontal' || gestureDirection === 'vertical'
|
||||
? 1
|
||||
: -1;
|
||||
|
||||
const closing =
|
||||
gestureDirectionFactor *
|
||||
(translation + velocity * gestureVelocityImpact) >
|
||||
(translation + velocity * gestureVelocityImpact) *
|
||||
getInvertedMultiplier(gestureDirection) >
|
||||
distance / 2
|
||||
? velocity !== 0 || translation !== 0
|
||||
: false;
|
||||
@@ -485,7 +480,7 @@ export default class Card extends React.Component<Props> {
|
||||
<CardAnimationContext.Provider value={animationContext}>
|
||||
<View pointerEvents="box-none" {...rest}>
|
||||
{overlayEnabled ? (
|
||||
<View style={StyleSheet.absoluteFill}>
|
||||
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
||||
{overlay({ style: overlayStyle })}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
@@ -117,7 +117,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.find((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
|
||||
|
||||
@@ -130,17 +130,17 @@ export default class StackView extends React.Component<Props, State> {
|
||||
openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];
|
||||
|
||||
closingRouteKeys = closingRouteKeys.filter(
|
||||
key => key !== nextFocusedRoute.key
|
||||
(key) => key !== nextFocusedRoute.key
|
||||
);
|
||||
replacingRouteKeys = replacingRouteKeys.filter(
|
||||
key => key !== nextFocusedRoute.key
|
||||
(key) => key !== nextFocusedRoute.key
|
||||
);
|
||||
|
||||
if (!routes.find(r => r.key === previousFocusedRoute.key)) {
|
||||
if (!routes.find((r) => r.key === previousFocusedRoute.key)) {
|
||||
// The previous focused route isn't present in state, we treat this as a replace
|
||||
|
||||
openingRouteKeys = openingRouteKeys.filter(
|
||||
key => key !== previousFocusedRoute.key
|
||||
(key) => key !== previousFocusedRoute.key
|
||||
);
|
||||
|
||||
if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {
|
||||
@@ -153,7 +153,7 @@ export default class StackView extends React.Component<Props, State> {
|
||||
// But since user configured it to animate the old screen like a pop, we need to add this without animation
|
||||
// So remove it from `openingRouteKeys` which will remove the animation
|
||||
openingRouteKeys = openingRouteKeys.filter(
|
||||
key => key !== nextFocusedRoute.key
|
||||
(key) => key !== nextFocusedRoute.key
|
||||
);
|
||||
|
||||
// Keep the route being removed at the end to animate it out
|
||||
@@ -165,7 +165,7 @@ export default class StackView extends React.Component<Props, State> {
|
||||
];
|
||||
|
||||
closingRouteKeys = closingRouteKeys.filter(
|
||||
key => key !== previousFocusedRoute.key
|
||||
(key) => key !== previousFocusedRoute.key
|
||||
);
|
||||
|
||||
// Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt
|
||||
@@ -176,7 +176,7 @@ export default class StackView extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!routes.find(r => r.key === previousFocusedRoute.key)) {
|
||||
} else if (!routes.find((r) => r.key === previousFocusedRoute.key)) {
|
||||
// The previously focused route was removed, we treat this as a pop
|
||||
|
||||
if (
|
||||
@@ -188,10 +188,10 @@ export default class StackView extends React.Component<Props, State> {
|
||||
// Sometimes a route can be closed before the opening animation finishes
|
||||
// So we also need to remove it from the opening list
|
||||
openingRouteKeys = openingRouteKeys.filter(
|
||||
key => key !== previousFocusedRoute.key
|
||||
(key) => key !== previousFocusedRoute.key
|
||||
);
|
||||
replacingRouteKeys = replacingRouteKeys.filter(
|
||||
key => key !== previousFocusedRoute.key
|
||||
(key) => key !== previousFocusedRoute.key
|
||||
);
|
||||
|
||||
// Keep a copy of route being removed in the state to be able to animate it
|
||||
@@ -273,13 +273,13 @@ export default class StackView extends React.Component<Props, State> {
|
||||
private getPreviousRoute = ({ route }: { route: Route<string> }) => {
|
||||
const { closingRouteKeys, replacingRouteKeys } = this.state;
|
||||
const routes = this.state.routes.filter(
|
||||
r =>
|
||||
(r) =>
|
||||
r.key === route.key ||
|
||||
(!closingRouteKeys.includes(r.key) &&
|
||||
!replacingRouteKeys.includes(r.key))
|
||||
);
|
||||
|
||||
const index = routes.findIndex(r => r.key === route.key);
|
||||
const index = routes.findIndex((r) => r.key === route.key);
|
||||
|
||||
return routes[index - 1];
|
||||
};
|
||||
@@ -323,12 +323,16 @@ export default class StackView extends React.Component<Props, State> {
|
||||
|
||||
private handleOpenRoute = ({ route }: { route: Route<string> }) => {
|
||||
this.handleTransitionComplete({ route });
|
||||
this.setState(state => ({
|
||||
this.setState((state) => ({
|
||||
routes: state.replacingRouteKeys.length
|
||||
? state.routes.filter(r => !state.replacingRouteKeys.includes(r.key))
|
||||
? 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),
|
||||
openingRouteKeys: state.openingRouteKeys.filter(
|
||||
(key) => key !== route.key
|
||||
),
|
||||
closingRouteKeys: state.closingRouteKeys.filter(
|
||||
(key) => key !== route.key
|
||||
),
|
||||
replacingRouteKeys: [],
|
||||
}));
|
||||
};
|
||||
@@ -336,7 +340,7 @@ export default class StackView extends React.Component<Props, State> {
|
||||
private handleCloseRoute = ({ route }: { route: Route<string> }) => {
|
||||
const { state, navigation } = this.props;
|
||||
|
||||
if (state.routes.find(r => r.key === route.key)) {
|
||||
if (state.routes.find((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
|
||||
@@ -345,20 +349,20 @@ export default class StackView extends React.Component<Props, State> {
|
||||
} 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);
|
||||
const index = this.state.routes.findIndex((r) => r.key === route.key);
|
||||
|
||||
this.handleTransitionComplete({
|
||||
route: this.state.routes[Math.max(index - 1, 0)],
|
||||
});
|
||||
|
||||
// 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),
|
||||
this.setState((state) => ({
|
||||
routes: state.routes.filter((r) => r.key !== route.key),
|
||||
openingRouteKeys: state.openingRouteKeys.filter(
|
||||
key => key !== route.key
|
||||
(key) => key !== route.key
|
||||
),
|
||||
closingRouteKeys: state.closingRouteKeys.filter(
|
||||
key => key !== route.key
|
||||
(key) => key !== route.key
|
||||
),
|
||||
}));
|
||||
}
|
||||
@@ -410,9 +414,9 @@ export default class StackView extends React.Component<Props, State> {
|
||||
<GestureHandlerWrapper style={styles.container}>
|
||||
<SafeAreaProviderCompat>
|
||||
<SafeAreaConsumer>
|
||||
{insets => (
|
||||
{(insets) => (
|
||||
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
|
||||
{props => (
|
||||
{(props) => (
|
||||
<CardStack
|
||||
mode={mode}
|
||||
insets={insets as EdgeInsets}
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.8.7](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.6...react-navigation-tabs@2.8.7) (2020-03-22)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.6](https://github.com/react-navigation/tabs/compare/react-navigation-tabs@2.8.5...react-navigation-tabs@2.8.6) (2020-03-20)
|
||||
|
||||
**Note:** Version bump only for package react-navigation-tabs
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation-tabs",
|
||||
"version": "2.8.6",
|
||||
"version": "2.8.7",
|
||||
"description": "Tab Navigation components for React Navigation",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"module": "lib/module/index.js",
|
||||
@@ -56,7 +56,7 @@
|
||||
"react-native-gesture-handler": "^1.6.0",
|
||||
"react-native-reanimated": "^1.2.0",
|
||||
"react-native-tab-view": "^2.13.0",
|
||||
"react-navigation": "^4.3.2",
|
||||
"react-navigation": "^4.3.3",
|
||||
"typescript": "~3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -131,7 +131,9 @@ class TabNavigationView extends React.PureComponent<Props, State> {
|
||||
_jumpTo = (key: string) => {
|
||||
const { navigation, onIndexChange } = this.props;
|
||||
|
||||
const index = navigation.state.routes.findIndex(route => route.key === key);
|
||||
const index = navigation.state.routes.findIndex(
|
||||
(route) => route.key === key
|
||||
);
|
||||
|
||||
onIndexChange(index);
|
||||
};
|
||||
|
||||
@@ -134,12 +134,12 @@ class MaterialTabView extends React.PureComponent<Props> {
|
||||
renderTabBar={this.renderTabBar}
|
||||
renderLazyPlaceholder={
|
||||
lazyPlaceholderComponent !== undefined
|
||||
? props => React.createElement(lazyPlaceholderComponent, props)
|
||||
? (props) => React.createElement(lazyPlaceholderComponent, props)
|
||||
: undefined
|
||||
}
|
||||
renderPager={
|
||||
pagerComponent !== undefined
|
||||
? props => React.createElement(pagerComponent, props)
|
||||
? (props) => React.createElement(pagerComponent, props)
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ const packages = path.join(__dirname, '..', 'packages');
|
||||
|
||||
const invalid = [];
|
||||
|
||||
fs.readdirSync(packages).forEach(name => {
|
||||
fs.readdirSync(packages).forEach((name) => {
|
||||
const dir = path.join(packages, name);
|
||||
|
||||
if (fs.statSync(path.join(packages, name)).isDirectory()) {
|
||||
@@ -26,6 +26,6 @@ fs.readdirSync(packages).forEach(name => {
|
||||
if (invalid.length) {
|
||||
console.log(
|
||||
'Found invalid path to type definitions in the following packages:\n',
|
||||
invalid.map(p => `- ${p.name} (${p.types})`).join('\n')
|
||||
invalid.map((p) => `- ${p.name} (${p.types})`).join('\n')
|
||||
);
|
||||
}
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@@ -3268,10 +3268,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.7.tgz#a65ce0702f55cb67fd777995de6fc7b3e5781903"
|
||||
integrity sha512-9KbP7LTLFz9dx1heURJbO6nuVMdSjDez8znlrUzaB1nUwKVsTTwlKRuHxGUYIIkReLWrJQeCv9tidy+84z2eCw==
|
||||
|
||||
"@react-navigation/stack@^5.2.3":
|
||||
version "5.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.2.3.tgz#2c92ee6f0a032720960acfa037e13061c378781e"
|
||||
integrity sha512-mCji6N6r03sTMF09hbVmhdCZHcuIrZCr/MY8yuiG+kzzYcFfj+72wwJ885erKw32jBKAaJV8wZNq8W0K+ZiCQQ==
|
||||
"@react-navigation/stack@^5.2.7":
|
||||
version "5.2.7"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.2.7.tgz#859e6faa3e350d5bd5d7d63ee066c92f6b82aa0a"
|
||||
integrity sha512-9kVQs/Oq6jxK+W0mklLBHRRj+w0HNkvovRhswAFv7ZXzqucloPud3HCcTVZa5+adnyR7cYtlS1DzeLtfBdUFCg==
|
||||
dependencies:
|
||||
color "^3.1.2"
|
||||
react-native-iphone-x-helper "^1.2.1"
|
||||
@@ -13637,10 +13637,10 @@ prettier-linter-helpers@^1.0.0:
|
||||
dependencies:
|
||||
fast-diff "^1.1.2"
|
||||
|
||||
prettier@^1.19.1:
|
||||
version "1.19.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
||||
prettier@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.1.tgz#3f00ac71263be34684b2b2c8d7e7f63737592dac"
|
||||
integrity sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA==
|
||||
|
||||
pretty-bytes@^4.0.2:
|
||||
version "4.0.2"
|
||||
|
||||
Reference in New Issue
Block a user