Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Rework the NavigationHeader
Browse files Browse the repository at this point in the history
Summary:Add ability to specify custom left, right components, and title component. Style the `NavigationBar` according to the Platform.

Refer ericvicenti/navigation-rfc#21

cc ericvicenti
Closes facebook#5971

Differential Revision: D3080601

Pulled By: ericvicenti

fb-gh-sync-id: 7b921cd36b4c2ec1edf6f52629f1f9890d272dfd
shipit-source-id: 7b921cd36b4c2ec1edf6f52629f1f9890d272dfd
  • Loading branch information
satya164 authored and Facebook Github Bot 2 committed Mar 22, 2016
1 parent 98aea63 commit 720c76f
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ class NavigationAnimatedExample extends React.Component {
_renderHeader(/*NavigationSceneRendererProps*/ props) {
return (
<NavigationHeader
{...props}
getTitle={state => state.key}
navigationProps={props}
renderTitleComponent={(navigationProps, scene) => {
return <NavigationHeader.Title>{scene.navigationState.key}</NavigationHeader.Title>;
}}
/>
);
}
Expand Down Expand Up @@ -144,7 +146,7 @@ const styles = StyleSheet.create({
flex: 1,
},
scrollView: {
marginTop: 64
marginTop: NavigationHeader.HEIGHT,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const {
} = React;

const {
AnimatedView: NavigationAnimatedView,
CardStack: NavigationCardStack,
Container: NavigationContainer,
Header: NavigationHeader,
Expand Down Expand Up @@ -178,8 +177,10 @@ class ExampleTabScreen extends React.Component {
_renderHeader(props: NavigationSceneRendererProps) {
return (
<NavigationHeader
{...props}
getTitle={state => stateTypeTitleMap(state)}
navigationProps={props}
renderTitleComponent={(navigationProps, scene) => {
return <NavigationHeader.Title>{stateTypeTitleMap(scene.navigationState)}</NavigationHeader.Title>;
}}
/>
);
}
Expand Down Expand Up @@ -284,7 +285,7 @@ const styles = StyleSheet.create({
flex: 1,
},
scrollView: {
marginTop: 64
marginTop: NavigationHeader.HEIGHT
},
tabContent: {
flex: 1,
Expand Down
14 changes: 5 additions & 9 deletions Examples/UIExplorer/UIExplorerApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,19 @@ const UIExplorerStateTitleMap = require('./UIExplorerStateTitleMap');

const {
Alert,
Animated,
AppRegistry,
NavigationExperimental,
SnapshotViewIOS,
StyleSheet,
Text,
TouchableHighlight,
View,
} = React;

const {
CardStack: NavigationCardStack,
Header: NavigationHeader,
Reducer: NavigationReducer,
RootContainer: NavigationRootContainer,
} = NavigationExperimental;

import type { Value } from 'Animated';

import type { NavigationSceneRendererProps } from 'NavigationTypeDefinition';

import type { UIExplorerNavigationState } from './UIExplorerNavigationReducer';
Expand Down Expand Up @@ -127,9 +121,11 @@ class UIExplorerApp extends React.Component {
_renderOverlay(props: NavigationSceneRendererProps): ReactElement {
return (
<NavigationHeader
{...props}
key={'header_' + props.scene.navigationState.key}
getTitle={UIExplorerStateTitleMap}
navigationProps={props}
renderTitleComponent={(navigationProps, scene) => {
return <NavigationHeader.Title>{UIExplorerStateTitleMap(scene.navigationState)}</NavigationHeader.Title>;
}}
/>
);
}
Expand Down Expand Up @@ -165,7 +161,7 @@ const styles = StyleSheet.create({
},
exampleContainer: {
flex: 1,
paddingTop: 60,
paddingTop: NavigationHeader.HEIGHT,
},
});

Expand Down
Loading

0 comments on commit 720c76f

Please sign in to comment.