2015-03-06 00:36:41 +00:00
|
|
|
/**
|
2017-05-06 03:50:47 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2016-07-12 12:51:57 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
2015-03-24 20:25:39 +00:00
|
|
|
* @flow
|
2017-02-25 11:05:32 +00:00
|
|
|
* @providesModule TabBarIOSExample
|
2015-03-06 00:36:41 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 03:36:40 +00:00
|
|
|
var React = require('react');
|
|
|
|
var ReactNative = require('react-native');
|
2015-03-26 07:41:30 +00:00
|
|
|
var {
|
|
|
|
StyleSheet,
|
|
|
|
TabBarIOS,
|
|
|
|
Text,
|
|
|
|
View,
|
2016-04-09 03:36:40 +00:00
|
|
|
} = ReactNative;
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2015-08-25 12:55:20 +00:00
|
|
|
var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
|
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
class TabBarExample extends React.Component {
|
|
|
|
static title = '<TabBarIOS>';
|
|
|
|
static description = 'Tab-based navigation.';
|
|
|
|
static displayName = 'TabBarExample';
|
2015-07-07 23:19:40 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
state = {
|
|
|
|
selectedTab: 'redTab',
|
|
|
|
notifCount: 0,
|
|
|
|
presses: 0,
|
|
|
|
};
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
_renderContent = (color: string, pageText: string, num?: number) => {
|
2015-03-06 00:36:41 +00:00
|
|
|
return (
|
|
|
|
<View style={[styles.tabContent, {backgroundColor: color}]}>
|
|
|
|
<Text style={styles.tabText}>{pageText}</Text>
|
2015-07-24 02:01:18 +00:00
|
|
|
<Text style={styles.tabText}>{num} re-renders of the {pageText}</Text>
|
2015-03-06 00:36:41 +00:00
|
|
|
</View>
|
|
|
|
);
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-03-06 00:36:41 +00:00
|
|
|
return (
|
2015-05-26 23:40:56 +00:00
|
|
|
<TabBarIOS
|
2016-05-03 12:39:21 +00:00
|
|
|
unselectedTintColor="yellow"
|
2015-07-24 02:01:18 +00:00
|
|
|
tintColor="white"
|
2016-11-29 20:14:41 +00:00
|
|
|
unselectedItemTintColor="red"
|
2015-07-24 02:01:18 +00:00
|
|
|
barTintColor="darkslateblue">
|
2015-04-02 20:35:03 +00:00
|
|
|
<TabBarIOS.Item
|
|
|
|
title="Blue Tab"
|
2015-08-25 12:55:20 +00:00
|
|
|
icon={{uri: base64Icon, scale: 3}}
|
2015-03-06 00:36:41 +00:00
|
|
|
selected={this.state.selectedTab === 'blueTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'blueTab',
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
{this._renderContent('#414A8C', 'Blue Tab')}
|
2015-04-02 20:35:03 +00:00
|
|
|
</TabBarIOS.Item>
|
|
|
|
<TabBarIOS.Item
|
|
|
|
systemIcon="history"
|
|
|
|
badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
|
2016-11-29 19:37:47 +00:00
|
|
|
badgeColor="black"
|
2015-03-06 00:36:41 +00:00
|
|
|
selected={this.state.selectedTab === 'redTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'redTab',
|
|
|
|
notifCount: this.state.notifCount + 1,
|
|
|
|
});
|
|
|
|
}}>
|
2015-07-24 02:01:18 +00:00
|
|
|
{this._renderContent('#783E33', 'Red Tab', this.state.notifCount)}
|
2015-04-02 20:35:03 +00:00
|
|
|
</TabBarIOS.Item>
|
|
|
|
<TabBarIOS.Item
|
2015-09-28 19:22:26 +00:00
|
|
|
icon={require('./flux.png')}
|
2016-05-24 08:52:01 +00:00
|
|
|
selectedIcon={require('./relay.png')}
|
2016-05-03 12:39:21 +00:00
|
|
|
renderAsOriginal
|
2015-09-28 19:22:26 +00:00
|
|
|
title="More"
|
2015-03-06 00:36:41 +00:00
|
|
|
selected={this.state.selectedTab === 'greenTab'}
|
|
|
|
onPress={() => {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: 'greenTab',
|
|
|
|
presses: this.state.presses + 1
|
2015-05-14 15:58:31 +00:00
|
|
|
});
|
2015-03-06 00:36:41 +00:00
|
|
|
}}>
|
2015-07-24 02:01:18 +00:00
|
|
|
{this._renderContent('#21551C', 'Green Tab', this.state.presses)}
|
2015-04-02 20:35:03 +00:00
|
|
|
</TabBarIOS.Item>
|
2015-03-06 00:36:41 +00:00
|
|
|
</TabBarIOS>
|
|
|
|
);
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-06 00:36:41 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
tabContent: {
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
tabText: {
|
|
|
|
color: 'white',
|
|
|
|
margin: 50,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = TabBarExample;
|