Merge pull request #17597 from phanalpha/master

[react-navigation] route params, headerBackTitle fixups or so.
This commit is contained in:
Paul van Brenk
2017-07-06 09:03:09 -07:00
committed by GitHub
3 changed files with 54 additions and 3 deletions
+22 -2
View File
@@ -6,6 +6,7 @@
// abrahambotros <https://github.com/abrahambotros>
// petejkim <https://github.com/petejkim>
// Kyle Roach <https://github.com/iRoachie>
// phanalpha <https://github.com/phanalpha>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -87,7 +88,7 @@ export type NavigationLeafRoute<Params> = {
* 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<NavigationLeafRouteParams> = NavigationLeafRoute<NavigationLeafRouteParams> & {
@@ -263,7 +264,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & {
headerTitleStyle?: Style,
headerTintColor?: string,
headerLeft?: React.ReactElement<any>,
headerBackTitle?: string,
headerBackTitle?: string | null,
headerTruncatedBackTitle?: string,
headerBackTitleStyle?: Style,
headerPressColorAndroid?: string,
@@ -676,3 +677,22 @@ export interface NavigationScreenProps<Params> {
/**
* 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<HeaderBackButtonProps>;
@@ -27,6 +27,7 @@ import {
TabNavigatorConfig,
Transitioner,
addNavigationHelpers,
HeaderBackButton,
} from 'react-navigation';
// Constants
@@ -97,6 +98,9 @@ class NextScreen extends React.Component<NextScreenProps, {}> {
}
}
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<CustomTransitionerProps, null>
}
}
/**
* Header
*/
function renderHeaderBackButton(schema: string): JSX.Element {
switch ( schema ) {
case 'compact':
return (
<HeaderBackButton />
);
default:
return (
<HeaderBackButton
onPress={() => 'noop'}
pressColorAndroid="#ccc"
title="Press Me"
titleStyle={{ color: '#333' }}
tintColor="#2196f3"
truncatedTitle="Press"
width={85}
/>
);
}
}
const initAction: NavigationInitAction = NavigationActions.init({
params: {
foo: "bar"
+1 -1
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [