Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions Examples/UIExplorer/NavigatorIOSColorsExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict';

var React = require('react-native');
var {
NavigatorIOS,
StatusBarIOS,
StyleSheet,
Text,
View
} = React;

var EmptyPage = React.createClass({

render: function() {
return (
<View style={styles.emptyPage}>
<Text style={styles.emptyPageText}>
{this.props.text}
</Text>
</View>
);
},

});

var NavigatorIOSColors = React.createClass({

statics: {
title: '<NavigatorIOS> - Custom',
description: 'iOS navigation with custom nav bar colors',
},

render: function() {
// Set StatusBar with light contents to get better contrast
StatusBarIOS.setStyle(StatusBarIOS.Style['lightContent']);

return (
<NavigatorIOS
style={styles.container}
initialRoute={{
component: EmptyPage,
title: '<NavigatorIOS>',
rightButtonTitle: 'Done',
onRightButtonPress: () => {
StatusBarIOS.setStyle(StatusBarIOS.Style['default']);
this.props.onExampleExit();
},
passProps: {
text: 'The nav bar has custom colors with tintColor,' +
'barTintColor and titleTextColor props.',
},
}}
tintColor='#FFFFFF'
barTintColor='#183E63'
titleTextColor='#FFFFFF'
/>
);
},

});

var styles = StyleSheet.create({
container: {
flex: 1,
},
emptyPage: {
flex: 1,
paddingTop: 64,
},
emptyPageText: {
margin: 10,
},
});

module.exports = NavigatorIOSColors;
8 changes: 8 additions & 0 deletions Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var {
View,
} = React;
var NavigatorExample = require('./Navigator/NavigatorExample');
var NavigatorIOSColorsExample = require('./NavigatorIOSColorsExample');

var { TestModule } = React.addons;

Expand All @@ -40,6 +41,7 @@ var COMPONENTS = [
require('./ListViewPagingExample'),
require('./MapViewExample'),
require('./NavigatorIOSExample'),
NavigatorIOSColorsExample,
NavigatorExample,
require('./PickerIOSExample'),
require('./ScrollViewExample'),
Expand Down Expand Up @@ -187,6 +189,12 @@ class UIExplorerList extends React.Component {
);
return;
}
if (example === NavigatorIOSColorsExample) {
this.props.onExternalExampleRequested(
NavigatorIOSColorsExample
);
return;
}
var Component = makeRenderable(example);
this.props.navigator.push({
title: Component.title,
Expand Down
14 changes: 13 additions & 1 deletion Libraries/Components/Navigation/NavigatorIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ var NavigatorIOS = React.createClass({
*/
tintColor: PropTypes.string,

/**
* The background color of the navigation bar
*/
barTintColor: PropTypes.string,

/**
* The text color of the navigation bar title
*/
titleTextColor: PropTypes.string,

},

navigator: (undefined: ?Object),
Expand Down Expand Up @@ -547,7 +557,9 @@ var NavigatorIOS = React.createClass({
backButtonTitle={route.backButtonTitle}
rightButtonTitle={route.rightButtonTitle}
onNavRightButtonTap={route.onRightButtonPress}
tintColor={this.props.tintColor}>
tintColor={this.props.tintColor}
barTintColor={this.props.barTintColor}
titleTextColor={this.props.titleTextColor}>
<Component
navigator={this.navigator}
route={route}
Expand Down
5 changes: 1 addition & 4 deletions React/Views/RCTWrapperViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ - (void)viewWillAppear:(BOOL)animated
bar.barTintColor = _navItem.barTintColor;
}
if (_navItem.tintColor) {
BOOL canSetTintColor = _navItem.barTintColor == nil;
if (canSetTintColor) {
bar.tintColor = _navItem.tintColor;
}
bar.tintColor = _navItem.tintColor;
}
if (_navItem.titleTextColor) {
[bar setTitleTextAttributes:@{NSForegroundColorAttributeName : _navItem.titleTextColor}];
Expand Down