[ReactNative] PropTypes for NavigationBars

This commit is contained in:
Philipp von Weitershausen 2015-03-30 15:35:04 -07:00
parent a2cfc5feca
commit a9167a29b7
2 changed files with 25 additions and 11 deletions

View File

@ -46,15 +46,12 @@ var TITLE_PROPS = Interpolators.map(() => {return {style: {}};});
var RIGHT_BUTTON_PROPS = Interpolators.map(() => {return {style: {}};});
/**
* TODO: Rename `observedTopOfStack` to `presentedIndex` in `NavigationStack`.
*/
var navStatePresentedIndex = function(navState) {
if (navState.presentedIndex !== undefined) {
return navState.presentedIndex;
} else {
return navState.observedTopOfStack;
}
// TODO: rename `observedTopOfStack` to `presentedIndex` in `NavigatorIOS`
return navState.observedTopOfStack;
};
@ -85,7 +82,12 @@ var NavigatorBreadcrumbNavigationBar = React.createClass({
titleContentForRoute: PropTypes.func,
iconForRoute: PropTypes.func,
}),
navigationBarStyles: PropTypes.number,
navState: React.PropTypes.shape({
routeStack: React.PropTypes.arrayOf(React.PropTypes.object),
idStack: React.PropTypes.arrayOf(React.PropTypes.number),
presentedIndex: React.PropTypes.number,
}),
navigationBarStyles: View.propTypes.style,
},
statics: {

View File

@ -34,19 +34,31 @@ var View = require('View');
var COMPONENT_NAMES = ['Title', 'LeftButton', 'RightButton'];
/**
* TODO (janzer): Rename `observedTopOfStack` to `presentedIndex` in `NavigationStack`.
*/
var navStatePresentedIndex = function(navState) {
if (navState.presentedIndex !== undefined) {
return navState.presentedIndex;
} else {
return navState.observedTopOfStack;
}
// TODO: rename `observedTopOfStack` to `presentedIndex` in `NavigatorIOS`
return navState.observedTopOfStack;
};
var NavigatorNavigationBar = React.createClass({
propTypes: {
navigator: React.PropTypes.object,
navigationBarRouteMapper: React.PropTypes.shape({
Title: React.PropTypes.func.isRequired,
LeftButton: React.PropTypes.func.isRequired,
RightButton: React.PropTypes.func.isRequired,
}),
navState: React.PropTypes.shape({
routeStack: React.PropTypes.arrayOf(React.PropTypes.object),
idStack: React.PropTypes.arrayOf(React.PropTypes.number),
presentedIndex: React.PropTypes.number,
}),
navigationBarStyles: View.propTypes.style,
},
statics: {
Styles: NavigatorNavigationBarStyles,
},