Skip to content

Commit 720c76f

Browse files
satya164Facebook Github Bot 2
authored and
Facebook Github Bot 2
committed
Rework the NavigationHeader
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
1 parent 98aea63 commit 720c76f

17 files changed

+338
-112
lines changed

Examples/UIExplorer/NavigationExperimental/NavigationAnimatedExample.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ class NavigationAnimatedExample extends React.Component {
9999
_renderHeader(/*NavigationSceneRendererProps*/ props) {
100100
return (
101101
<NavigationHeader
102-
{...props}
103-
getTitle={state => state.key}
102+
navigationProps={props}
103+
renderTitleComponent={(navigationProps, scene) => {
104+
return <NavigationHeader.Title>{scene.navigationState.key}</NavigationHeader.Title>;
105+
}}
104106
/>
105107
);
106108
}
@@ -144,7 +146,7 @@ const styles = StyleSheet.create({
144146
flex: 1,
145147
},
146148
scrollView: {
147-
marginTop: 64
149+
marginTop: NavigationHeader.HEIGHT,
148150
},
149151
});
150152

Examples/UIExplorer/NavigationExperimental/NavigationCompositionExample.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const {
2727
} = React;
2828

2929
const {
30-
AnimatedView: NavigationAnimatedView,
3130
CardStack: NavigationCardStack,
3231
Container: NavigationContainer,
3332
Header: NavigationHeader,
@@ -178,8 +177,10 @@ class ExampleTabScreen extends React.Component {
178177
_renderHeader(props: NavigationSceneRendererProps) {
179178
return (
180179
<NavigationHeader
181-
{...props}
182-
getTitle={state => stateTypeTitleMap(state)}
180+
navigationProps={props}
181+
renderTitleComponent={(navigationProps, scene) => {
182+
return <NavigationHeader.Title>{stateTypeTitleMap(scene.navigationState)}</NavigationHeader.Title>;
183+
}}
183184
/>
184185
);
185186
}
@@ -284,7 +285,7 @@ const styles = StyleSheet.create({
284285
flex: 1,
285286
},
286287
scrollView: {
287-
marginTop: 64
288+
marginTop: NavigationHeader.HEIGHT
288289
},
289290
tabContent: {
290291
flex: 1,

Examples/UIExplorer/UIExplorerApp.ios.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,19 @@ const UIExplorerStateTitleMap = require('./UIExplorerStateTitleMap');
2525

2626
const {
2727
Alert,
28-
Animated,
2928
AppRegistry,
3029
NavigationExperimental,
3130
SnapshotViewIOS,
3231
StyleSheet,
33-
Text,
34-
TouchableHighlight,
3532
View,
3633
} = React;
3734

3835
const {
3936
CardStack: NavigationCardStack,
4037
Header: NavigationHeader,
41-
Reducer: NavigationReducer,
4238
RootContainer: NavigationRootContainer,
4339
} = NavigationExperimental;
4440

45-
import type { Value } from 'Animated';
46-
4741
import type { NavigationSceneRendererProps } from 'NavigationTypeDefinition';
4842

4943
import type { UIExplorerNavigationState } from './UIExplorerNavigationReducer';
@@ -127,9 +121,11 @@ class UIExplorerApp extends React.Component {
127121
_renderOverlay(props: NavigationSceneRendererProps): ReactElement {
128122
return (
129123
<NavigationHeader
130-
{...props}
131124
key={'header_' + props.scene.navigationState.key}
132-
getTitle={UIExplorerStateTitleMap}
125+
navigationProps={props}
126+
renderTitleComponent={(navigationProps, scene) => {
127+
return <NavigationHeader.Title>{UIExplorerStateTitleMap(scene.navigationState)}</NavigationHeader.Title>;
128+
}}
133129
/>
134130
);
135131
}
@@ -165,7 +161,7 @@ const styles = StyleSheet.create({
165161
},
166162
exampleContainer: {
167163
flex: 1,
168-
paddingTop: 60,
164+
paddingTop: NavigationHeader.HEIGHT,
169165
},
170166
});
171167

0 commit comments

Comments
 (0)