2015-03-06 00:36:41 +00:00
|
|
|
/**
|
2015-03-28 05:18:47 +00:00
|
|
|
* The examples provided by Facebook are for non-commercial testing and
|
|
|
|
* evaluation purposes only.
|
2015-03-23 20:35:08 +00:00
|
|
|
*
|
2015-03-28 05:18:47 +00:00
|
|
|
* 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.
|
2015-03-24 20:25:39 +00:00
|
|
|
*
|
|
|
|
* @flow
|
2015-03-06 00:36:41 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-26 07:41:30 +00:00
|
|
|
var React = require('react-native');
|
|
|
|
var {
|
|
|
|
StyleSheet,
|
|
|
|
TabBarIOS,
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
} = React;
|
|
|
|
var TabBarItemIOS = TabBarIOS.Item;
|
2015-03-06 00:36:41 +00:00
|
|
|
var TabBarExample = React.createClass({
|
|
|
|
|
|
|
|
statics: {
|
|
|
|
title: '<TabBarIOS>',
|
|
|
|
description: 'Tab-based navigation.'
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
selectedTab: 'redTab',
|
|
|
|
notifCount: 0,
|
|
|
|
presses: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-03-24 20:25:39 +00:00
|
|
|
_renderContent: function(color: string, pageText: string) {
|
2015-03-06 00:36:41 +00:00
|
|
|
return (
|
|
|
|
<View style={[styles.tabContent, {backgroundColor: color}]}>
|
|
|
|
<Text style={styles.tabText}>{pageText}</Text>
|
|
|
|
<Text style={styles.tabText}>{this.state.presses} re-renders of this tab</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<TabBarIOS
|
|
|
|
selectedTab={this.state.selectedTab}>
|
|
|
|
<TabBarItemIOS
|
|
|
|
name="blueTab"
|
2015-03-23 20:47:47 +00:00
|
|
|
icon={_ix_DEPRECATED('favorites')}
|
2015-03-06 00:36:41 +00:00
|
|
|
accessibilityLabel="Blue Tab"
|
|
|
|
selected={this.state.selectedTab === 'blueTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'blueTab',
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
{this._renderContent('#414A8C', 'Blue Tab')}
|
|
|
|
</TabBarItemIOS>
|
|
|
|
<TabBarItemIOS
|
|
|
|
accessibilityLabel="Red Tab"
|
|
|
|
name="redTab"
|
2015-03-23 20:47:47 +00:00
|
|
|
icon={_ix_DEPRECATED('history')}
|
2015-03-06 00:36:41 +00:00
|
|
|
badgeValue={this.state.notifCount ? String(this.state.notifCount) : null}
|
|
|
|
selected={this.state.selectedTab === 'redTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'redTab',
|
|
|
|
notifCount: this.state.notifCount + 1,
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
{this._renderContent('#783E33', 'Red Tab')}
|
|
|
|
</TabBarItemIOS>
|
|
|
|
<TabBarItemIOS
|
|
|
|
name="greenTab"
|
2015-03-23 20:47:47 +00:00
|
|
|
icon={_ix_DEPRECATED('more')}
|
2015-03-06 00:36:41 +00:00
|
|
|
accessibilityLabel="Green Tab"
|
|
|
|
selected={this.state.selectedTab === 'greenTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'greenTab',
|
|
|
|
presses: this.state.presses + 1
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
{this._renderContent('#21551C', 'Green Tab')}
|
|
|
|
</TabBarItemIOS>
|
|
|
|
</TabBarIOS>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
tabContent: {
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
tabText: {
|
|
|
|
color: 'white',
|
|
|
|
margin: 50,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2015-03-23 20:47:47 +00:00
|
|
|
// This is needed because the actual image may not exist as a file and
|
|
|
|
// is used by the native code to load a system image.
|
|
|
|
// TODO(nicklockwood): How can this fit our require system?
|
|
|
|
function _ix_DEPRECATED(imageUri) {
|
|
|
|
return {
|
|
|
|
uri: imageUri,
|
|
|
|
isStatic: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-06 00:36:41 +00:00
|
|
|
module.exports = TabBarExample;
|