mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-26 22:28:19 +08:00
Compare commits
24 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e0ebb05f9 | ||
|
|
bf0b408238 | ||
|
|
1b2983eaa9 | ||
|
|
b38ee1c162 | ||
|
|
fdc24d2523 | ||
|
|
6a8242c31a | ||
|
|
3ad2e6ebcf | ||
|
|
5c8d183d68 | ||
|
|
f1b976b68c | ||
|
|
6b75cbaaa6 | ||
|
|
c951027ebb | ||
|
|
cdbf1e97f9 | ||
|
|
56a2ee99f9 | ||
|
|
a9d4813b47 | ||
|
|
74c3377b63 | ||
|
|
8c1acc33c6 | ||
|
|
d72a96d1ef | ||
|
|
f9e8c7e80f | ||
|
|
9245c79990 | ||
|
|
ea4c753d0a | ||
|
|
01196d7b48 | ||
|
|
b4a5c3c35e | ||
|
|
f302416631 | ||
|
|
dead4e826a |
@@ -64,5 +64,11 @@
|
|||||||
"@react-navigation/([^/]+)": "<rootDir>/packages/$1/src"
|
"@react-navigation/([^/]+)": "<rootDir>/packages/$1/src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
},
|
||||||
"name": "react-navigation"
|
"name": "react-navigation"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,26 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.6...@react-navigation/bottom-tabs@5.0.0-alpha.7) (2019-08-31)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.5...@react-navigation/bottom-tabs@5.0.0-alpha.6) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow making params optional. fixes [#80](https://github.com/react-navigation/navigation-ex/issues/80) ([a9d4813](https://github.com/react-navigation/navigation-ex/commit/a9d4813))
|
||||||
|
* types path ([#75](https://github.com/react-navigation/navigation-ex/issues/75)) ([b4a5c3c](https://github.com/react-navigation/navigation-ex/commit/b4a5c3c))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.4...@react-navigation/bottom-tabs@5.0.0-alpha.5) (2019-08-28)
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.4...@react-navigation/bottom-tabs@5.0.0-alpha.5) (2019-08-28)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"android",
|
"android",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.5",
|
"version": "5.0.0-alpha.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
"main": "lib/commonjs/index.js",
|
"main": "lib/commonjs/index.js",
|
||||||
"react-native": "src/index.tsx",
|
"react-native": "src/index.tsx",
|
||||||
"module": "lib/module/index.js",
|
"module": "lib/module/index.js",
|
||||||
"types": "lib/typescript/bottom-tabssrc/index.d.ts",
|
"types": "lib/typescript/bottom-tabs/src/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"lib"
|
"lib"
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.5",
|
"@react-navigation/routers": "^5.0.0-alpha.7",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ export type BottomTabNavigationProp<
|
|||||||
* @param [params] Params object for the route.
|
* @param [params] Params object for the route.
|
||||||
*/
|
*/
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
||||||
...args: ParamList[RouteName] extends void
|
...args: ParamList[RouteName] extends (undefined | any)
|
||||||
? [RouteName]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,31 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.4...@react-navigation/core@5.0.0-alpha.5) (2019-08-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/core
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.3...@react-navigation/core@5.0.0-alpha.4) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow making params optional. fixes [#80](https://github.com/react-navigation/navigation-ex/issues/80) ([a9d4813](https://github.com/react-navigation/navigation-ex/commit/a9d4813))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* export NavigationContext ([9245c79](https://github.com/react-navigation/navigation-ex/commit/9245c79))
|
||||||
|
* handle navigating with both with both key and name ([#83](https://github.com/react-navigation/navigation-ex/issues/83)) ([6b75cba](https://github.com/react-navigation/navigation-ex/commit/6b75cba))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.3](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.2...@react-navigation/core@5.0.0-alpha.3) (2019-08-27)
|
# [5.0.0-alpha.3](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.2...@react-navigation/core@5.0.0-alpha.3) (2019-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation"
|
"react-navigation"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.3",
|
"version": "5.0.0-alpha.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ export type Action =
|
|||||||
type: 'NAVIGATE';
|
type: 'NAVIGATE';
|
||||||
payload:
|
payload:
|
||||||
| { name: string; key?: undefined; params?: object }
|
| { name: string; key?: undefined; params?: object }
|
||||||
| { key: string; name?: undefined; params?: object };
|
| { key: string; name?: undefined; params?: object }
|
||||||
|
| { key: string; name: string; params?: object };
|
||||||
source?: string;
|
source?: string;
|
||||||
target?: string;
|
target?: string;
|
||||||
}
|
}
|
||||||
@@ -38,7 +39,10 @@ export function goBack(): Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function navigate(
|
export function navigate(
|
||||||
route: { key: string; params?: object } | { name: string; params?: object }
|
route:
|
||||||
|
| { key: string; params?: object }
|
||||||
|
| { name: string; params?: object }
|
||||||
|
| { name: string; key: string; params?: object }
|
||||||
): Action;
|
): Action;
|
||||||
export function navigate(name: string, params?: object): Action;
|
export function navigate(name: string, params?: object): Action;
|
||||||
export function navigate(...args: any): Action {
|
export function navigate(...args: any): Action {
|
||||||
@@ -47,12 +51,9 @@ export function navigate(...args: any): Action {
|
|||||||
} else {
|
} else {
|
||||||
const payload = args[0];
|
const payload = args[0];
|
||||||
|
|
||||||
if (
|
if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
|
||||||
(payload.hasOwnProperty('key') && payload.hasOwnProperty('name')) ||
|
|
||||||
(!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name'))
|
|
||||||
) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'While calling navigate with an object as the argument, you need to specify either name or key'
|
'While calling navigate with an object as the argument, you need to specify name or key'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,42 +7,7 @@ import MockRouter, { MockRouterKey } from './__fixtures__/MockRouter';
|
|||||||
|
|
||||||
beforeEach(() => (MockRouterKey.current = 0));
|
beforeEach(() => (MockRouterKey.current = 0));
|
||||||
|
|
||||||
it('throws if NAVIGATE dispatched with both key and name', () => {
|
it('throws if NAVIGATE dispatched neither key nor name', () => {
|
||||||
const TestNavigator = (props: any) => {
|
|
||||||
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
|
|
||||||
|
|
||||||
return descriptors[state.routes[state.index].key].render();
|
|
||||||
};
|
|
||||||
|
|
||||||
const FooScreen = (props: any) => {
|
|
||||||
React.useEffect(() => {
|
|
||||||
props.navigation.navigate({ key: '1', name: '2' });
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const onStateChange = jest.fn();
|
|
||||||
|
|
||||||
const element = (
|
|
||||||
<NavigationContainer onStateChange={onStateChange}>
|
|
||||||
<TestNavigator initialRouteName="foo">
|
|
||||||
<Screen
|
|
||||||
name="foo"
|
|
||||||
component={FooScreen}
|
|
||||||
initialParams={{ count: 10 }}
|
|
||||||
/>
|
|
||||||
</TestNavigator>
|
|
||||||
</NavigationContainer>
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(() => render(element).update(element)).toThrowError(
|
|
||||||
'While calling navigate with an object as the argument, you need to specify either name or key'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('throws if NAVIGATE dispatched neither both key nor name', () => {
|
|
||||||
const TestNavigator = (props: any) => {
|
const TestNavigator = (props: any) => {
|
||||||
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
|
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
|
||||||
|
|
||||||
@@ -73,6 +38,6 @@ it('throws if NAVIGATE dispatched neither both key nor name', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(() => render(element).update(element)).toThrowError(
|
expect(() => render(element).update(element)).toThrowError(
|
||||||
'While calling navigate with an object as the argument, you need to specify either name or key'
|
'While calling navigate with an object as the argument, you need to specify name or key'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -6,6 +6,8 @@ export { default as BaseRouter } from './BaseRouter';
|
|||||||
export { default as NavigationContainer } from './NavigationContainer';
|
export { default as NavigationContainer } from './NavigationContainer';
|
||||||
export { default as createNavigator } from './createNavigator';
|
export { default as createNavigator } from './createNavigator';
|
||||||
|
|
||||||
|
export { default as NavigationContext } from './NavigationContext';
|
||||||
|
|
||||||
export { default as useNavigationBuilder } from './useNavigationBuilder';
|
export { default as useNavigationBuilder } from './useNavigationBuilder';
|
||||||
export { default as useNavigation } from './useNavigation';
|
export { default as useNavigation } from './useNavigation';
|
||||||
export { default as useFocusEffect } from './useFocusEffect';
|
export { default as useFocusEffect } from './useFocusEffect';
|
||||||
|
|||||||
@@ -274,8 +274,8 @@ type NavigationHelpersCommon<
|
|||||||
* @param [params] Params object for the route.
|
* @param [params] Params object for the route.
|
||||||
*/
|
*/
|
||||||
navigate<RouteName extends keyof ParamList>(
|
navigate<RouteName extends keyof ParamList>(
|
||||||
...args: ParamList[RouteName] extends undefined
|
...args: ParamList[RouteName] extends (undefined | any)
|
||||||
? [RouteName] | [RouteName, undefined]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ type NavigationHelpersCommon<
|
|||||||
navigate<RouteName extends keyof ParamList>(
|
navigate<RouteName extends keyof ParamList>(
|
||||||
route:
|
route:
|
||||||
| { key: string; params?: ParamList[RouteName] }
|
| { key: string; params?: ParamList[RouteName] }
|
||||||
| { name: RouteName; params: ParamList[RouteName] }
|
| { name: RouteName; key?: string; params: ParamList[RouteName] }
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +298,7 @@ type NavigationHelpersCommon<
|
|||||||
*/
|
*/
|
||||||
replace<RouteName extends keyof ParamList>(
|
replace<RouteName extends keyof ParamList>(
|
||||||
...args: ParamList[RouteName] extends undefined
|
...args: ParamList[RouteName] extends undefined
|
||||||
? [RouteName] | [RouteName, undefined]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,33 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.7...@react-navigation/drawer@5.0.0-alpha.8) (2019-08-31)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.6...@react-navigation/drawer@5.0.0-alpha.7) (2019-08-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* rename contentContainerStyle to sceneContainerStyle for drawer ([fdc24d2](https://github.com/react-navigation/navigation-ex/commit/fdc24d2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.5...@react-navigation/drawer@5.0.0-alpha.6) (2019-08-29)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.4...@react-navigation/drawer@5.0.0-alpha.5) (2019-08-28)
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.4...@react-navigation/drawer@5.0.0-alpha.5) (2019-08-28)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/drawer
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"drawer"
|
"drawer"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.5",
|
"version": "5.0.0-alpha.8",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.5",
|
"@react-navigation/routers": "^5.0.0-alpha.7",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export type DrawerNavigationConfig = {
|
|||||||
lazy: boolean;
|
lazy: boolean;
|
||||||
/**
|
/**
|
||||||
* Whether a screen should be unmounted when navigating away from it.
|
* Whether a screen should be unmounted when navigating away from it.
|
||||||
* Defaults to `false`..
|
* Defaults to `false`.
|
||||||
*/
|
*/
|
||||||
unmountInactiveRoutes?: boolean;
|
unmountInactiveRoutes?: boolean;
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +87,10 @@ export type DrawerNavigationConfig = {
|
|||||||
* Options for the content component which will be passed as props.
|
* Options for the content component which will be passed as props.
|
||||||
*/
|
*/
|
||||||
contentOptions?: object;
|
contentOptions?: object;
|
||||||
contentContainerStyle?: StyleProp<ViewStyle>;
|
/**
|
||||||
|
* Style object for the component wrapping the screen content.
|
||||||
|
*/
|
||||||
|
sceneContainerStyle?: StyleProp<ViewStyle>;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ type Props = {
|
|||||||
statusBarAnimation: 'slide' | 'none' | 'fade';
|
statusBarAnimation: 'slide' | 'none' | 'fade';
|
||||||
overlayStyle?: StyleProp<ViewStyle>;
|
overlayStyle?: StyleProp<ViewStyle>;
|
||||||
drawerStyle?: StyleProp<ViewStyle>;
|
drawerStyle?: StyleProp<ViewStyle>;
|
||||||
contentContainerStyle?: StyleProp<ViewStyle>;
|
sceneContainerStyle?: StyleProp<ViewStyle>;
|
||||||
renderDrawerContent: Renderer;
|
renderDrawerContent: Renderer;
|
||||||
renderSceneContent: Renderer;
|
renderSceneContent: Renderer;
|
||||||
gestureHandlerProps?: React.ComponentProps<typeof PanGestureHandler>;
|
gestureHandlerProps?: React.ComponentProps<typeof PanGestureHandler>;
|
||||||
@@ -484,7 +484,7 @@ export default class DrawerView extends React.PureComponent<Props> {
|
|||||||
drawerPosition,
|
drawerPosition,
|
||||||
drawerType,
|
drawerType,
|
||||||
swipeEdgeWidth,
|
swipeEdgeWidth,
|
||||||
contentContainerStyle,
|
sceneContainerStyle,
|
||||||
drawerStyle,
|
drawerStyle,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
onGestureRef,
|
onGestureRef,
|
||||||
@@ -534,7 +534,7 @@ export default class DrawerView extends React.PureComponent<Props> {
|
|||||||
{
|
{
|
||||||
transform: [{ translateX: contentTranslateX }],
|
transform: [{ translateX: contentTranslateX }],
|
||||||
},
|
},
|
||||||
contentContainerStyle as any,
|
sceneContainerStyle as any,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{renderSceneContent({ progress: this.progress })}
|
{renderSceneContent({ progress: this.progress })}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
|||||||
drawerPosition,
|
drawerPosition,
|
||||||
drawerBackgroundColor,
|
drawerBackgroundColor,
|
||||||
overlayColor,
|
overlayColor,
|
||||||
contentContainerStyle,
|
sceneContainerStyle,
|
||||||
edgeWidth,
|
edgeWidth,
|
||||||
minSwipeDistance,
|
minSwipeDistance,
|
||||||
hideStatusBar,
|
hideStatusBar,
|
||||||
@@ -222,7 +222,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
|
|||||||
gestureHandlerProps={gestureHandlerProps}
|
gestureHandlerProps={gestureHandlerProps}
|
||||||
drawerType={drawerType}
|
drawerType={drawerType}
|
||||||
drawerPosition={drawerPosition}
|
drawerPosition={drawerPosition}
|
||||||
contentContainerStyle={contentContainerStyle}
|
sceneContainerStyle={sceneContainerStyle}
|
||||||
drawerStyle={{
|
drawerStyle={{
|
||||||
backgroundColor: drawerBackgroundColor || 'white',
|
backgroundColor: drawerBackgroundColor || 'white',
|
||||||
width: this.state.drawerWidth,
|
width: this.state.drawerWidth,
|
||||||
|
|||||||
@@ -3,6 +3,28 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.4](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.3...@react-navigation/example@5.0.0-alpha.4) (2019-08-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* handle route names change when all routes are removed ([#86](https://github.com/satya164/navigation-ex/issues/86)) ([1b2983e](https://github.com/satya164/navigation-ex/commit/1b2983e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.3](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.2...@react-navigation/example@5.0.0-alpha.3) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* handle more methods in useScrollToTop ([f9e8c7e](https://github.com/react-navigation/navigation-ex/commit/f9e8c7e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.2](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.1...@react-navigation/example@5.0.0-alpha.2) (2019-08-27)
|
# [5.0.0-alpha.2](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.1...@react-navigation/example@5.0.0-alpha.2) (2019-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/example",
|
"name": "@react-navigation/example",
|
||||||
"description": "Demo app to showcase various functionality of React Navigation",
|
"description": "Demo app to showcase various functionality of React Navigation",
|
||||||
"version": "5.0.0-alpha.2",
|
"version": "5.0.0-alpha.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"nohoist": [
|
"nohoist": [
|
||||||
|
|||||||
128
packages/example/src/Screens/AuthFlow.tsx
Normal file
128
packages/example/src/Screens/AuthFlow.tsx
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { View, TextInput, ActivityIndicator, StyleSheet } from 'react-native';
|
||||||
|
import { Title, Button } from 'react-native-paper';
|
||||||
|
import { ParamListBase } from '@react-navigation/core';
|
||||||
|
import {
|
||||||
|
createStackNavigator,
|
||||||
|
HeaderBackButton,
|
||||||
|
StackNavigationProp,
|
||||||
|
} from '@react-navigation/stack';
|
||||||
|
|
||||||
|
type AuthStackParams = {
|
||||||
|
splash: undefined;
|
||||||
|
home: undefined;
|
||||||
|
'sign-in': undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SplashScreen = () => (
|
||||||
|
<View style={styles.content}>
|
||||||
|
<ActivityIndicator />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
const SignInScreen = ({
|
||||||
|
setUserToken,
|
||||||
|
}: {
|
||||||
|
setUserToken: (token: string) => void;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View style={styles.content}>
|
||||||
|
<TextInput placeholder="Username" style={styles.input} />
|
||||||
|
<TextInput placeholder="Password" secureTextEntry style={styles.input} />
|
||||||
|
<Button
|
||||||
|
mode="contained"
|
||||||
|
onPress={() => setUserToken('token')}
|
||||||
|
style={styles.button}
|
||||||
|
>
|
||||||
|
Sign in
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const HomeScreen = ({
|
||||||
|
setUserToken,
|
||||||
|
}: {
|
||||||
|
setUserToken: (token: undefined) => void;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View style={styles.content}>
|
||||||
|
<Title style={styles.text}>Signed in successfully 🎉</Title>
|
||||||
|
<Button onPress={() => setUserToken(undefined)} style={styles.button}>
|
||||||
|
Sign out
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const SimpleStack = createStackNavigator<AuthStackParams>();
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
navigation: StackNavigationProp<ParamListBase>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function SimpleStackScreen({ navigation }: Props) {
|
||||||
|
const [isLoading, setIsLoading] = React.useState(true);
|
||||||
|
const [userToken, setUserToken] = React.useState<string | undefined>(
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const timer = setTimeout(() => setIsLoading(false), 1000);
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
navigation.setOptions({
|
||||||
|
header: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SimpleStack.Navigator
|
||||||
|
screenOptions={{
|
||||||
|
headerLeft: () => (
|
||||||
|
<HeaderBackButton onPress={() => navigation.goBack()} />
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<SimpleStack.Screen
|
||||||
|
name="splash"
|
||||||
|
component={SplashScreen}
|
||||||
|
options={{ title: `Auth Flow` }}
|
||||||
|
/>
|
||||||
|
) : userToken === undefined ? (
|
||||||
|
<SimpleStack.Screen name="sign-in" options={{ title: `Sign in` }}>
|
||||||
|
{() => <SignInScreen setUserToken={setUserToken} />}
|
||||||
|
</SimpleStack.Screen>
|
||||||
|
) : (
|
||||||
|
<SimpleStack.Screen name="home" options={{ title: 'Home' }}>
|
||||||
|
{() => <HomeScreen setUserToken={setUserToken} />}
|
||||||
|
</SimpleStack.Screen>
|
||||||
|
)}
|
||||||
|
</SimpleStack.Navigator>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
content: {
|
||||||
|
flex: 1,
|
||||||
|
padding: 16,
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
margin: 8,
|
||||||
|
padding: 10,
|
||||||
|
backgroundColor: 'white',
|
||||||
|
borderRadius: 3,
|
||||||
|
borderWidth: StyleSheet.hairlineWidth,
|
||||||
|
borderColor: 'rgba(0, 0, 0, 0.08)',
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
margin: 8,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
textAlign: 'center',
|
||||||
|
margin: 8,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -8,6 +8,7 @@ import TouchableBounce from 'react-native/Libraries/Components/Touchable/Touchab
|
|||||||
import Albums from '../Shared/Albums';
|
import Albums from '../Shared/Albums';
|
||||||
import Contacts from '../Shared/Contacts';
|
import Contacts from '../Shared/Contacts';
|
||||||
import Chat from '../Shared/Chat';
|
import Chat from '../Shared/Chat';
|
||||||
|
import SimpleStackScreen from './SimpleStack';
|
||||||
|
|
||||||
const getTabBarIcon = (name: string) => ({
|
const getTabBarIcon = (name: string) => ({
|
||||||
tintColor,
|
tintColor,
|
||||||
@@ -20,6 +21,7 @@ const getTabBarIcon = (name: string) => ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
type BottomTabParams = {
|
type BottomTabParams = {
|
||||||
|
article: undefined;
|
||||||
albums: undefined;
|
albums: undefined;
|
||||||
contacts: undefined;
|
contacts: undefined;
|
||||||
chat: undefined;
|
chat: undefined;
|
||||||
@@ -30,6 +32,18 @@ const BottomTabs = createBottomTabNavigator<BottomTabParams>();
|
|||||||
export default function BottomTabsScreen() {
|
export default function BottomTabsScreen() {
|
||||||
return (
|
return (
|
||||||
<BottomTabs.Navigator>
|
<BottomTabs.Navigator>
|
||||||
|
<BottomTabs.Screen
|
||||||
|
name="article"
|
||||||
|
options={{
|
||||||
|
title: 'Article',
|
||||||
|
tabBarIcon: getTabBarIcon('chrome-reader-mode'),
|
||||||
|
tabBarButtonComponent: TouchableBounce,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props => (
|
||||||
|
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
|
||||||
|
)}
|
||||||
|
</BottomTabs.Screen>
|
||||||
<BottomTabs.Screen
|
<BottomTabs.Screen
|
||||||
name="chat"
|
name="chat"
|
||||||
component={Chat}
|
component={Chat}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
|
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
|
||||||
import Article from '../Shared/Article';
|
|
||||||
import Albums from '../Shared/Albums';
|
import Albums from '../Shared/Albums';
|
||||||
import Contacts from '../Shared/Contacts';
|
import Contacts from '../Shared/Contacts';
|
||||||
import Chat from '../Shared/Chat';
|
import Chat from '../Shared/Chat';
|
||||||
|
import SimpleStackScreen from './SimpleStack';
|
||||||
|
|
||||||
type MaterialBottomTabParams = {
|
type MaterialBottomTabParams = {
|
||||||
article: undefined;
|
article: undefined;
|
||||||
@@ -22,13 +22,16 @@ export default function MaterialBottomTabsScreen() {
|
|||||||
<MaterialBottomTabs.Navigator barStyle={styles.tabBar}>
|
<MaterialBottomTabs.Navigator barStyle={styles.tabBar}>
|
||||||
<MaterialBottomTabs.Screen
|
<MaterialBottomTabs.Screen
|
||||||
name="article"
|
name="article"
|
||||||
component={Article}
|
|
||||||
options={{
|
options={{
|
||||||
tabBarLabel: 'Article',
|
tabBarLabel: 'Article',
|
||||||
tabBarIcon: 'chrome-reader-mode',
|
tabBarIcon: 'chrome-reader-mode',
|
||||||
tabBarColor: '#C9E7F8',
|
tabBarColor: '#C9E7F8',
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
{props => (
|
||||||
|
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
|
||||||
|
)}
|
||||||
|
</MaterialBottomTabs.Screen>
|
||||||
<MaterialBottomTabs.Screen
|
<MaterialBottomTabs.Screen
|
||||||
name="chat"
|
name="chat"
|
||||||
component={Chat}
|
component={Chat}
|
||||||
|
|||||||
@@ -72,17 +72,18 @@ const AlbumsScreen = ({
|
|||||||
|
|
||||||
const SimpleStack = createStackNavigator<SimpleStackParams>();
|
const SimpleStack = createStackNavigator<SimpleStackParams>();
|
||||||
|
|
||||||
export default function SimpleStackScreen({
|
type Props = {
|
||||||
navigation,
|
options?: React.ComponentProps<typeof SimpleStack.Navigator>;
|
||||||
}: {
|
|
||||||
navigation: StackNavigationProp<ParamListBase>;
|
navigation: StackNavigationProp<ParamListBase>;
|
||||||
}) {
|
};
|
||||||
|
|
||||||
|
export default function SimpleStackScreen({ navigation, options }: Props) {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
header: null,
|
header: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SimpleStack.Navigator>
|
<SimpleStack.Navigator {...options}>
|
||||||
<SimpleStack.Screen
|
<SimpleStack.Screen
|
||||||
name="article"
|
name="article"
|
||||||
component={ArticleScreen}
|
component={ArticleScreen}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Image, Dimensions, ScrollView, StyleSheet } from 'react-native';
|
import { Image, Dimensions, ScrollView, StyleSheet } from 'react-native';
|
||||||
|
import { useScrollToTop } from '@react-navigation/native';
|
||||||
|
|
||||||
const COVERS = [
|
const COVERS = [
|
||||||
require('../../assets/album-art-1.jpg'),
|
require('../../assets/album-art-1.jpg'),
|
||||||
@@ -12,19 +13,22 @@ const COVERS = [
|
|||||||
require('../../assets/album-art-8.jpg'),
|
require('../../assets/album-art-8.jpg'),
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class Albums extends React.Component {
|
export default function Albums() {
|
||||||
render() {
|
const ref = React.useRef<ScrollView>(null);
|
||||||
return (
|
|
||||||
<ScrollView
|
useScrollToTop(ref);
|
||||||
style={styles.container}
|
|
||||||
contentContainerStyle={styles.content}
|
return (
|
||||||
>
|
<ScrollView
|
||||||
{COVERS.map((source, i) => (
|
ref={ref}
|
||||||
<Image key={i} source={source} style={styles.cover} />
|
style={styles.container}
|
||||||
))}
|
contentContainerStyle={styles.content}
|
||||||
</ScrollView>
|
>
|
||||||
);
|
{COVERS.map((source, i) => (
|
||||||
}
|
<Image key={i} source={source} style={styles.cover} />
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
@@ -1,63 +1,63 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { View, Text, Image, ScrollView, StyleSheet } from 'react-native';
|
import { View, Text, Image, ScrollView, StyleSheet } from 'react-native';
|
||||||
|
import { useScrollToTop } from '@react-navigation/native';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
date: string;
|
date?: string;
|
||||||
author: {
|
author?: {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class Article extends React.Component<Props> {
|
export default function Article({
|
||||||
static defaultProps = {
|
date = '1st Jan 2025',
|
||||||
date: '1st Jan 2025',
|
author = {
|
||||||
author: {
|
name: 'Knowledge Bot',
|
||||||
name: 'Knowledge Bot',
|
},
|
||||||
},
|
}: Props) {
|
||||||
};
|
const ref = React.useRef<ScrollView>(null);
|
||||||
|
|
||||||
render() {
|
useScrollToTop(ref);
|
||||||
const { date, author } = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<ScrollView
|
||||||
style={styles.container}
|
ref={ref}
|
||||||
contentContainerStyle={styles.content}
|
style={styles.container}
|
||||||
>
|
contentContainerStyle={styles.content}
|
||||||
<View style={styles.author}>
|
>
|
||||||
<Image
|
<View style={styles.author}>
|
||||||
style={styles.avatar}
|
<Image
|
||||||
source={require('../../assets/avatar-1.png')}
|
style={styles.avatar}
|
||||||
/>
|
source={require('../../assets/avatar-1.png')}
|
||||||
<View style={styles.meta}>
|
/>
|
||||||
<Text style={styles.name}>{author.name}</Text>
|
<View style={styles.meta}>
|
||||||
<Text style={styles.timestamp}>{date}</Text>
|
<Text style={styles.name}>{author.name}</Text>
|
||||||
</View>
|
<Text style={styles.timestamp}>{date}</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.title}>Lorem Ipsum</Text>
|
</View>
|
||||||
<Text style={styles.paragraph}>
|
<Text style={styles.title}>Lorem Ipsum</Text>
|
||||||
Contrary to popular belief, Lorem Ipsum is not simply random text. It
|
<Text style={styles.paragraph}>
|
||||||
has roots in a piece of classical Latin literature from 45 BC, making
|
Contrary to popular belief, Lorem Ipsum is not simply random text. It
|
||||||
it over 2000 years old.
|
has roots in a piece of classical Latin literature from 45 BC, making it
|
||||||
</Text>
|
over 2000 years old.
|
||||||
<Image style={styles.image} source={require('../../assets/book.jpg')} />
|
</Text>
|
||||||
<Text style={styles.paragraph}>
|
<Image style={styles.image} source={require('../../assets/book.jpg')} />
|
||||||
Richard McClintock, a Latin professor at Hampden-Sydney College in
|
<Text style={styles.paragraph}>
|
||||||
Virginia, looked up one of the more obscure Latin words, consectetur,
|
Richard McClintock, a Latin professor at Hampden-Sydney College in
|
||||||
from a Lorem Ipsum passage, and going through the cites of the word in
|
Virginia, looked up one of the more obscure Latin words, consectetur,
|
||||||
classical literature, discovered the undoubtable source.
|
from a Lorem Ipsum passage, and going through the cites of the word in
|
||||||
</Text>
|
classical literature, discovered the undoubtable source.
|
||||||
<Text style={styles.paragraph}>
|
</Text>
|
||||||
Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de
|
<Text style={styles.paragraph}>
|
||||||
Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by
|
Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus
|
||||||
Cicero, written in 45 BC. This book is a treatise on the theory of
|
Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
|
||||||
ethics, very popular during the Renaissance. The first line of Lorem
|
written in 45 BC. This book is a treatise on the theory of ethics, very
|
||||||
Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
|
popular during the Renaissance. The first line of Lorem Ipsum,
|
||||||
section 1.10.32.
|
"Lorem ipsum dolor sit amet..", comes from a line in section
|
||||||
</Text>
|
1.10.32.
|
||||||
</ScrollView>
|
</Text>
|
||||||
);
|
</ScrollView>
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
ScrollView,
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
import { useScrollToTop } from '@react-navigation/native';
|
||||||
|
|
||||||
const MESSAGES = [
|
const MESSAGES = [
|
||||||
'okay',
|
'okay',
|
||||||
@@ -15,49 +16,51 @@ const MESSAGES = [
|
|||||||
'make me a sandwich',
|
'make me a sandwich',
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class Chat extends React.Component {
|
export default function Chat() {
|
||||||
render() {
|
const ref = React.useRef<ScrollView>(null);
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
|
||||||
<ScrollView
|
|
||||||
style={styles.inverted}
|
|
||||||
contentContainerStyle={styles.content}
|
|
||||||
>
|
|
||||||
{MESSAGES.map((text, i) => {
|
|
||||||
const odd = i % 2;
|
|
||||||
|
|
||||||
return (
|
useScrollToTop(ref);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<ScrollView
|
||||||
|
style={styles.inverted}
|
||||||
|
contentContainerStyle={styles.content}
|
||||||
|
>
|
||||||
|
{MESSAGES.map((text, i) => {
|
||||||
|
const odd = i % 2;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
key={i}
|
||||||
|
style={[odd ? styles.odd : styles.even, styles.inverted]}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
style={styles.avatar}
|
||||||
|
source={
|
||||||
|
odd
|
||||||
|
? require('../../assets/avatar-2.png')
|
||||||
|
: require('../../assets/avatar-1.png')
|
||||||
|
}
|
||||||
|
/>
|
||||||
<View
|
<View
|
||||||
key={i}
|
style={[styles.bubble, odd ? styles.received : styles.sent]}
|
||||||
style={[odd ? styles.odd : styles.even, styles.inverted]}
|
|
||||||
>
|
>
|
||||||
<Image
|
<Text style={odd ? styles.receivedText : styles.sentText}>
|
||||||
style={styles.avatar}
|
{text}
|
||||||
source={
|
</Text>
|
||||||
odd
|
|
||||||
? require('../../assets/avatar-2.png')
|
|
||||||
: require('../../assets/avatar-1.png')
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<View
|
|
||||||
style={[styles.bubble, odd ? styles.received : styles.sent]}
|
|
||||||
>
|
|
||||||
<Text style={odd ? styles.receivedText : styles.sentText}>
|
|
||||||
{text}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
</View>
|
||||||
})}
|
);
|
||||||
</ScrollView>
|
})}
|
||||||
<TextInput
|
</ScrollView>
|
||||||
style={styles.input}
|
<TextInput
|
||||||
placeholder="Write a message"
|
style={styles.input}
|
||||||
underlineColorAndroid="transparent"
|
placeholder="Write a message"
|
||||||
/>
|
underlineColorAndroid="transparent"
|
||||||
</View>
|
/>
|
||||||
);
|
</View>
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { View, Text, StyleSheet } from 'react-native';
|
import { View, Text, FlatList, StyleSheet } from 'react-native';
|
||||||
import { FlatList } from 'react-native-gesture-handler';
|
import { useScrollToTop } from '@react-navigation/native';
|
||||||
|
|
||||||
type Item = { name: string; number: number };
|
type Item = { name: string; number: number };
|
||||||
|
|
||||||
@@ -79,23 +79,24 @@ class ContactItem extends React.PureComponent<{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Contacts extends React.Component {
|
export default function Contacts() {
|
||||||
private renderItem = ({ item }: { item: Item }) => (
|
const ref = React.useRef<FlatList<Item>>(null);
|
||||||
<ContactItem item={item} />
|
|
||||||
|
useScrollToTop(ref);
|
||||||
|
|
||||||
|
const renderItem = ({ item }: { item: Item }) => <ContactItem item={item} />;
|
||||||
|
|
||||||
|
const ItemSeparator = () => <View style={styles.separator} />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FlatList
|
||||||
|
ref={ref}
|
||||||
|
data={CONTACTS}
|
||||||
|
keyExtractor={(_, i) => String(i)}
|
||||||
|
renderItem={renderItem}
|
||||||
|
ItemSeparatorComponent={ItemSeparator}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
private ItemSeparator = () => <View style={styles.separator} />;
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<FlatList
|
|
||||||
data={CONTACTS}
|
|
||||||
keyExtractor={(_, i) => String(i)}
|
|
||||||
renderItem={this.renderItem}
|
|
||||||
ItemSeparatorComponent={this.ItemSeparator}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import SimpleStackScreen from './Screens/SimpleStack';
|
|||||||
import BottomTabsScreen from './Screens/BottomTabs';
|
import BottomTabsScreen from './Screens/BottomTabs';
|
||||||
import MaterialTopTabsScreen from './Screens/MaterialTopTabs';
|
import MaterialTopTabsScreen from './Screens/MaterialTopTabs';
|
||||||
import MaterialBottomTabs from './Screens/MaterialBottomTabs';
|
import MaterialBottomTabs from './Screens/MaterialBottomTabs';
|
||||||
|
import AuthFlow from './Screens/AuthFlow';
|
||||||
|
|
||||||
YellowBox.ignoreWarnings(['Require cycle:', 'Warning: Async Storage']);
|
YellowBox.ignoreWarnings(['Require cycle:', 'Warning: Async Storage']);
|
||||||
|
|
||||||
@@ -47,6 +48,10 @@ const SCREENS = {
|
|||||||
title: 'Material Bottom Tabs',
|
title: 'Material Bottom Tabs',
|
||||||
component: MaterialBottomTabs,
|
component: MaterialBottomTabs,
|
||||||
},
|
},
|
||||||
|
'auth-flow': {
|
||||||
|
title: 'Auth Flow',
|
||||||
|
component: AuthFlow,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const Drawer = createDrawerNavigator<RootDrawerParamList>();
|
const Drawer = createDrawerNavigator<RootDrawerParamList>();
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.6...@react-navigation/material-bottom-tabs@5.0.0-alpha.7) (2019-08-31)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.5...@react-navigation/material-bottom-tabs@5.0.0-alpha.6) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow making params optional. fixes [#80](https://github.com/react-navigation/navigation-ex/issues/80) ([a9d4813](https://github.com/react-navigation/navigation-ex/commit/a9d4813))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.4...@react-navigation/material-bottom-tabs@5.0.0-alpha.5) (2019-08-28)
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.4...@react-navigation/material-bottom-tabs@5.0.0-alpha.5) (2019-08-28)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.5",
|
"version": "5.0.0-alpha.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.5"
|
"@react-navigation/routers": "^5.0.0-alpha.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export type MaterialBottomTabNavigationProp<
|
|||||||
* @param [params] Params object for the route.
|
* @param [params] Params object for the route.
|
||||||
*/
|
*/
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
||||||
...args: ParamList[RouteName] extends void
|
...args: ParamList[RouteName] extends (undefined | any)
|
||||||
? [RouteName]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,25 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.6...@react-navigation/material-top-tabs@5.0.0-alpha.7) (2019-08-31)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.5...@react-navigation/material-top-tabs@5.0.0-alpha.6) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow making params optional. fixes [#80](https://github.com/react-navigation/navigation-ex/issues/80) ([a9d4813](https://github.com/react-navigation/navigation-ex/commit/a9d4813))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.4...@react-navigation/material-top-tabs@5.0.0-alpha.5) (2019-08-28)
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.4...@react-navigation/material-top-tabs@5.0.0-alpha.5) (2019-08-28)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"material",
|
"material",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.5",
|
"version": "5.0.0-alpha.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.5"
|
"@react-navigation/routers": "^5.0.0-alpha.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.7.0",
|
"@react-native-community/bob": "^0.7.0",
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ export type MaterialTopTabNavigationProp<
|
|||||||
* @param [params] Params object for the route.
|
* @param [params] Params object for the route.
|
||||||
*/
|
*/
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
||||||
...args: ParamList[RouteName] extends void
|
...args: ParamList[RouteName] extends (undefined | any)
|
||||||
? [RouteName]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
};
|
};
|
||||||
@@ -125,7 +125,7 @@ export type MaterialTopTabNavigationConfig = Partial<
|
|||||||
*
|
*
|
||||||
* This view is usually only shown for a split second. Keep it lightweight.
|
* This view is usually only shown for a split second. Keep it lightweight.
|
||||||
*
|
*
|
||||||
* By default, this renders null..
|
* By default, this renders null.
|
||||||
*/
|
*/
|
||||||
lazyPlaceholderComponent?: React.ComponentType<{ route: Route<string> }>;
|
lazyPlaceholderComponent?: React.ComponentType<{ route: Route<string> }>;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,34 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.4...@react-navigation/native@5.0.0-alpha.5) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* handle both null and undefined in useScrollToTop ([c951027](https://github.com/react-navigation/navigation-ex/commit/c951027))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* handle animated component wrappers in `useScrollToTop` ([#81](https://github.com/react-navigation/navigation-ex/issues/81)) ([cdbf1e9](https://github.com/react-navigation/navigation-ex/commit/cdbf1e9))
|
||||||
|
* handle more methods in useScrollToTop ([f9e8c7e](https://github.com/react-navigation/navigation-ex/commit/f9e8c7e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.3...@react-navigation/native@5.0.0-alpha.4) (2019-08-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix stack nested in tab always getting reset ([dead4e8](https://github.com/react-navigation/navigation-ex/commit/dead4e8))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.3](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.2...@react-navigation/native@5.0.0-alpha.3) (2019-08-27)
|
# [5.0.0-alpha.3](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native@5.0.0-alpha.2...@react-navigation/native@5.0.0-alpha.3) (2019-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"ios",
|
"ios",
|
||||||
"android"
|
"android"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.3",
|
"version": "5.0.0-alpha.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1,11 +1,40 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useNavigation, EventArg } from '@react-navigation/core';
|
import { useNavigation, EventArg } from '@react-navigation/core';
|
||||||
|
|
||||||
type ScrollableView = {
|
type ScrollOptions = { y?: number; animated?: boolean };
|
||||||
scrollTo(options: { x?: number; y?: number; animated?: boolean }): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function useScrollToTop(ref: React.RefObject<ScrollableView>) {
|
type ScrollableView =
|
||||||
|
| { scrollToTop(): void }
|
||||||
|
| { scrollTo(options: ScrollOptions): void }
|
||||||
|
| { scrollToOffset(options: ScrollOptions): void }
|
||||||
|
| { scrollResponderScrollTo(options: ScrollOptions): void };
|
||||||
|
|
||||||
|
type ScrollableWrapper =
|
||||||
|
| { getScrollResponder(): ScrollableView }
|
||||||
|
| { getNode(): ScrollableView }
|
||||||
|
| ScrollableView;
|
||||||
|
|
||||||
|
function getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {
|
||||||
|
if (ref.current == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('getScrollResponder' in ref.current) {
|
||||||
|
// If the view is a wrapper like FlatList, SectionList etc.
|
||||||
|
// We need to use `getScrollResponder` to get access to the scroll responder
|
||||||
|
return ref.current.getScrollResponder();
|
||||||
|
} else if ('getNode' in ref.current) {
|
||||||
|
// When a `ScrollView` is wraped in `Animated.createAnimatedComponent`
|
||||||
|
// we need to use `getNode` to get the ref to the actual scrollview
|
||||||
|
return ref.current.getNode();
|
||||||
|
} else {
|
||||||
|
return ref.current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useScrollToTop(
|
||||||
|
ref: React.RefObject<ScrollableWrapper>
|
||||||
|
) {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
@@ -14,12 +43,24 @@ export default function useScrollToTop(ref: React.RefObject<ScrollableView>) {
|
|||||||
// We don't wanna import tab types here to avoid extra deps
|
// We don't wanna import tab types here to avoid extra deps
|
||||||
// in addition, there are multiple tab implementations
|
// in addition, there are multiple tab implementations
|
||||||
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
|
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
|
||||||
|
const isFocused = navigation.isFocused();
|
||||||
|
|
||||||
// Run the operation in the next frame so we're sure all listeners have been run
|
// Run the operation in the next frame so we're sure all listeners have been run
|
||||||
// This is necessary to know if preventDefault() has been called
|
// This is necessary to know if preventDefault() has been called
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
if (navigation.isFocused() && !e.defaultPrevented && ref.current) {
|
const scrollable = getScrollableNode(ref);
|
||||||
|
|
||||||
|
if (isFocused && !e.defaultPrevented && scrollable) {
|
||||||
// When user taps on already focused tab, scroll to top
|
// When user taps on already focused tab, scroll to top
|
||||||
ref.current.scrollTo({ y: 0 });
|
if ('scrollToTop' in scrollable) {
|
||||||
|
scrollable.scrollToTop();
|
||||||
|
} else if ('scrollTo' in scrollable) {
|
||||||
|
scrollable.scrollTo({ y: 0, animated: true });
|
||||||
|
} else if ('scrollToOffset' in scrollable) {
|
||||||
|
scrollable.scrollToOffset({ y: 0, animated: true });
|
||||||
|
} else if ('scrollResponderScrollTo' in scrollable) {
|
||||||
|
scrollable.scrollResponderScrollTo({ y: 0, animated: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -3,6 +3,28 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.6...@react-navigation/routers@5.0.0-alpha.7) (2019-08-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* handle route names change when all routes are removed ([#86](https://github.com/react-navigation/navigation-ex/issues/86)) ([1b2983e](https://github.com/react-navigation/navigation-ex/commit/1b2983e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.5...@react-navigation/routers@5.0.0-alpha.6) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* handle navigating with both with both key and name ([#83](https://github.com/react-navigation/navigation-ex/issues/83)) ([6b75cba](https://github.com/react-navigation/navigation-ex/commit/6b75cba))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.4...@react-navigation/routers@5.0.0-alpha.5) (2019-08-28)
|
# [5.0.0-alpha.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.4...@react-navigation/routers@5.0.0-alpha.5) (2019-08-28)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/routers
|
**Note:** Version bump only for package @react-navigation/routers
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ it('gets state on route names change', () => {
|
|||||||
expect(
|
expect(
|
||||||
router.getStateForRouteNamesChange(
|
router.getStateForRouteNamesChange(
|
||||||
{
|
{
|
||||||
index: 0,
|
index: 2,
|
||||||
key: 'stack-test',
|
key: 'stack-test',
|
||||||
routeNames: ['bar', 'baz', 'qux'],
|
routeNames: ['bar', 'baz', 'qux'],
|
||||||
routes: [
|
routes: [
|
||||||
@@ -157,7 +157,7 @@ it('gets state on route names change', () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
index: 0,
|
index: 1,
|
||||||
key: 'stack-test',
|
key: 'stack-test',
|
||||||
routeNames: ['qux', 'baz', 'foo', 'fiz'],
|
routeNames: ['qux', 'baz', 'foo', 'fiz'],
|
||||||
routes: [
|
routes: [
|
||||||
@@ -166,6 +166,64 @@ it('gets state on route names change', () => {
|
|||||||
],
|
],
|
||||||
stale: false,
|
stale: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
router.getStateForRouteNamesChange(
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
key: 'stack-test',
|
||||||
|
routeNames: ['foo', 'bar'],
|
||||||
|
routes: [
|
||||||
|
{ key: 'foo-test', name: 'foo' },
|
||||||
|
{ key: 'bar-test', name: 'bar' },
|
||||||
|
],
|
||||||
|
stale: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
routeNames: ['baz', 'qux'],
|
||||||
|
routeParamList: {
|
||||||
|
baz: { name: 'John' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).toEqual({
|
||||||
|
index: 0,
|
||||||
|
key: 'stack-test',
|
||||||
|
routeNames: ['baz', 'qux'],
|
||||||
|
routes: [{ key: 'baz-test', name: 'baz', params: { name: 'John' } }],
|
||||||
|
stale: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('gets state on route names change with initialRouteName', () => {
|
||||||
|
const router = StackRouter({ initialRouteName: 'qux' });
|
||||||
|
|
||||||
|
expect(
|
||||||
|
router.getStateForRouteNamesChange(
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
key: 'stack-test',
|
||||||
|
routeNames: ['foo', 'bar'],
|
||||||
|
routes: [
|
||||||
|
{ key: 'foo-test', name: 'foo' },
|
||||||
|
{ key: 'bar-test', name: 'bar' },
|
||||||
|
],
|
||||||
|
stale: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
routeNames: ['baz', 'qux'],
|
||||||
|
routeParamList: {
|
||||||
|
baz: { name: 'John' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).toEqual({
|
||||||
|
index: 0,
|
||||||
|
key: 'stack-test',
|
||||||
|
routeNames: ['baz', 'qux'],
|
||||||
|
routes: [{ key: 'qux-test', name: 'qux' }],
|
||||||
|
stale: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles navigate action', () => {
|
it('handles navigate action', () => {
|
||||||
@@ -267,6 +325,51 @@ it('handles navigate action', () => {
|
|||||||
CommonActions.navigate({ key: 'unknown' })
|
CommonActions.navigate({ key: 'unknown' })
|
||||||
)
|
)
|
||||||
).toBe(null);
|
).toBe(null);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
router.getStateForAction(
|
||||||
|
{
|
||||||
|
stale: false,
|
||||||
|
key: 'root',
|
||||||
|
index: 1,
|
||||||
|
routeNames: ['baz', 'bar', 'qux'],
|
||||||
|
routes: [{ key: 'baz-0', name: 'baz' }, { key: 'bar', name: 'bar' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'NAVIGATE',
|
||||||
|
payload: { key: 'baz-0', name: 'baz' },
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).toEqual({
|
||||||
|
stale: false,
|
||||||
|
key: 'root',
|
||||||
|
index: 0,
|
||||||
|
routeNames: ['baz', 'bar', 'qux'],
|
||||||
|
routes: [{ key: 'baz-0', name: 'baz' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
router.getStateForAction(
|
||||||
|
{
|
||||||
|
stale: false,
|
||||||
|
key: 'root',
|
||||||
|
index: 1,
|
||||||
|
routeNames: ['baz', 'bar', 'qux'],
|
||||||
|
routes: [{ key: 'baz-0', name: 'baz' }, { key: 'bar', name: 'bar' }],
|
||||||
|
},
|
||||||
|
CommonActions.navigate({ key: 'baz-1', name: 'baz' })
|
||||||
|
)
|
||||||
|
).toEqual({
|
||||||
|
stale: false,
|
||||||
|
key: 'root',
|
||||||
|
index: 2,
|
||||||
|
routeNames: ['baz', 'bar', 'qux'],
|
||||||
|
routes: [
|
||||||
|
{ key: 'baz-0', name: 'baz' },
|
||||||
|
{ key: 'bar', name: 'bar' },
|
||||||
|
{ key: 'baz-1', name: 'baz' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles go back action', () => {
|
it('handles go back action', () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation"
|
"react-navigation"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.5",
|
"version": "5.0.0-alpha.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
export type StackActionType =
|
export type StackActionType =
|
||||||
| {
|
| {
|
||||||
type: 'PUSH';
|
type: 'PUSH';
|
||||||
payload: { name: string; params?: object };
|
payload: { name: string; key?: string | undefined; params?: object };
|
||||||
source?: string;
|
source?: string;
|
||||||
target?: string;
|
target?: string;
|
||||||
}
|
}
|
||||||
@@ -114,11 +114,25 @@ export default function StackRouter(options: StackRouterOptions) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getStateForRouteNamesChange(state, { routeNames }) {
|
getStateForRouteNamesChange(state, { routeNames, routeParamList }) {
|
||||||
const routes = state.routes.filter(route =>
|
const routes = state.routes.filter(route =>
|
||||||
routeNames.includes(route.name)
|
routeNames.includes(route.name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (routes.length === 0) {
|
||||||
|
const initialRouteName =
|
||||||
|
options.initialRouteName !== undefined &&
|
||||||
|
routeNames.includes(options.initialRouteName)
|
||||||
|
? options.initialRouteName
|
||||||
|
: routeNames[0];
|
||||||
|
|
||||||
|
routes.push({
|
||||||
|
key: `${initialRouteName}-${shortid()}`,
|
||||||
|
name: initialRouteName,
|
||||||
|
params: routeParamList[initialRouteName],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
routeNames,
|
routeNames,
|
||||||
@@ -151,7 +165,10 @@ export default function StackRouter(options: StackRouterOptions) {
|
|||||||
routes: [
|
routes: [
|
||||||
...state.routes,
|
...state.routes,
|
||||||
{
|
{
|
||||||
key: `${action.payload.name}-${shortid()}`,
|
key:
|
||||||
|
action.payload.key === undefined
|
||||||
|
? `${action.payload.name}-${shortid()}`
|
||||||
|
: action.payload.key,
|
||||||
name: action.payload.name,
|
name: action.payload.name,
|
||||||
params: action.payload.params,
|
params: action.payload.params,
|
||||||
},
|
},
|
||||||
@@ -199,14 +216,16 @@ export default function StackRouter(options: StackRouterOptions) {
|
|||||||
let index = -1;
|
let index = -1;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
state.routes[state.index].name === action.payload.name ||
|
(state.routes[state.index].name === action.payload.name &&
|
||||||
|
action.payload.key === undefined) ||
|
||||||
state.routes[state.index].key === action.payload.key
|
state.routes[state.index].key === action.payload.key
|
||||||
) {
|
) {
|
||||||
index = state.index;
|
index = state.index;
|
||||||
} else {
|
} else {
|
||||||
for (let i = state.routes.length - 1; i >= 0; i--) {
|
for (let i = state.routes.length - 1; i >= 0; i--) {
|
||||||
if (
|
if (
|
||||||
state.routes[i].name === action.payload.name ||
|
(state.routes[i].name === action.payload.name &&
|
||||||
|
action.payload.key === undefined) ||
|
||||||
state.routes[i].key === action.payload.key
|
state.routes[i].key === action.payload.key
|
||||||
) {
|
) {
|
||||||
index = i;
|
index = i;
|
||||||
@@ -215,7 +234,11 @@ export default function StackRouter(options: StackRouterOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index === -1 && action.payload.key) {
|
if (
|
||||||
|
index === -1 &&
|
||||||
|
action.payload.key &&
|
||||||
|
action.payload.name === undefined
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +246,7 @@ export default function StackRouter(options: StackRouterOptions) {
|
|||||||
return router.getStateForAction(state, {
|
return router.getStateForAction(state, {
|
||||||
type: 'PUSH',
|
type: 'PUSH',
|
||||||
payload: {
|
payload: {
|
||||||
|
key: action.payload.key,
|
||||||
name: action.payload.name,
|
name: action.payload.name,
|
||||||
params: action.payload.params,
|
params: action.payload.params,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,49 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.0.0-alpha.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.9...@react-navigation/stack@5.0.0-alpha.10) (2019-08-31)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/stack
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.8...@react-navigation/stack@5.0.0-alpha.9) (2019-08-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* change interpolated style when idle to avoid messing up reanimated ([3ad2e6e](https://github.com/react-navigation/navigation-ex/commit/3ad2e6e))
|
||||||
|
* properly set animated node on gestureEnabled change ([6a8242c](https://github.com/react-navigation/navigation-ex/commit/6a8242c))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.7...@react-navigation/stack@5.0.0-alpha.8) (2019-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow making params optional. fixes [#80](https://github.com/react-navigation/navigation-ex/issues/80) ([a9d4813](https://github.com/react-navigation/navigation-ex/commit/a9d4813))
|
||||||
|
* fix gestures not working in stack ([8c1acc3](https://github.com/react-navigation/navigation-ex/commit/8c1acc3))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.6...@react-navigation/stack@5.0.0-alpha.7) (2019-08-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix stack nested in tab always getting reset ([dead4e8](https://github.com/react-navigation/navigation-ex/commit/dead4e8))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.5...@react-navigation/stack@5.0.0-alpha.6) (2019-08-28)
|
# [5.0.0-alpha.6](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.5...@react-navigation/stack@5.0.0-alpha.6) (2019-08-28)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"android",
|
"android",
|
||||||
"stack"
|
"stack"
|
||||||
],
|
],
|
||||||
"version": "5.0.0-alpha.6",
|
"version": "5.0.0-alpha.10",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.0.0-alpha.5",
|
"@react-navigation/routers": "^5.0.0-alpha.7",
|
||||||
"react-native-safe-area-view": "^0.14.6"
|
"react-native-safe-area-view": "^0.14.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -9,15 +9,16 @@ const { cond, add, multiply, interpolate } = Animated;
|
|||||||
* Standard iOS-style slide in from the right.
|
* Standard iOS-style slide in from the right.
|
||||||
*/
|
*/
|
||||||
export function forHorizontalIOS({
|
export function forHorizontalIOS({
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
}: CardInterpolationProps): CardInterpolatedStyle {
|
}: CardInterpolationProps): CardInterpolatedStyle {
|
||||||
const translateFocused = interpolate(current, {
|
const translateFocused = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [I18nManager.isRTL ? -screen.width : screen.width, 0],
|
outputRange: [I18nManager.isRTL ? -screen.width : screen.width, 0],
|
||||||
});
|
});
|
||||||
const translateUnfocused = next
|
const translateUnfocused = next
|
||||||
? interpolate(next, {
|
? interpolate(next.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [
|
outputRange: [
|
||||||
0,
|
0,
|
||||||
@@ -26,12 +27,12 @@ export function forHorizontalIOS({
|
|||||||
})
|
})
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
const overlayOpacity = interpolate(current, {
|
const overlayOpacity = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [0, 0.07],
|
outputRange: [0, 0.07],
|
||||||
});
|
});
|
||||||
|
|
||||||
const shadowOpacity = interpolate(current, {
|
const shadowOpacity = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [0, 0.3],
|
outputRange: [0, 0.3],
|
||||||
});
|
});
|
||||||
@@ -54,10 +55,10 @@ export function forHorizontalIOS({
|
|||||||
* Standard iOS-style slide in from the bottom (used for modals).
|
* Standard iOS-style slide in from the bottom (used for modals).
|
||||||
*/
|
*/
|
||||||
export function forVerticalIOS({
|
export function forVerticalIOS({
|
||||||
progress: { current },
|
current,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
}: CardInterpolationProps): CardInterpolatedStyle {
|
}: CardInterpolationProps): CardInterpolatedStyle {
|
||||||
const translateY = interpolate(current, {
|
const translateY = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [screen.height, 0],
|
outputRange: [screen.height, 0],
|
||||||
});
|
});
|
||||||
@@ -77,14 +78,15 @@ export function forVerticalIOS({
|
|||||||
*/
|
*/
|
||||||
export function forModalPresentationIOS({
|
export function forModalPresentationIOS({
|
||||||
index,
|
index,
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
}: CardInterpolationProps): CardInterpolatedStyle {
|
}: CardInterpolationProps): CardInterpolatedStyle {
|
||||||
const topOffset = 10;
|
const topOffset = 10;
|
||||||
const statusBarHeight = getStatusBarHeight(screen.width > screen.height);
|
const statusBarHeight = getStatusBarHeight(screen.width > screen.height);
|
||||||
const aspectRatio = screen.height / screen.width;
|
const aspectRatio = screen.height / screen.width;
|
||||||
|
|
||||||
const progress = add(current, next ? next : 0);
|
const progress = add(current.progress, next ? next.progress : 0);
|
||||||
|
|
||||||
const translateY = interpolate(progress, {
|
const translateY = interpolate(progress, {
|
||||||
inputRange: [0, 1, 2],
|
inputRange: [0, 1, 2],
|
||||||
@@ -129,19 +131,19 @@ export function forModalPresentationIOS({
|
|||||||
* Standard Android-style fade in from the bottom for Android Oreo.
|
* Standard Android-style fade in from the bottom for Android Oreo.
|
||||||
*/
|
*/
|
||||||
export function forFadeFromBottomAndroid({
|
export function forFadeFromBottomAndroid({
|
||||||
progress: { current },
|
current,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
closing,
|
closing,
|
||||||
}: CardInterpolationProps): CardInterpolatedStyle {
|
}: CardInterpolationProps): CardInterpolatedStyle {
|
||||||
const translateY = interpolate(current, {
|
const translateY = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [multiply(screen.height, 0.08), 0],
|
outputRange: [multiply(screen.height, 0.08), 0],
|
||||||
});
|
});
|
||||||
|
|
||||||
const opacity = cond(
|
const opacity = cond(
|
||||||
closing,
|
closing,
|
||||||
current,
|
current.progress,
|
||||||
interpolate(current, {
|
interpolate(current.progress, {
|
||||||
inputRange: [0, 0.5, 0.9, 1],
|
inputRange: [0, 0.5, 0.9, 1],
|
||||||
outputRange: [0, 0.25, 0.7, 1],
|
outputRange: [0, 0.25, 0.7, 1],
|
||||||
})
|
})
|
||||||
@@ -156,27 +158,28 @@ export function forFadeFromBottomAndroid({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Android-style wipe from the bottom for Android Pie.
|
* Standard Android-style reveal from the bottom for Android Pie.
|
||||||
*/
|
*/
|
||||||
export function forRevealFromBottomAndroid({
|
export function forRevealFromBottomAndroid({
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
}: CardInterpolationProps): CardInterpolatedStyle {
|
}: CardInterpolationProps): CardInterpolatedStyle {
|
||||||
const containerTranslateY = interpolate(current, {
|
const containerTranslateY = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [screen.height, 0],
|
outputRange: [screen.height, 0],
|
||||||
});
|
});
|
||||||
const cardTranslateYFocused = interpolate(current, {
|
const cardTranslateYFocused = interpolate(current.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [multiply(screen.height, 95.9 / 100, -1), 0],
|
outputRange: [multiply(screen.height, 95.9 / 100, -1), 0],
|
||||||
});
|
});
|
||||||
const cardTranslateYUnfocused = next
|
const cardTranslateYUnfocused = next
|
||||||
? interpolate(next, {
|
? interpolate(next.progress, {
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [0, multiply(screen.height, 2 / 100, -1)],
|
outputRange: [0, multiply(screen.height, 2 / 100, -1)],
|
||||||
})
|
})
|
||||||
: 0;
|
: 0;
|
||||||
const overlayOpacity = interpolate(current, {
|
const overlayOpacity = interpolate(current.progress, {
|
||||||
inputRange: [0, 0.36, 1],
|
inputRange: [0, 0.36, 1],
|
||||||
outputRange: [0, 0.1, 0.1],
|
outputRange: [0, 0.1, 0.1],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import { HeaderInterpolationProps, HeaderInterpolatedStyle } from '../types';
|
|||||||
|
|
||||||
const { interpolate, add } = Animated;
|
const { interpolate, add } = Animated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard UIKit style animation for the header where the title fades into the back button label.
|
||||||
|
*/
|
||||||
export function forUIKit({
|
export function forUIKit({
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
layouts,
|
layouts,
|
||||||
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
||||||
const defaultOffset = 100;
|
const defaultOffset = 100;
|
||||||
@@ -27,7 +31,7 @@ export function forUIKit({
|
|||||||
// The back title also animates in from this position
|
// The back title also animates in from this position
|
||||||
const rightOffset = layouts.screen.width / 4;
|
const rightOffset = layouts.screen.width / 4;
|
||||||
|
|
||||||
const progress = add(current, next ? next : 0);
|
const progress = add(current.progress, next ? next.progress : 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
leftButtonStyle: {
|
leftButtonStyle: {
|
||||||
@@ -85,10 +89,14 @@ export function forUIKit({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple fade animation for the header elements.
|
||||||
|
*/
|
||||||
export function forFade({
|
export function forFade({
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
||||||
const progress = add(current, next ? next : 0);
|
const progress = add(current.progress, next ? next.progress : 0);
|
||||||
const opacity = interpolate(progress, {
|
const opacity = interpolate(progress, {
|
||||||
inputRange: [0, 1, 2],
|
inputRange: [0, 1, 2],
|
||||||
outputRange: [0, 1, 0],
|
outputRange: [0, 1, 0],
|
||||||
@@ -102,11 +110,15 @@ export function forFade({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple translate animation to translate the header along with the sliding screen.
|
||||||
|
*/
|
||||||
export function forStatic({
|
export function forStatic({
|
||||||
progress: { current, next },
|
current,
|
||||||
|
next,
|
||||||
layouts: { screen },
|
layouts: { screen },
|
||||||
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
}: HeaderInterpolationProps): HeaderInterpolatedStyle {
|
||||||
const progress = add(current, next ? next : 0);
|
const progress = add(current.progress, next ? next.progress : 0);
|
||||||
const translateX = interpolate(progress, {
|
const translateX = interpolate(progress, {
|
||||||
inputRange: [0, 1, 2],
|
inputRange: [0, 1, 2],
|
||||||
outputRange: I18nManager.isRTL
|
outputRange: I18nManager.isRTL
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import { Platform } from 'react-native';
|
|||||||
|
|
||||||
const ANDROID_VERSION_PIE = 28;
|
const ANDROID_VERSION_PIE = 28;
|
||||||
|
|
||||||
// Standard iOS navigation transition
|
/**
|
||||||
|
* Standard iOS navigation transition.
|
||||||
|
*/
|
||||||
export const SlideFromRightIOS: TransitionPreset = {
|
export const SlideFromRightIOS: TransitionPreset = {
|
||||||
gestureDirection: 'horizontal',
|
gestureDirection: 'horizontal',
|
||||||
transitionSpec: {
|
transitionSpec: {
|
||||||
@@ -28,7 +30,9 @@ export const SlideFromRightIOS: TransitionPreset = {
|
|||||||
headerStyleInterpolator: forFade,
|
headerStyleInterpolator: forFade,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard iOS navigation transition for modals
|
/**
|
||||||
|
* Standard iOS navigation transition for modals.
|
||||||
|
*/
|
||||||
export const ModalSlideFromBottomIOS: TransitionPreset = {
|
export const ModalSlideFromBottomIOS: TransitionPreset = {
|
||||||
gestureDirection: 'vertical',
|
gestureDirection: 'vertical',
|
||||||
transitionSpec: {
|
transitionSpec: {
|
||||||
@@ -39,7 +43,9 @@ export const ModalSlideFromBottomIOS: TransitionPreset = {
|
|||||||
headerStyleInterpolator: forNoAnimation,
|
headerStyleInterpolator: forNoAnimation,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard iOS modal presentation style (introduced in iOS 13)
|
/**
|
||||||
|
* Standard iOS modal presentation style (introduced in iOS 13).
|
||||||
|
*/
|
||||||
export const ModalPresentationIOS: TransitionPreset = {
|
export const ModalPresentationIOS: TransitionPreset = {
|
||||||
gestureDirection: 'vertical',
|
gestureDirection: 'vertical',
|
||||||
transitionSpec: {
|
transitionSpec: {
|
||||||
@@ -50,7 +56,9 @@ export const ModalPresentationIOS: TransitionPreset = {
|
|||||||
headerStyleInterpolator: forNoAnimation,
|
headerStyleInterpolator: forNoAnimation,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard Android navigation transition when opening or closing an Activity on Android < 9
|
/**
|
||||||
|
* Standard Android navigation transition when opening or closing an Activity on Android < 9 (Oreo).
|
||||||
|
*/
|
||||||
export const FadeFromBottomAndroid: TransitionPreset = {
|
export const FadeFromBottomAndroid: TransitionPreset = {
|
||||||
gestureDirection: 'vertical',
|
gestureDirection: 'vertical',
|
||||||
transitionSpec: {
|
transitionSpec: {
|
||||||
@@ -61,7 +69,9 @@ export const FadeFromBottomAndroid: TransitionPreset = {
|
|||||||
headerStyleInterpolator: forNoAnimation,
|
headerStyleInterpolator: forNoAnimation,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard Android navigation transition when opening or closing an Activity on Android >= 9
|
/**
|
||||||
|
* Standard Android navigation transition when opening or closing an Activity on Android >= 9 (Pie).
|
||||||
|
*/
|
||||||
export const RevealFromBottomAndroid: TransitionPreset = {
|
export const RevealFromBottomAndroid: TransitionPreset = {
|
||||||
gestureDirection: 'vertical',
|
gestureDirection: 'vertical',
|
||||||
transitionSpec: {
|
transitionSpec: {
|
||||||
@@ -72,6 +82,9 @@ export const RevealFromBottomAndroid: TransitionPreset = {
|
|||||||
headerStyleInterpolator: forNoAnimation,
|
headerStyleInterpolator: forNoAnimation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default navigation transition for the current platform.
|
||||||
|
*/
|
||||||
export const DefaultTransition = Platform.select({
|
export const DefaultTransition = Platform.select({
|
||||||
ios: SlideFromRightIOS,
|
ios: SlideFromRightIOS,
|
||||||
default:
|
default:
|
||||||
@@ -80,6 +93,9 @@ export const DefaultTransition = Platform.select({
|
|||||||
: RevealFromBottomAndroid,
|
: RevealFromBottomAndroid,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default modal transition for the current platform.
|
||||||
|
*/
|
||||||
export const ModalTransition = Platform.select({
|
export const ModalTransition = Platform.select({
|
||||||
ios: ModalSlideFromBottomIOS,
|
ios: ModalSlideFromBottomIOS,
|
||||||
default: DefaultTransition,
|
default: DefaultTransition,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { Easing } from 'react-native-reanimated';
|
import { Easing } from 'react-native-reanimated';
|
||||||
import { TransitionSpec } from '../types';
|
import { TransitionSpec } from '../types';
|
||||||
|
|
||||||
// These are the exact values from UINavigationController's animation configuration
|
/**
|
||||||
|
* Exact values from UINavigationController's animation configuration.
|
||||||
|
*/
|
||||||
export const TransitionIOSSpec: TransitionSpec = {
|
export const TransitionIOSSpec: TransitionSpec = {
|
||||||
timing: 'spring',
|
animation: 'spring',
|
||||||
config: {
|
config: {
|
||||||
stiffness: 1000,
|
stiffness: 1000,
|
||||||
damping: 500,
|
damping: 500,
|
||||||
@@ -14,27 +16,36 @@ export const TransitionIOSSpec: TransitionSpec = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// See http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
|
/**
|
||||||
|
* Configuration for activity open animation from Android Nougat.
|
||||||
|
* See http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
|
||||||
|
*/
|
||||||
export const FadeInFromBottomAndroidSpec: TransitionSpec = {
|
export const FadeInFromBottomAndroidSpec: TransitionSpec = {
|
||||||
timing: 'timing',
|
animation: 'timing',
|
||||||
config: {
|
config: {
|
||||||
duration: 350,
|
duration: 350,
|
||||||
easing: Easing.out(Easing.poly(5)),
|
easing: Easing.out(Easing.poly(5)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// See http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/res/res/anim/activity_close_exit.xml
|
/**
|
||||||
|
* Configuration for activity close animation from Android Nougat.
|
||||||
|
* See http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/res/res/anim/activity_close_exit.xml
|
||||||
|
*/
|
||||||
export const FadeOutToBottomAndroidSpec: TransitionSpec = {
|
export const FadeOutToBottomAndroidSpec: TransitionSpec = {
|
||||||
timing: 'timing',
|
animation: 'timing',
|
||||||
config: {
|
config: {
|
||||||
duration: 150,
|
duration: 150,
|
||||||
easing: Easing.in(Easing.linear),
|
easing: Easing.in(Easing.linear),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// See http://androidxref.com/9.0.0_r3/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
|
/**
|
||||||
|
* Approximate configuration for activity open animation from Android Pie.
|
||||||
|
* See http://androidxref.com/9.0.0_r3/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
|
||||||
|
*/
|
||||||
export const RevealFromBottomAndroidSpec: TransitionSpec = {
|
export const RevealFromBottomAndroidSpec: TransitionSpec = {
|
||||||
timing: 'timing',
|
animation: 'timing',
|
||||||
config: {
|
config: {
|
||||||
duration: 425,
|
duration: 425,
|
||||||
// This is super rough approximation of the path used for the curve by android
|
// This is super rough approximation of the path used for the curve by android
|
||||||
|
|||||||
@@ -45,14 +45,12 @@ function StackNavigator({
|
|||||||
() =>
|
() =>
|
||||||
navigation.addListener &&
|
navigation.addListener &&
|
||||||
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
|
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
|
||||||
|
const isFocused = navigation.isFocused();
|
||||||
|
|
||||||
// Run the operation in the next frame so we're sure all listeners have been run
|
// Run the operation in the next frame so we're sure all listeners have been run
|
||||||
// This is necessary to know if preventDefault() has been called
|
// This is necessary to know if preventDefault() has been called
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
if (
|
if (state.index > 0 && isFocused && !e.defaultPrevented) {
|
||||||
state.index > 0 &&
|
|
||||||
navigation.isFocused() &&
|
|
||||||
!e.defaultPrevented
|
|
||||||
) {
|
|
||||||
// When user taps on already focused tab and we're inside the tab,
|
// When user taps on already focused tab and we're inside the tab,
|
||||||
// reset the stack to replicate native behaviour
|
// reset the stack to replicate native behaviour
|
||||||
navigation.dispatch({
|
navigation.dispatch({
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export type StackNavigationProp<
|
|||||||
* @param [params] Params object for the route.
|
* @param [params] Params object for the route.
|
||||||
*/
|
*/
|
||||||
push<RouteName extends keyof ParamList>(
|
push<RouteName extends keyof ParamList>(
|
||||||
...args: ParamList[RouteName] extends void
|
...args: ParamList[RouteName] extends (undefined | any)
|
||||||
? [RouteName]
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
: [RouteName, ParamList[RouteName]]
|
: [RouteName, ParamList[RouteName]]
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
@@ -405,28 +405,33 @@ export type TimingConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type TransitionSpec =
|
export type TransitionSpec =
|
||||||
| { timing: 'spring'; config: SpringConfig }
|
| { animation: 'spring'; config: SpringConfig }
|
||||||
| { timing: 'timing'; config: TimingConfig };
|
| { animation: 'timing'; config: TimingConfig };
|
||||||
|
|
||||||
export type CardInterpolationProps = {
|
export type CardInterpolationProps = {
|
||||||
|
/**
|
||||||
|
* Values for the current screen.
|
||||||
|
*/
|
||||||
|
current: {
|
||||||
|
/**
|
||||||
|
* Animated node representing the progress value of the current screen.
|
||||||
|
*/
|
||||||
|
progress: Animated.Node<number>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Values for the current screen the screen after this one in the stack.
|
||||||
|
* This can be `undefined` in case the screen animating is the last one.
|
||||||
|
*/
|
||||||
|
next?: {
|
||||||
|
/**
|
||||||
|
* Animated node representing the progress value of the next screen.
|
||||||
|
*/
|
||||||
|
progress: Animated.Node<number>;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* The index of the card in the stack.
|
* The index of the card in the stack.
|
||||||
*/
|
*/
|
||||||
index: number;
|
index: number;
|
||||||
/**
|
|
||||||
* Animated nodes representing the progress of the animation.
|
|
||||||
*/
|
|
||||||
progress: {
|
|
||||||
/**
|
|
||||||
* Progress value of the current screen.
|
|
||||||
*/
|
|
||||||
current: Animated.Node<number>;
|
|
||||||
/**
|
|
||||||
* Progress value for the screen after this one in the stack.
|
|
||||||
* This can be `undefined` in case the screen animating is the last one.
|
|
||||||
*/
|
|
||||||
next?: Animated.Node<number>;
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Animated node representing whether the card is closing.
|
* Animated node representing whether the card is closing.
|
||||||
*/
|
*/
|
||||||
@@ -467,18 +472,23 @@ export type CardStyleInterpolator = (
|
|||||||
|
|
||||||
export type HeaderInterpolationProps = {
|
export type HeaderInterpolationProps = {
|
||||||
/**
|
/**
|
||||||
* Animated nodes representing the progress of the animation.
|
* Values for the current screen (the screen which owns this header).
|
||||||
*/
|
*/
|
||||||
progress: {
|
current: {
|
||||||
/**
|
/**
|
||||||
* Progress value of the current screen (the screen which owns this header).
|
* Animated node representing the progress value of the current screen.
|
||||||
*/
|
*/
|
||||||
current: Animated.Node<number>;
|
progress: Animated.Node<number>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Values for the current screen the screen after this one in the stack.
|
||||||
|
* This can be `undefined` in case the screen animating is the last one.
|
||||||
|
*/
|
||||||
|
next?: {
|
||||||
/**
|
/**
|
||||||
* Progress value for the screen after this one in the stack.
|
* Animated node representing the progress value of the next screen.
|
||||||
* This can be `undefined` in case the screen animating is the last one.
|
|
||||||
*/
|
*/
|
||||||
next?: Animated.Node<number>;
|
progress: Animated.Node<number>;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Layout measurements for various items we use for animation.
|
* Layout measurements for various items we use for animation.
|
||||||
|
|||||||
@@ -121,10 +121,8 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
|||||||
leftLabelLayout: Layout | undefined
|
leftLabelLayout: Layout | undefined
|
||||||
) =>
|
) =>
|
||||||
styleInterpolator({
|
styleInterpolator({
|
||||||
progress: {
|
current: { progress: current },
|
||||||
current,
|
next: next && { progress: next },
|
||||||
next,
|
|
||||||
},
|
|
||||||
layouts: {
|
layouts: {
|
||||||
screen: layout,
|
screen: layout,
|
||||||
title: titleLayout,
|
title: titleLayout,
|
||||||
|
|||||||
@@ -202,7 +202,11 @@ export default class Card extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closing !== prevProps.closing) {
|
if (closing !== prevProps.closing) {
|
||||||
this.isClosing.setValue(closing ? TRUE : FALSE);
|
// If the style updates during render, setting the value here doesn't work
|
||||||
|
// We need to defer it a bit so the animation starts properly
|
||||||
|
requestAnimationFrame(() =>
|
||||||
|
this.isClosing.setValue(closing ? TRUE : FALSE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +271,17 @@ export default class Card extends React.Component<Props> {
|
|||||||
finished: new Value(FALSE),
|
finished: new Value(FALSE),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleTransitionEnd = () => {
|
||||||
|
this.isRunningAnimation = false;
|
||||||
|
this.interpolatedStyle = this.getInterpolatedStyle(
|
||||||
|
this.props.styleInterpolator,
|
||||||
|
this.props.index,
|
||||||
|
this.props.current,
|
||||||
|
this.props.next,
|
||||||
|
this.props.layout
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
private runTransition = (isVisible: Binary | Animated.Node<number>) => {
|
private runTransition = (isVisible: Binary | Animated.Node<number>) => {
|
||||||
const { open: openingSpec, close: closingSpec } = this.props.transitionSpec;
|
const { open: openingSpec, close: closingSpec } = this.props.transitionSpec;
|
||||||
|
|
||||||
@@ -298,7 +313,7 @@ export default class Card extends React.Component<Props> {
|
|||||||
]),
|
]),
|
||||||
cond(
|
cond(
|
||||||
eq(isVisible, 1),
|
eq(isVisible, 1),
|
||||||
openingSpec.timing === 'spring'
|
openingSpec.animation === 'spring'
|
||||||
? memoizedSpring(
|
? memoizedSpring(
|
||||||
this.clock,
|
this.clock,
|
||||||
{ ...this.transitionState, velocity: this.transitionVelocity },
|
{ ...this.transitionState, velocity: this.transitionVelocity },
|
||||||
@@ -309,7 +324,7 @@ export default class Card extends React.Component<Props> {
|
|||||||
{ ...this.transitionState, frameTime: this.frameTime },
|
{ ...this.transitionState, frameTime: this.frameTime },
|
||||||
{ ...openingSpec.config, toValue: this.toValue }
|
{ ...openingSpec.config, toValue: this.toValue }
|
||||||
),
|
),
|
||||||
closingSpec.timing === 'spring'
|
closingSpec.animation === 'spring'
|
||||||
? memoizedSpring(
|
? memoizedSpring(
|
||||||
this.clock,
|
this.clock,
|
||||||
{ ...this.transitionState, velocity: this.transitionVelocity },
|
{ ...this.transitionState, velocity: this.transitionVelocity },
|
||||||
@@ -331,7 +346,9 @@ export default class Card extends React.Component<Props> {
|
|||||||
call([this.isVisible], ([value]: ReadonlyArray<Binary>) => {
|
call([this.isVisible], ([value]: ReadonlyArray<Binary>) => {
|
||||||
const isOpen = Boolean(value);
|
const isOpen = Boolean(value);
|
||||||
const { onOpen, onClose } = this.props;
|
const { onOpen, onClose } = this.props;
|
||||||
this.isRunningAnimation = false;
|
|
||||||
|
this.handleTransitionEnd();
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
onOpen(true);
|
onOpen(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -357,7 +374,7 @@ export default class Card extends React.Component<Props> {
|
|||||||
cond(neq(this.nextIsVisible, UNSET), [
|
cond(neq(this.nextIsVisible, UNSET), [
|
||||||
// Stop any running animations
|
// Stop any running animations
|
||||||
cond(clockRunning(this.clock), [
|
cond(clockRunning(this.clock), [
|
||||||
call([], () => (this.isRunningAnimation = false)),
|
call([], this.handleTransitionEnd),
|
||||||
stopClock(this.clock),
|
stopClock(this.clock),
|
||||||
]),
|
]),
|
||||||
set(this.gesture, 0),
|
set(this.gesture, 0),
|
||||||
@@ -500,10 +517,8 @@ export default class Card extends React.Component<Props> {
|
|||||||
) =>
|
) =>
|
||||||
styleInterpolator({
|
styleInterpolator({
|
||||||
index,
|
index,
|
||||||
progress: {
|
current: { progress: current },
|
||||||
current,
|
next: next && { progress: next },
|
||||||
next,
|
|
||||||
},
|
|
||||||
closing: this.isClosing,
|
closing: this.isClosing,
|
||||||
layouts: {
|
layouts: {
|
||||||
screen: layout,
|
screen: layout,
|
||||||
@@ -511,6 +526,18 @@ export default class Card extends React.Component<Props> {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Keep track of the style in a property to avoid changing the animated node when deps change
|
||||||
|
// The style shouldn't change in the middle of the animation and should refer to what was there at the start of it
|
||||||
|
// Which will be the last value when just before the render which started the animation
|
||||||
|
// We need to make sure to update this when the running animation ends
|
||||||
|
private interpolatedStyle = this.getInterpolatedStyle(
|
||||||
|
this.props.styleInterpolator,
|
||||||
|
this.props.index,
|
||||||
|
this.props.current,
|
||||||
|
this.props.next,
|
||||||
|
this.props.layout
|
||||||
|
);
|
||||||
|
|
||||||
private gestureActivationCriteria() {
|
private gestureActivationCriteria() {
|
||||||
const { layout, gestureDirection, gestureResponseDistance } = this.props;
|
const { layout, gestureDirection, gestureResponseDistance } = this.props;
|
||||||
|
|
||||||
@@ -551,35 +578,39 @@ export default class Card extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
index,
|
|
||||||
active,
|
active,
|
||||||
transparent,
|
transparent,
|
||||||
layout,
|
styleInterpolator,
|
||||||
|
index,
|
||||||
current,
|
current,
|
||||||
next,
|
next,
|
||||||
|
layout,
|
||||||
overlayEnabled,
|
overlayEnabled,
|
||||||
shadowEnabled,
|
shadowEnabled,
|
||||||
gestureEnabled,
|
gestureEnabled,
|
||||||
gestureDirection,
|
gestureDirection,
|
||||||
children,
|
children,
|
||||||
styleInterpolator,
|
|
||||||
containerStyle: customContainerStyle,
|
containerStyle: customContainerStyle,
|
||||||
contentStyle,
|
contentStyle,
|
||||||
...rest
|
...rest
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
if (!this.isRunningAnimation) {
|
||||||
|
this.interpolatedStyle = this.getInterpolatedStyle(
|
||||||
|
styleInterpolator,
|
||||||
|
index,
|
||||||
|
current,
|
||||||
|
next,
|
||||||
|
layout
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
containerStyle,
|
containerStyle,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
shadowStyle,
|
shadowStyle,
|
||||||
} = this.getInterpolatedStyle(
|
} = this.interpolatedStyle;
|
||||||
styleInterpolator,
|
|
||||||
index,
|
|
||||||
current,
|
|
||||||
next,
|
|
||||||
layout
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleGestureEvent = gestureEnabled
|
const handleGestureEvent = gestureEnabled
|
||||||
? gestureDirection === 'vertical'
|
? gestureDirection === 'vertical'
|
||||||
@@ -591,11 +622,10 @@ export default class Card extends React.Component<Props> {
|
|||||||
<StackGestureContext.Provider value={this.gestureRef}>
|
<StackGestureContext.Provider value={this.gestureRef}>
|
||||||
<View pointerEvents="box-none" {...rest}>
|
<View pointerEvents="box-none" {...rest}>
|
||||||
<Animated.Code exec={this.exec} />
|
<Animated.Code exec={this.exec} />
|
||||||
{this.props.gestureEnabled ? (
|
<Animated.Code
|
||||||
<Animated.Code exec={this.execNoGesture} />
|
key={gestureEnabled ? 'gesture-code' : 'no-gesture-code'}
|
||||||
) : (
|
exec={gestureEnabled ? this.execWithGesture : this.execNoGesture}
|
||||||
<Animated.Code exec={this.execWithGesture} />
|
/>
|
||||||
)}
|
|
||||||
{overlayEnabled && overlayStyle ? (
|
{overlayEnabled && overlayStyle ? (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
|
|||||||
@@ -167,11 +167,14 @@ export default class Stack extends React.Component<Props, State> {
|
|||||||
: undefined;
|
: undefined;
|
||||||
const next = nextRoute ? progress[nextRoute.key] : undefined;
|
const next = nextRoute ? progress[nextRoute.key] : undefined;
|
||||||
|
|
||||||
|
const oldScene = state.scenes[index];
|
||||||
const scene = {
|
const scene = {
|
||||||
route,
|
route,
|
||||||
previous: previousRoute,
|
previous: previousRoute,
|
||||||
descriptor:
|
descriptor:
|
||||||
props.descriptors[route.key] || state.descriptors[route.key],
|
props.descriptors[route.key] ||
|
||||||
|
state.descriptors[route.key] ||
|
||||||
|
(oldScene ? oldScene.descriptor : { options: {} }),
|
||||||
progress: {
|
progress: {
|
||||||
current,
|
current,
|
||||||
next,
|
next,
|
||||||
@@ -179,8 +182,6 @@ export default class Stack extends React.Component<Props, State> {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const oldScene = state.scenes[index];
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
oldScene &&
|
oldScene &&
|
||||||
scene.route === oldScene.route &&
|
scene.route === oldScene.route &&
|
||||||
|
|||||||
Reference in New Issue
Block a user