mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Try to update type definition to new version of react-navigation 2.0.1
This commit is contained in:
Vendored
+303
-174
@@ -1,4 +1,4 @@
|
||||
// Type definitions for react-navigation 1.5
|
||||
// Type definitions for react-navigation 2.0.1
|
||||
// Project: https://github.com/react-navigation/react-navigation
|
||||
// Definitions by: Huhuanming <https://github.com/huhuanming>
|
||||
// mhcgrq <https://github.com/mhcgrq>
|
||||
@@ -16,11 +16,12 @@
|
||||
// Armando Assuncao <https://github.com/ArmandoAssuncao>
|
||||
// Ciaran Liedeman <https://github.com/cliedeman>
|
||||
// Edward Sammut Alessi <https://github.com/Slessi>
|
||||
// Jeremy Magrin <https://github.com/magrinj>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/**
|
||||
* Reference: https://github.com/react-navigation/react-navigation/tree/3f3ef6485c8932f49fddc3dd2c508629110bf2b6
|
||||
* Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06
|
||||
*
|
||||
* NOTE: Please update the commit/link above when updating to a new Flow
|
||||
* react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on
|
||||
@@ -43,15 +44,21 @@ export type AnimatedValue = any;
|
||||
|
||||
export type HeaderMode = 'float' | 'screen' | 'none';
|
||||
|
||||
export interface HeaderForceInset {
|
||||
horizontal?: string;
|
||||
vertical?: string,
|
||||
left?: string,
|
||||
right?: string,
|
||||
top?: string,
|
||||
bottom?: string,
|
||||
}
|
||||
|
||||
export interface HeaderProps extends NavigationSceneRendererProps {
|
||||
mode: HeaderMode;
|
||||
router: NavigationRouter<
|
||||
NavigationState,
|
||||
NavigationStackScreenOptions
|
||||
>;
|
||||
getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails<
|
||||
NavigationStackScreenOptions
|
||||
>;
|
||||
router: NavigationRouter<NavigationState, NavigationStackScreenOptions>;
|
||||
getScreenDetails: (
|
||||
navigationScene: NavigationScene
|
||||
) => NavigationScreenDetails<NavigationStackScreenOptions>;
|
||||
style: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
@@ -76,7 +83,9 @@ export interface NavigationState {
|
||||
routes: any[];
|
||||
}
|
||||
|
||||
export type NavigationRoute<Params = NavigationParams> = NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
|
||||
export type NavigationRoute<Params = NavigationParams> =
|
||||
| NavigationLeafRoute<Params>
|
||||
| NavigationStateRoute<Params>;
|
||||
|
||||
export interface NavigationLeafRoute<Params> {
|
||||
/**
|
||||
@@ -100,7 +109,9 @@ export interface NavigationLeafRoute<Params> {
|
||||
params?: Params;
|
||||
}
|
||||
|
||||
export type NavigationStateRoute<NavigationLeafRouteParams> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
|
||||
export type NavigationStateRoute<
|
||||
NavigationLeafRouteParams
|
||||
> = NavigationLeafRoute<NavigationLeafRouteParams> & NavigationState;
|
||||
|
||||
export type NavigationScreenOptionsGetter<Options> = (
|
||||
navigation: NavigationScreenProp<NavigationRoute<any>>,
|
||||
@@ -113,7 +124,10 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
|
||||
* an optional previous state. When the action is considered handled but the
|
||||
* state is unchanged, the output state is null.
|
||||
*/
|
||||
getStateForAction: (action: NavigationAction, lastState?: State) => (State | null);
|
||||
getStateForAction: (
|
||||
action: NavigationAction,
|
||||
lastState?: State
|
||||
) => State | null;
|
||||
|
||||
/**
|
||||
* Maps a URI-like string to an action. This can be mapped to a state
|
||||
@@ -122,14 +136,14 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
|
||||
getActionForPathAndParams: (
|
||||
path: string,
|
||||
params?: NavigationParams
|
||||
) => (NavigationAction | null);
|
||||
) => NavigationAction | null;
|
||||
|
||||
getPathAndParamsForState: (
|
||||
state: State
|
||||
) => {
|
||||
path: string,
|
||||
params?: NavigationParams,
|
||||
};
|
||||
path: string;
|
||||
params?: NavigationParams;
|
||||
};
|
||||
|
||||
getComponentForRouteName: (routeName: string) => NavigationComponent;
|
||||
|
||||
@@ -147,11 +161,8 @@ export interface NavigationRouter<State = NavigationState, Options = {}> {
|
||||
}
|
||||
|
||||
export type NavigationScreenOption<T> =
|
||||
T
|
||||
| ((
|
||||
navigation: NavigationScreenProp<NavigationRoute>,
|
||||
config: T
|
||||
) => T);
|
||||
| T
|
||||
| ((navigation: NavigationScreenProp<NavigationRoute>, config: T) => T);
|
||||
|
||||
export interface NavigationScreenDetails<T> {
|
||||
options: T;
|
||||
@@ -159,7 +170,9 @@ export interface NavigationScreenDetails<T> {
|
||||
navigation: NavigationScreenProp<NavigationRoute>;
|
||||
}
|
||||
|
||||
export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions;
|
||||
export type NavigationScreenOptions = NavigationStackScreenOptions &
|
||||
NavigationTabScreenOptions &
|
||||
NavigationDrawerScreenOptions;
|
||||
|
||||
export interface NavigationScreenConfigProps {
|
||||
navigation: NavigationScreenProp<NavigationRoute>;
|
||||
@@ -167,30 +180,34 @@ export interface NavigationScreenConfigProps {
|
||||
}
|
||||
|
||||
export type NavigationScreenConfig<Options> =
|
||||
Options
|
||||
| ((navigationOptionsContainer: NavigationScreenConfigProps & {
|
||||
navigationOptions: NavigationScreenProp<NavigationRoute>,
|
||||
}) => Options);
|
||||
| Options
|
||||
| ((
|
||||
navigationOptionsContainer: NavigationScreenConfigProps & {
|
||||
navigationOptions: NavigationScreenProp<NavigationRoute>;
|
||||
}
|
||||
) => Options);
|
||||
|
||||
export type NavigationComponent =
|
||||
NavigationScreenComponent<any, any, any>
|
||||
| NavigationNavigator<any, any, any>;
|
||||
| NavigationScreenComponent<any, any, any>
|
||||
| NavigationNavigator<any, any, any>
|
||||
| any;
|
||||
|
||||
export type NavigationScreenComponent<
|
||||
Params = NavigationParams,
|
||||
Options = {},
|
||||
Props = {}
|
||||
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> &
|
||||
{ navigationOptions?: NavigationScreenConfig<Options> };
|
||||
Params = NavigationParams,
|
||||
Options = {},
|
||||
Props = {}
|
||||
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> & {
|
||||
navigationOptions?: NavigationScreenConfig<Options>;
|
||||
};
|
||||
|
||||
export type NavigationNavigator<
|
||||
State = NavigationState,
|
||||
Options = {},
|
||||
Props = {}
|
||||
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
|
||||
router: NavigationRouter<State, Options>,
|
||||
navigationOptions?: NavigationScreenConfig<Options>,
|
||||
};
|
||||
State = NavigationState,
|
||||
Options = {},
|
||||
Props = {}
|
||||
> = React.ComponentType<NavigationNavigatorProps<Options, State> & Props> & {
|
||||
router: NavigationRouter<State, Options>;
|
||||
navigationOptions?: NavigationScreenConfig<Options>;
|
||||
};
|
||||
|
||||
export interface NavigationParams {
|
||||
[key: string]: any;
|
||||
@@ -206,7 +223,8 @@ export interface NavigationNavigateActionPayload {
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface NavigationNavigateAction extends NavigationNavigateActionPayload {
|
||||
export interface NavigationNavigateAction
|
||||
extends NavigationNavigateActionPayload {
|
||||
type: 'Navigation/NAVIGATE';
|
||||
}
|
||||
|
||||
@@ -226,7 +244,8 @@ export interface NavigationSetParamsActionPayload {
|
||||
params?: NavigationParams;
|
||||
}
|
||||
|
||||
export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload {
|
||||
export interface NavigationSetParamsAction
|
||||
extends NavigationSetParamsActionPayload {
|
||||
type: 'Navigation/SET_PARAMS';
|
||||
}
|
||||
|
||||
@@ -271,40 +290,69 @@ export interface NavigationPopToTopActionPayload {
|
||||
immediate?: boolean;
|
||||
}
|
||||
|
||||
export interface NavigationPopToTopAction extends NavigationPopToTopActionPayload {
|
||||
export interface NavigationPopToTopAction
|
||||
extends NavigationPopToTopActionPayload {
|
||||
type: 'Navigation/POP_TO_TOP';
|
||||
}
|
||||
|
||||
export interface NavigationStackViewConfig {
|
||||
mode?: 'card' | 'modal';
|
||||
headerMode?: HeaderMode;
|
||||
headerTransitionPreset?: 'fade-in-place' | 'uikit';
|
||||
cardStyle?: StyleProp<ViewStyle>;
|
||||
transitionConfig?: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps: NavigationTransitionProps,
|
||||
isModal: boolean,
|
||||
isModal: boolean
|
||||
) => TransitionConfig;
|
||||
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
|
||||
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
|
||||
onTransitionStart?: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
) => Promise<void> | void;
|
||||
onTransitionEnd?: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch Navigator
|
||||
*/
|
||||
|
||||
export interface NavigationSwitchRouterConfig {
|
||||
initialRouteName?: string;
|
||||
initialRouteParams?: NavigationParams;
|
||||
paths?: NavigationPathsConfig;
|
||||
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
|
||||
order?: string[];
|
||||
backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'`
|
||||
resetOnBlur?: boolean; // defaults to `true`
|
||||
}
|
||||
|
||||
export interface NavigationStackScreenOptions {
|
||||
title?: string;
|
||||
header?: (React.ReactElement<any> | ((headerProps: HeaderProps) => React.ReactElement<any>)) | null;
|
||||
header?:
|
||||
| (
|
||||
| React.ReactElement<any>
|
||||
| ((headerProps: HeaderProps) => React.ReactElement<any>))
|
||||
| null;
|
||||
headerTransparent?: boolean;
|
||||
headerTitle?: string | React.ReactElement<any>;
|
||||
headerTitleStyle?: StyleProp<TextStyle>;
|
||||
headerTintColor?: string;
|
||||
headerLeft?: React.ReactElement<any>;
|
||||
headerBackTitle?: string | null;
|
||||
headerBackImage?: React.ReactElement<any>;
|
||||
headerTruncatedBackTitle?: string;
|
||||
headerBackTitleStyle?: StyleProp<TextStyle>;
|
||||
headerPressColorAndroid?: string;
|
||||
headerRight?: React.ReactElement<any>;
|
||||
headerStyle?: StyleProp<ViewStyle>;
|
||||
headerForceInset?: HeaderForceInset;
|
||||
headerBackground?: React.ReactNode | React.ReactType;
|
||||
gesturesEnabled?: boolean;
|
||||
gestureResponseDistance?: { vertical?: number; horizontal?: number };
|
||||
gestureDirection?: 'default' | 'inverted';
|
||||
}
|
||||
|
||||
export interface NavigationStackRouterConfig {
|
||||
@@ -317,7 +365,7 @@ export interface NavigationStackRouterConfig {
|
||||
}
|
||||
|
||||
export type NavigationStackAction =
|
||||
NavigationInitAction
|
||||
| NavigationInitAction
|
||||
| NavigationNavigateAction
|
||||
| NavigationBackAction
|
||||
| NavigationSetParamsAction
|
||||
@@ -326,25 +374,30 @@ export type NavigationStackAction =
|
||||
| NavigationPopToTopAction;
|
||||
|
||||
export type NavigationTabAction =
|
||||
NavigationInitAction
|
||||
| NavigationInitAction
|
||||
| NavigationNavigateAction
|
||||
| NavigationBackAction;
|
||||
|
||||
export type NavigationAction =
|
||||
NavigationInitAction
|
||||
| NavigationInitAction
|
||||
| NavigationStackAction
|
||||
| NavigationTabAction;
|
||||
|
||||
export type NavigationRouteConfig = NavigationComponent | ({
|
||||
navigationOptions?: NavigationScreenConfig<any>,
|
||||
path?: string,
|
||||
} & NavigationScreenRouteConfig);
|
||||
export type NavigationRouteConfig =
|
||||
| NavigationComponent
|
||||
| ({
|
||||
navigationOptions?: NavigationScreenConfig<any>;
|
||||
path?: string;
|
||||
} & NavigationScreenRouteConfig);
|
||||
|
||||
export type NavigationScreenRouteConfig = NavigationComponent | {
|
||||
screen: NavigationComponent,
|
||||
} | {
|
||||
getScreen: () => NavigationComponent,
|
||||
};
|
||||
export type NavigationScreenRouteConfig =
|
||||
| NavigationComponent
|
||||
| {
|
||||
screen: NavigationComponent;
|
||||
}
|
||||
| {
|
||||
getScreen: () => NavigationComponent;
|
||||
};
|
||||
|
||||
export interface NavigationPathsConfig {
|
||||
[routeName: string]: string;
|
||||
@@ -360,45 +413,48 @@ export interface NavigationTabRouterConfig {
|
||||
backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute`
|
||||
}
|
||||
export interface TabScene {
|
||||
route: NavigationRoute;
|
||||
focused: boolean;
|
||||
index: number;
|
||||
tintColor?: string;
|
||||
route: NavigationRoute;
|
||||
focused: boolean;
|
||||
index: number;
|
||||
tintColor?: string;
|
||||
}
|
||||
export interface NavigationTabScreenOptions {
|
||||
title?: string;
|
||||
tabBarIcon?:
|
||||
React.ReactElement<any>
|
||||
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
|
||||
any
|
||||
> | null));
|
||||
| React.ReactElement<any>
|
||||
| ((
|
||||
options: { tintColor: string | null; focused: boolean }
|
||||
) => React.ReactElement<any> | null);
|
||||
tabBarLabel?:
|
||||
string
|
||||
| React.ReactElement<any>
|
||||
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
|
||||
any
|
||||
> | string | null));
|
||||
| string
|
||||
| React.ReactElement<any>
|
||||
| ((
|
||||
options: { tintColor: string | null; focused: boolean }
|
||||
) => React.ReactElement<any> | string | null);
|
||||
tabBarVisible?: boolean;
|
||||
tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string };
|
||||
tabBarOnPress?: (options: {
|
||||
scene: TabScene,
|
||||
jumpToIndex: (index: number) => void
|
||||
}) => void;
|
||||
tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string };
|
||||
tabBarOnPress?: (
|
||||
options: {
|
||||
scene: TabScene;
|
||||
jumpToIndex: (index: number) => void;
|
||||
}
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface NavigationDrawerScreenOptions {
|
||||
title?: string;
|
||||
drawerIcon?:
|
||||
React.ReactElement<any>
|
||||
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
|
||||
any
|
||||
> | null));
|
||||
| React.ReactElement<any>
|
||||
| ((
|
||||
options: { tintColor: string | null; focused: boolean }
|
||||
) => React.ReactElement<any> | null);
|
||||
drawerLabel?:
|
||||
string
|
||||
| React.ReactElement<any>
|
||||
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
|
||||
any
|
||||
> | null));
|
||||
| string
|
||||
| React.ReactElement<any>
|
||||
| ((
|
||||
options: { tintColor: string | null; focused: boolean }
|
||||
) => React.ReactElement<any> | null);
|
||||
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open';
|
||||
}
|
||||
|
||||
export interface NavigationRouteConfigMap {
|
||||
@@ -413,22 +469,20 @@ export interface NavigationProp<S> {
|
||||
}
|
||||
|
||||
export type EventType =
|
||||
| 'willFocus'
|
||||
| 'didFocus'
|
||||
| 'willBlur'
|
||||
| 'didBlur'
|
||||
| 'action';
|
||||
| 'willFocus'
|
||||
| 'didFocus'
|
||||
| 'willBlur'
|
||||
| 'didBlur'
|
||||
| 'action';
|
||||
|
||||
export interface NavigationEventPayload {
|
||||
type: EventType;
|
||||
action: NavigationAction;
|
||||
state: NavigationState;
|
||||
lastState: NavigationState;
|
||||
lastState: NavigationState | null | undefined;
|
||||
}
|
||||
|
||||
export type NavigationEventCallback = (
|
||||
payload: NavigationEventPayload
|
||||
) => void;
|
||||
export type NavigationEventCallback = (payload: NavigationEventPayload) => void;
|
||||
|
||||
export interface NavigationEventSubscription {
|
||||
remove: () => void;
|
||||
@@ -438,8 +492,14 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
state: S;
|
||||
dispatch: NavigationDispatch;
|
||||
goBack: (routeKey?: string | null) => boolean;
|
||||
dismiss: () => boolean;
|
||||
navigate(options: {
|
||||
routeName: string;
|
||||
routeName: string | {
|
||||
routeName: string;
|
||||
params?: NavigationParams;
|
||||
action?: NavigationNavigateAction;
|
||||
key?: string;
|
||||
};
|
||||
params?: NavigationParams;
|
||||
action?: NavigationAction;
|
||||
key?: string;
|
||||
@@ -447,7 +507,7 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
navigate(
|
||||
routeNameOrOptions: string,
|
||||
params?: NavigationParams,
|
||||
action?: NavigationAction,
|
||||
action?: NavigationAction
|
||||
): boolean;
|
||||
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
|
||||
setParams: (newParams: P) => boolean;
|
||||
@@ -467,6 +527,7 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
) => boolean;
|
||||
pop: (n?: number, params?: { immediate?: boolean }) => boolean;
|
||||
popToTop: (params?: { immediate?: boolean }) => boolean;
|
||||
isFocused: () => boolean;
|
||||
}
|
||||
|
||||
export interface NavigationNavigatorProps<O = {}, S = {}> {
|
||||
@@ -558,7 +619,7 @@ export type NavigationAnimationSetter = (
|
||||
lastState: NavigationState
|
||||
) => void;
|
||||
|
||||
export type NavigationSceneRenderer = () => (React.ReactElement<any> | null);
|
||||
export type NavigationSceneRenderer = () => React.ReactElement<any> | null;
|
||||
|
||||
export type NavigationStyleInterpolator = (
|
||||
props: NavigationSceneRendererProps
|
||||
@@ -567,50 +628,49 @@ export type NavigationStyleInterpolator = (
|
||||
export interface LayoutEvent {
|
||||
nativeEvent: {
|
||||
layout: {
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
},
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export type NavigatorType =
|
||||
| 'react-navigation/STACK'
|
||||
| 'react-navigation/TABS'
|
||||
| 'react-navigation/DRAWER';
|
||||
| 'react-navigation/STACK'
|
||||
| 'react-navigation/TABS'
|
||||
| 'react-navigation/DRAWER';
|
||||
|
||||
export function addNavigationHelpers<S = {}>(
|
||||
navigation: {
|
||||
state: S;
|
||||
dispatch: (action: NavigationAction) => any;
|
||||
addListener?: (
|
||||
eventName: string,
|
||||
callback: NavigationEventCallback
|
||||
) => NavigationEventSubscription;
|
||||
}
|
||||
): NavigationScreenProp<S>;
|
||||
|
||||
export interface NavigationContainerProps {
|
||||
export interface NavigationContainerProps<S = {}, O = {}> {
|
||||
uriPrefix?: string | RegExp;
|
||||
onNavigationStateChange?: (
|
||||
prevNavigationState: NavigationState,
|
||||
nextNavigationState: NavigationState,
|
||||
action: NavigationAction,
|
||||
) => void;
|
||||
action: NavigationAction
|
||||
) => void | null | undefined;
|
||||
navigation?: NavigationScreenProp<S>;
|
||||
persistenceKey?: string | null | undefined;
|
||||
renderLoadingExperimental?: React.ComponentType<{}>,
|
||||
screenProps?: any;
|
||||
navigationOptions?: O;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
export interface NavigationContainerComponent extends React.Component<
|
||||
export interface NavigationContainerComponent
|
||||
extends React.Component<
|
||||
NavigationContainerProps & NavigationNavigatorProps<any>
|
||||
> {
|
||||
dispatch: NavigationDispatch;
|
||||
}
|
||||
|
||||
export interface NavigationContainer extends React.ComponentClass<
|
||||
export interface NavigationContainer
|
||||
extends React.ComponentClass<
|
||||
NavigationContainerProps & NavigationNavigatorProps<any>
|
||||
> {
|
||||
new(props: NavigationContainerProps & NavigationNavigatorProps<any>, context?: any): NavigationContainerComponent;
|
||||
new(
|
||||
props: NavigationContainerProps & NavigationNavigatorProps<any>,
|
||||
context?: any
|
||||
): NavigationContainerComponent;
|
||||
|
||||
router: NavigationRouter<any, any>;
|
||||
screenProps: { [key: string]: any };
|
||||
@@ -618,29 +678,43 @@ export interface NavigationContainer extends React.ComponentClass<
|
||||
state: { nav: NavigationState | null };
|
||||
}
|
||||
|
||||
export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig {
|
||||
export interface StackNavigatorConfig
|
||||
extends NavigationStackViewConfig,
|
||||
NavigationStackRouterConfig {
|
||||
containerOptions?: any;
|
||||
}
|
||||
|
||||
// Return createNavigationContainer
|
||||
export function StackNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
stackConfig?: StackNavigatorConfig,
|
||||
stackConfig?: StackNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createStackNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
stackConfig?: StackNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export interface SwitchNavigatorConfig {
|
||||
initialRouteName: string;
|
||||
resetOnBlur?: boolean;
|
||||
paths?: NavigationPathsConfig;
|
||||
backBehavior?: 'none' | 'initialRoute';
|
||||
backBehavior?: 'none' | 'intialRoute';
|
||||
}
|
||||
|
||||
// Return createNavigationContainer
|
||||
export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig;
|
||||
|
||||
export function SwitchNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
switchConfig?: SwitchNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createSwitchNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
switchConfig?: SwitchNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
// DrawerItems
|
||||
export const DrawerItems: React.ReactType;
|
||||
|
||||
@@ -655,21 +729,28 @@ export interface DrawerViewConfig {
|
||||
contentOptions?: any;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig {
|
||||
export interface DrawerNavigatorConfig
|
||||
extends NavigationTabRouterConfig,
|
||||
DrawerViewConfig {
|
||||
containerConfig?: any;
|
||||
contentOptions?: {
|
||||
activeTintColor?: string,
|
||||
activeBackgroundColor?: string,
|
||||
inactiveTintColor?: string,
|
||||
inactiveBackgroundColor?: string,
|
||||
style?: StyleProp<ViewStyle>,
|
||||
labelStyle?: StyleProp<TextStyle>,
|
||||
activeTintColor?: string;
|
||||
activeBackgroundColor?: string;
|
||||
inactiveTintColor?: string;
|
||||
inactiveBackgroundColor?: string;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
labelStyle?: StyleProp<TextStyle>;
|
||||
};
|
||||
}
|
||||
|
||||
export function DrawerNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawerConfig?: DrawerNavigatorConfig,
|
||||
drawerConfig?: DrawerNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createDrawerNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawerConfig?: DrawerNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
/**
|
||||
@@ -681,23 +762,23 @@ export interface TabViewConfig {
|
||||
tabBarComponent?: React.ReactType;
|
||||
tabBarPosition?: 'top' | 'bottom';
|
||||
tabBarOptions?: {
|
||||
activeTintColor?: string,
|
||||
allowFontScaling?: boolean,
|
||||
activeBackgroundColor?: string,
|
||||
inactiveTintColor?: string,
|
||||
inactiveBackgroundColor?: string,
|
||||
showLabel?: boolean,
|
||||
style?: StyleProp<ViewStyle>,
|
||||
labelStyle?: StyleProp<TextStyle>,
|
||||
iconStyle?: StyleProp<ViewStyle>,
|
||||
activeTintColor?: string;
|
||||
allowFontScaling?: boolean;
|
||||
activeBackgroundColor?: string;
|
||||
inactiveTintColor?: string;
|
||||
inactiveBackgroundColor?: string;
|
||||
showLabel?: boolean;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
labelStyle?: StyleProp<TextStyle>;
|
||||
iconStyle?: StyleProp<ViewStyle>;
|
||||
// Top
|
||||
showIcon?: boolean,
|
||||
upperCaseLabel?: boolean,
|
||||
pressColor?: string,
|
||||
pressOpacity?: number,
|
||||
scrollEnabled?: boolean,
|
||||
tabStyle?: StyleProp<ViewStyle>,
|
||||
indicatorStyle?: StyleProp<ViewStyle>,
|
||||
showIcon?: boolean;
|
||||
upperCaseLabel?: boolean;
|
||||
pressColor?: string;
|
||||
pressOpacity?: number;
|
||||
scrollEnabled?: boolean;
|
||||
tabStyle?: StyleProp<ViewStyle>;
|
||||
indicatorStyle?: StyleProp<ViewStyle>;
|
||||
};
|
||||
swipeEnabled?: boolean;
|
||||
animationEnabled?: boolean;
|
||||
@@ -705,16 +786,33 @@ export interface TabViewConfig {
|
||||
}
|
||||
|
||||
// From navigators/TabNavigator.js
|
||||
export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig {
|
||||
export interface TabNavigatorConfig
|
||||
extends NavigationTabRouterConfig,
|
||||
TabViewConfig {
|
||||
lazy?: boolean;
|
||||
removeClippedSubviews?: boolean;
|
||||
initialLayout?: { height: number, width: number };
|
||||
initialLayout?: { height: number; width: number };
|
||||
}
|
||||
|
||||
// From navigators/TabNavigator.js
|
||||
export function TabNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawConfig?: TabNavigatorConfig,
|
||||
drawConfig?: TabNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createTabNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawConfig?: TabNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createBottomTabNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawConfig?: TabNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export function createMaterialTopNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap,
|
||||
drawConfig?: TabNavigatorConfig
|
||||
): NavigationContainer;
|
||||
|
||||
export interface TabBarTopProps {
|
||||
@@ -729,15 +827,17 @@ export interface TabBarTopProps {
|
||||
tabBarPosition: string;
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
jumpToIndex: (index: number) => void;
|
||||
getLabel: (scene: TabScene) => (React.ReactNode | string);
|
||||
getLabel: (scene: TabScene) => React.ReactNode | string;
|
||||
getOnPress: (
|
||||
previousScene: NavigationRoute,
|
||||
scene: TabScene
|
||||
) => (args: {
|
||||
previousScene: NavigationRoute,
|
||||
scene: TabScene,
|
||||
jumpToIndex: (index: number) => void,
|
||||
}) => void;
|
||||
) => (
|
||||
args: {
|
||||
previousScene: NavigationRoute;
|
||||
scene: TabScene;
|
||||
jumpToIndex: (index: number) => void;
|
||||
}
|
||||
) => void;
|
||||
renderIcon: (scene: TabScene) => React.ReactElement<any>;
|
||||
labelStyle?: TextStyle;
|
||||
iconStyle?: ViewStyle;
|
||||
@@ -754,15 +854,17 @@ export interface TabBarBottomProps {
|
||||
position: AnimatedValue;
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
jumpToIndex: (index: number) => void;
|
||||
getLabel: (scene: TabScene) => (React.ReactNode | string);
|
||||
getLabel: (scene: TabScene) => React.ReactNode | string;
|
||||
getOnPress: (
|
||||
previousScene: NavigationRoute,
|
||||
scene: TabScene
|
||||
) => (args: {
|
||||
previousScene: NavigationRoute,
|
||||
scene: TabScene,
|
||||
jumpToIndex: (index: number) => void,
|
||||
}) => void;
|
||||
) => (
|
||||
args: {
|
||||
previousScene: NavigationRoute;
|
||||
scene: TabScene;
|
||||
jumpToIndex: (index: number) => void;
|
||||
}
|
||||
) => void;
|
||||
getTestIDProps: (scene: TabScene) => (scene: TabScene) => any;
|
||||
renderIcon: (scene: TabScene) => React.ReactNode;
|
||||
style?: ViewStyle;
|
||||
@@ -789,12 +891,18 @@ export namespace NavigationActions {
|
||||
const POP_TO_TOP: 'Navigation/POP_TO_TOP';
|
||||
|
||||
function init(options?: NavigationInitActionPayload): NavigationInitAction;
|
||||
function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction;
|
||||
function navigate(
|
||||
options: NavigationNavigateActionPayload
|
||||
): NavigationNavigateAction;
|
||||
function reset(options: NavigationResetActionPayload): NavigationResetAction;
|
||||
function back(options?: NavigationBackActionPayload): NavigationBackAction;
|
||||
function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction;
|
||||
function setParams(
|
||||
options: NavigationSetParamsActionPayload
|
||||
): NavigationSetParamsAction;
|
||||
function pop(options: NavigationPopActionPayload): NavigationPopAction;
|
||||
function popToTop(options: NavigationPopToTopActionPayload): NavigationPopToTopAction;
|
||||
function popToTop(
|
||||
options: NavigationPopToTopActionPayload
|
||||
): NavigationPopToTopAction;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -807,8 +915,14 @@ export interface TransitionerProps {
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
) => NavigationTransitionSpec;
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise<void> | void;
|
||||
onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void;
|
||||
onTransitionStart?: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
) => Promise<void> | void;
|
||||
onTransitionEnd?: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
) => void;
|
||||
render: (
|
||||
transitionProps: NavigationTransitionProps,
|
||||
prevTransitionProps?: NavigationTransitionProps
|
||||
@@ -826,7 +940,7 @@ export interface TransitionerState {
|
||||
export class Transitioner extends React.Component<
|
||||
TransitionerProps,
|
||||
TransitionerState
|
||||
> { }
|
||||
> { }
|
||||
|
||||
/**
|
||||
* Tab Router
|
||||
@@ -853,12 +967,23 @@ export function StackRouter(
|
||||
*
|
||||
* @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js
|
||||
*/
|
||||
export interface NavigationDescriptor<Params = NavigationParams> {
|
||||
key: string;
|
||||
state: NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
|
||||
navigation: NavigationScreenProp<any>;
|
||||
getComponent: () => React.ComponentType<{}>;
|
||||
}
|
||||
|
||||
export type NavigationView<O, S> = React.ComponentType<{
|
||||
descriptors: { [key: string]: NavigationDescriptor };
|
||||
} & NavigationInjectedProps>;
|
||||
|
||||
export function createNavigator<C, S, Options>(
|
||||
view: NavigationView<Options, S>,
|
||||
router: NavigationRouter<S, Options>,
|
||||
routeConfigs?: NavigationRouteConfigMap,
|
||||
navigatorConfig?: {} | null,
|
||||
navigatorType?: NavigatorType
|
||||
): (NavigationView: React.ComponentClass<C>) => NavigationNavigator<C, S, Options>;
|
||||
): any;
|
||||
|
||||
/**
|
||||
* Create an HOC that injects the navigation and manages the navigation state
|
||||
@@ -879,7 +1004,10 @@ export function createNavigationContainer(
|
||||
* BEGIN CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export interface NavigationScreenProps<Params = NavigationParams, Options = any> {
|
||||
export interface NavigationScreenProps<
|
||||
Params = NavigationParams,
|
||||
Options = any
|
||||
> {
|
||||
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
|
||||
screenProps?: { [key: string]: any };
|
||||
navigationOptions?: NavigationScreenConfig<Options>;
|
||||
@@ -936,6 +1064,7 @@ export interface SafeAreaViewProps extends ViewProps {
|
||||
horizontal?: SafeAreaViewForceInsetValue;
|
||||
vertical?: SafeAreaViewForceInsetValue;
|
||||
};
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const SafeAreaView: React.ComponentClass<SafeAreaViewProps>;
|
||||
|
||||
Reference in New Issue
Block a user