Added the ability to set an image title in the NavigatorIOS

Summary:
This pull request adds support for setting an image title in `NavigatorIOS`. It sets the `titleView` property of `UINavigationItem`.

Added an example into `UIExplorer`

<img width="487" alt="ex" src="https://cloud.githubusercontent.com/assets/289640/16147578/3d552606-3484-11e6-9a26-1e8c113ace03.png">

The code follows the same style as the rest of `RCTNavItem` and `RCTWrapperViewController`.
Closes https://github.com/facebook/react-native/pull/8182

Differential Revision: D3469073

Pulled By: javache

fbshipit-source-id: 2d3e4bad534f92b6e6b24a6b74f2993f3a8c9012
This commit is contained in:
alvaromb
2016-06-23 08:27:29 -07:00
committed by Facebook Github Bot 0
parent 39f524d8e5
commit 9bd80cbc26
7 changed files with 59 additions and 25 deletions

View File

@@ -24,7 +24,6 @@ var View = require('View');
var invariant = require('fbjs/lib/invariant');
var logError = require('logError');
var requireNativeComponent = require('requireNativeComponent');
var resolveAssetSource = require('resolveAssetSource');
var TRANSITIONER_REF = 'transitionerRef';
@@ -52,30 +51,31 @@ var NavigatorTransitionerIOS = React.createClass({
});
type Route = {
component: Function;
title: string;
passProps?: Object;
backButtonTitle?: string;
backButtonIcon?: Object;
leftButtonTitle?: string;
leftButtonIcon?: Object;
onLeftButtonPress?: Function;
rightButtonTitle?: string;
rightButtonIcon?: Object;
onRightButtonPress?: Function;
wrapperStyle?: any;
component: Function,
title: string,
titleImage?: Object,
passProps?: Object,
backButtonTitle?: string,
backButtonIcon?: Object,
leftButtonTitle?: string,
leftButtonIcon?: Object,
onLeftButtonPress?: Function,
rightButtonTitle?: string,
rightButtonIcon?: Object,
onRightButtonPress?: Function,
wrapperStyle?: any,
};
type State = {
idStack: Array<number>;
routeStack: Array<Route>;
requestedTopOfStack: number;
observedTopOfStack: number;
progress: number;
fromIndex: number;
toIndex: number;
makingNavigatorRequest: boolean;
updatingAllIndicesAtOrBeyond: ?number;
idStack: Array<number>,
routeStack: Array<Route>,
requestedTopOfStack: number,
observedTopOfStack: number,
progress: number,
fromIndex: number,
toIndex: number,
makingNavigatorRequest: boolean,
updatingAllIndicesAtOrBeyond: ?number,
}
type Event = Object;
@@ -185,6 +185,11 @@ var NavigatorIOS = React.createClass({
*/
title: PropTypes.string.isRequired,
/**
* If set, the image will appear instead of the text title
*/
titleImage: Image.propTypes.source,
/**
* Specify additional props passed to the component. NavigatorIOS will
* automatically provide "route" and "navigator" components
@@ -404,8 +409,8 @@ var NavigatorIOS = React.createClass({
},
getChildContext: function(): {
onFocusRequested: Function;
focusEmitter: EventEmitter;
onFocusRequested: Function,
focusEmitter: EventEmitter,
} {
return {
onFocusRequested: this._handleFocusRequest,