diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 6b821586dd..e8740523a6 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -6,6 +6,7 @@ // abrahambotros // petejkim // Kyle Roach +// phanalpha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -87,7 +88,7 @@ export type NavigationLeafRoute = { * Params passed to this route when navigating to it, * e.g. `{ car_id: 123 }` in a route that displays a car. */ - params?: Params, + params: Params, }; export type NavigationStateRoute = NavigationLeafRoute & { @@ -263,7 +264,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { headerTitleStyle?: Style, headerTintColor?: string, headerLeft?: React.ReactElement, - headerBackTitle?: string, + headerBackTitle?: string | null, headerTruncatedBackTitle?: string, headerBackTitleStyle?: Style, headerPressColorAndroid?: string, @@ -676,3 +677,22 @@ export interface NavigationScreenProps { /** * END CUSTOM CONVENIENCE INTERFACES */ + + +/* + * Header + */ + +// src/views/HeaderBackButton.js + +export interface HeaderBackButtonProps { + onPress?: () => void, + pressColorAndroid?: string, + title?: string, + titleStyle?: TextStyle, + tintColor?: string, + truncatedTitle?: string, + width?: number, +} + +export const HeaderBackButton: React.ComponentClass; diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 1840fd7ccf..caa8b37843 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -27,6 +27,7 @@ import { TabNavigatorConfig, Transitioner, addNavigationHelpers, + HeaderBackButton, } from 'react-navigation'; // Constants @@ -97,6 +98,9 @@ class NextScreen extends React.Component { } } +const navigationOptions = { + headerBackTitle: null, +}; const initialRouteParams: StartScreenNavigationParams = { id: 1, s: "Start", @@ -116,6 +120,7 @@ export const AppNavigator = StackNavigator( { initialRouteName: ROUTE_NAME_START_SCREEN, initialRouteParams, + navigationOptions, }, ); @@ -227,6 +232,32 @@ class CustomTransitioner extends React.Component } } +/** + * Header + */ +function renderHeaderBackButton(schema: string): JSX.Element { + switch ( schema ) { + case 'compact': + return ( + + ); + + default: + return ( + 'noop'} + pressColorAndroid="#ccc" + title="Press Me" + titleStyle={{ color: '#333' }} + tintColor="#2196f3" + truncatedTitle="Press" + width={85} + /> + ); + } +} + + const initAction: NavigationInitAction = NavigationActions.init({ params: { foo: "bar" diff --git a/types/react-navigation/tsconfig.json b/types/react-navigation/tsconfig.json index ad15863a78..bbf721c233 100644 --- a/types/react-navigation/tsconfig.json +++ b/types/react-navigation/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "jsx": "react", "typeRoots": [