mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-28 09:08:47 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eaec68860 | ||
|
|
6142f06bbd | ||
|
|
d342812102 | ||
|
|
5c13cea6c9 | ||
|
|
2433071930 | ||
|
|
dd03234e2d | ||
|
|
3bd15d3f8b | ||
|
|
2b27bcd134 | ||
|
|
3aee211c73 |
12
example/README.md
Normal file
12
example/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Navigation Playground Example
|
||||
|
||||
The NavigationPlayground example app includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
yarn bootstrap # in the react-navigation root directory
|
||||
yarn example start
|
||||
```
|
||||
|
||||
You can view this example application directly on Android phones by visiting scanning the QR code on [this site](https://exp.host/@react-navigation/NavigationPlayground) with the [Expo app](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en).
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation",
|
||||
"version": "4.0.5",
|
||||
"version": "4.0.8",
|
||||
"description": "Routing and navigation for your React Native apps",
|
||||
"main": "src/react-navigation.js",
|
||||
"types": "typescript/react-navigation.d.ts",
|
||||
|
||||
27
src/react-navigation.js
vendored
27
src/react-navigation.js
vendored
@@ -1,4 +1,29 @@
|
||||
export * from '@react-navigation/core';
|
||||
export * from '@react-navigation/native';
|
||||
|
||||
export * from './deprecations';
|
||||
// Export each item individually so that they can be evaluated lazily
|
||||
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy
|
||||
export {
|
||||
createNavigationContainer,
|
||||
createStackNavigator,
|
||||
createBottomTabNavigator,
|
||||
createMaterialTopTabNavigator,
|
||||
createDrawerNavigator,
|
||||
StackGestureContext,
|
||||
DrawerGestureContext,
|
||||
DrawerRouter,
|
||||
DrawerActions,
|
||||
Transitioner,
|
||||
StackView,
|
||||
StackViewCard,
|
||||
StackViewTransitionConfigs,
|
||||
Header,
|
||||
HeaderTitle,
|
||||
HeaderBackButton,
|
||||
HeaderStyleInterpolator,
|
||||
DrawerView,
|
||||
DrawerItems,
|
||||
DrawerSidebar,
|
||||
BottomTabBar,
|
||||
MaterialTopTabBar,
|
||||
} from './deprecations';
|
||||
|
||||
179
typescript/react-navigation.d.ts
vendored
179
typescript/react-navigation.d.ts
vendored
@@ -164,9 +164,13 @@ declare module 'react-navigation' {
|
||||
params?: NavigationParams;
|
||||
};
|
||||
|
||||
getComponentForRouteName: (routeName: string) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
|
||||
getComponentForRouteName: (
|
||||
routeName: string
|
||||
) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
|
||||
|
||||
getComponentForState: (state: State) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
|
||||
getComponentForState: (
|
||||
state: State
|
||||
) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
|
||||
|
||||
getActionCreators: (
|
||||
route: NavigationRoute,
|
||||
@@ -186,20 +190,36 @@ declare module 'react-navigation' {
|
||||
getScreenOptions: NavigationScreenOptionsGetter<Options>;
|
||||
}
|
||||
|
||||
export type NavigationScreenComponent<Options, NavigationScreenPropType> = React.ComponentType<any> & {
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
export type NavigationScreenComponent<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
> = React.ComponentType<any> & {
|
||||
navigationOptions?: NavigationScreenConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
>;
|
||||
};
|
||||
|
||||
export interface NavigationScreenConfigProps<NavigationScreenPropType> {
|
||||
export interface NavigationScreenConfigProps<
|
||||
NavigationScreenPropType,
|
||||
ScreenProps = unknown
|
||||
> {
|
||||
navigation: NavigationScreenPropType;
|
||||
screenProps: unknown;
|
||||
screenProps: ScreenProps;
|
||||
theme: SupportedThemes;
|
||||
}
|
||||
|
||||
export type NavigationScreenConfig<Options, NavigationScreenPropType> =
|
||||
export type NavigationScreenConfig<
|
||||
Options,
|
||||
NavigationScreenPropType,
|
||||
ScreenProps = unknown
|
||||
> =
|
||||
| Options
|
||||
| ((
|
||||
navigationOptionsContainer: NavigationScreenConfigProps<NavigationScreenPropType> & {
|
||||
navigationOptionsContainer: NavigationScreenConfigProps<
|
||||
NavigationScreenPropType,
|
||||
ScreenProps
|
||||
> & {
|
||||
navigationOptions: Options;
|
||||
}
|
||||
) => Options);
|
||||
@@ -208,7 +228,10 @@ declare module 'react-navigation' {
|
||||
| NavigationScreenComponent<Options, NavigationPropType>
|
||||
| NavigationNavigator<Options, NavigationPropType>;
|
||||
|
||||
export type NavigationNavigator<Options, NavigationPropType> = React.ComponentType<NavigationNavigatorProps<Options>> & {
|
||||
export type NavigationNavigator<
|
||||
Options,
|
||||
NavigationPropType
|
||||
> = React.ComponentType<NavigationNavigatorProps<Options>> & {
|
||||
router: NavigationRouter<Options>;
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationPropType>;
|
||||
};
|
||||
@@ -345,7 +368,7 @@ declare module 'react-navigation' {
|
||||
|
||||
export interface NavigationJumpToActionPayload {
|
||||
routeName: string;
|
||||
key: string;
|
||||
key?: string;
|
||||
params?: NavigationParams;
|
||||
}
|
||||
|
||||
@@ -399,6 +422,33 @@ declare module 'react-navigation' {
|
||||
config?: NavigationSwitchRouterConfig
|
||||
): NavigationRouter<any, any>;
|
||||
|
||||
export type NavigationSwitchProp<
|
||||
State = NavigationRoute,
|
||||
Params = NavigationParams
|
||||
> = NavigationScreenProp<State, Params> & {
|
||||
jumpTo(routeName: string, key?: string): void;
|
||||
};
|
||||
|
||||
export type NavigationSwitchScreenProps<
|
||||
Params = NavigationParams,
|
||||
ScreenProps = unknown
|
||||
> = {
|
||||
theme: SupportedThemes;
|
||||
navigation: NavigationSwitchProp<NavigationRoute, Params>;
|
||||
screenProps: ScreenProps;
|
||||
};
|
||||
|
||||
export type NavigationSwitchScreenComponent<
|
||||
Params = NavigationParams,
|
||||
ScreenProps = unknown
|
||||
> = React.ComponentType<NavigationSwitchScreenProps<Params, ScreenProps>> & {
|
||||
navigationOptions?: NavigationScreenConfig<
|
||||
{},
|
||||
NavigationSwitchProp<NavigationRoute, Params>,
|
||||
ScreenProps
|
||||
>;
|
||||
};
|
||||
|
||||
export type NavigationStackAction =
|
||||
| NavigationInitAction
|
||||
| NavigationNavigateAction
|
||||
@@ -437,9 +487,17 @@ declare module 'react-navigation' {
|
||||
| NavigationComponent<Options, NavigationScreenPropType>
|
||||
| (
|
||||
| { screen: NavigationComponent<Options, NavigationScreenPropType> }
|
||||
| { getScreen(): NavigationScreenComponent<Options, NavigationScreenPropType> }) & {
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
params?: { [key: string]: any }
|
||||
| {
|
||||
getScreen(): NavigationScreenComponent<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
>;
|
||||
}) & {
|
||||
navigationOptions?: NavigationScreenConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
>;
|
||||
params?: { [key: string]: any };
|
||||
path?: string;
|
||||
};
|
||||
|
||||
@@ -458,7 +516,10 @@ declare module 'react-navigation' {
|
||||
}
|
||||
|
||||
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType> {
|
||||
[routeName: string]: NavigationRouteConfig<Options, NavigationScreenPropType>;
|
||||
[routeName: string]: NavigationRouteConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
>;
|
||||
}
|
||||
|
||||
export type NavigationDispatch = (action: NavigationAction) => boolean;
|
||||
@@ -542,12 +603,16 @@ declare module 'react-navigation' {
|
||||
dangerouslyGetParent: () => NavigationScreenProp<S> | undefined;
|
||||
}
|
||||
|
||||
export interface NavigationNavigatorProps<O = {}, S = {}> {
|
||||
export interface NavigationNavigatorProps<
|
||||
Options = {},
|
||||
State = {},
|
||||
ScreenProps = unknown
|
||||
> {
|
||||
theme?: SupportedThemes | 'no-preference';
|
||||
detached?: boolean;
|
||||
navigation?: NavigationProp<S>;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: O;
|
||||
navigation?: NavigationProp<State>;
|
||||
screenProps?: ScreenProps;
|
||||
navigationOptions?: Options;
|
||||
}
|
||||
|
||||
export type NavigatorType =
|
||||
@@ -555,7 +620,11 @@ declare module 'react-navigation' {
|
||||
| 'react-navigation/TABS'
|
||||
| 'react-navigation/DRAWER';
|
||||
|
||||
export interface NavigationContainerProps<S = {}, O = {}> {
|
||||
export interface NavigationContainerProps<
|
||||
State = {},
|
||||
Options = {},
|
||||
ScreenProps = unknown
|
||||
> {
|
||||
uriPrefix?: string | RegExp;
|
||||
/**
|
||||
* Controls whether the navigation container handles URLs opened via 'Linking'
|
||||
@@ -568,7 +637,7 @@ declare module 'react-navigation' {
|
||||
nextNavigationState: NavigationState,
|
||||
action: NavigationAction
|
||||
) => void | null | undefined;
|
||||
navigation?: NavigationScreenProp<S>;
|
||||
navigation?: NavigationScreenProp<State>;
|
||||
/*
|
||||
* This prop is no longer supported. Use `loadNavigationState` and
|
||||
* `persistNavigationState` instead.
|
||||
@@ -579,8 +648,8 @@ declare module 'react-navigation' {
|
||||
persistNavigationState?: (state: NavigationState) => Promise<any>;
|
||||
|
||||
renderLoadingExperimental?: React.ComponentType;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: O;
|
||||
screenProps?: ScreenProps;
|
||||
navigationOptions?: Options;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
@@ -613,13 +682,13 @@ declare module 'react-navigation' {
|
||||
backBehavior?: 'none' | 'initialRoute';
|
||||
}
|
||||
|
||||
// Return createNavigationContainer
|
||||
export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig;
|
||||
|
||||
export function createSwitchNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap<SwitchNavigatorConfig, NavigationScreenProp<NavigationRoute>>,
|
||||
routeConfigMap: NavigationRouteConfigMap<
|
||||
SwitchNavigatorConfig,
|
||||
NavigationScreenProp<NavigationRoute>
|
||||
>,
|
||||
switchConfig?: SwitchNavigatorConfig
|
||||
): NavigationContainer;
|
||||
): NavigationNavigator<{}, NavigationProp<NavigationState>>;
|
||||
|
||||
/**
|
||||
* NavigationActions
|
||||
@@ -738,25 +807,41 @@ declare module 'react-navigation' {
|
||||
getComponent: () => React.ComponentType;
|
||||
}
|
||||
|
||||
export type NavigationView<O, S> = React.ComponentType<
|
||||
export type NavigationView<
|
||||
Options,
|
||||
State,
|
||||
ScreenProps = unknown
|
||||
> = React.ComponentType<
|
||||
{
|
||||
descriptors: { [key: string]: NavigationDescriptor };
|
||||
navigationConfig: O;
|
||||
screenProps?: unknown;
|
||||
navigationConfig: Options;
|
||||
screenProps?: ScreenProps;
|
||||
} & NavigationInjectedProps
|
||||
>;
|
||||
|
||||
export type CreateNavigatorConfig<NavigatorConfig, RouterConfig, Options, NavigationScreenPropType> = NavigatorConfig & RouterConfig & {
|
||||
defaultNavigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
navigationOptions?: NavigationScreenConfig<{ [key: string]: any }, NavigationScreenProp<NavigationRoute>>;
|
||||
}
|
||||
export type CreateNavigatorConfig<
|
||||
NavigatorConfig,
|
||||
RouterConfig,
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
> = NavigatorConfig &
|
||||
RouterConfig & {
|
||||
defaultNavigationOptions?: NavigationScreenConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
>;
|
||||
navigationOptions?: NavigationScreenConfig<
|
||||
{ [key: string]: any },
|
||||
NavigationScreenProp<NavigationRoute>
|
||||
>;
|
||||
};
|
||||
|
||||
export function createNavigator<S, Options>(
|
||||
view: NavigationView<Options, S>,
|
||||
router: NavigationRouter<S, Options>,
|
||||
navigatorConfig?: {} | null,
|
||||
navigatorConfig?: {},
|
||||
navigatorType?: NavigatorType
|
||||
): any;
|
||||
): NavigationNavigator<Options, NavigationProp<NavigationState>>;
|
||||
|
||||
/**
|
||||
* Create an HOC that injects the navigation and manages the navigation state
|
||||
@@ -779,28 +864,6 @@ declare module 'react-navigation' {
|
||||
Component: NavigationNavigator<Options, NavigationPropType>
|
||||
): NavigationContainer;
|
||||
|
||||
/**
|
||||
* END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS
|
||||
*/
|
||||
|
||||
/**
|
||||
* BEGIN CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export interface NavigationScreenProps<
|
||||
Params = NavigationParams,
|
||||
Options = {},
|
||||
NavigationScreenPropType = NavigationScreenProp<NavigationRoute>
|
||||
> {
|
||||
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
}
|
||||
|
||||
/**
|
||||
* END CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type InferProps<
|
||||
|
||||
Reference in New Issue
Block a user