From ac8c3392a03ead2a2c47b9e822b8327bbd6e41d6 Mon Sep 17 00:00:00 2001 From: tsai phan Date: Thu, 29 Jun 2017 13:24:40 +0800 Subject: [PATCH 1/2] route params, headerBackTitle fixups or so. --- types/react-navigation/index.d.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 1d07494104..6f2011da3c 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -5,6 +5,7 @@ // fangpenlin // abrahambotros // petejkim +// phanalpha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -86,7 +87,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 & { @@ -262,7 +263,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { headerTitleStyle?: Style, headerTintColor?: string, headerLeft?: React.ReactElement, - headerBackTitle?: string, + headerBackTitle?: string | null, headerTruncatedBackTitle?: string, headerBackTitleStyle?: Style, headerPressColorAndroid?: string, @@ -651,3 +652,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; From 9a456fefcf08ea5b6d0284524c2e7f130180134a Mon Sep 17 00:00:00 2001 From: tsai phan Date: Fri, 30 Jun 2017 12:28:18 +0800 Subject: [PATCH 2/2] [react-navigation] strictNullChecks, and tests. --- .../react-navigation-tests.tsx | 31 +++++++++++++++++++ types/react-navigation/tsconfig.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) 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": [