mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 12:34:17 +00:00
50c2467905
Summary: Hi, This PR Solves this issue #3083. This PR solves the problem of default color on TabBar being always grey. Which looks great if the barTintColor is unchanged. However if we set the barTintColor to something else (like blue in example) text and icons become quite unreadable. ![simulator screen shot 27 apr 2016 21 58 40](https://cloud.githubusercontent.com/assets/12081272/14866402/e51c7120-0cc3-11e6-9570-097b686c160f.png) Commit (c206417) - Enable setting color of unselected tabs Solves this issue with a prop (unselectedTintColor) on TabBarIOS to which you just pass a color like you can for barTintColor and tintColor. This leaves us with a result that is on second picture. Notice the color of text on tabs. ![simulator screen shot 27 apr 2016 21 59 06](https://cloud.githubusercontent.com/assets/12081272/14866419/f77aa7e2-0cc3-11e6-8c90-33209009bc09.png) Or change it to yellow for demonstrating purposes ![simulator screen shot 27 apr 2016 21 59 13](https://cloud.githubusercontent.com/assets/1208 Closes https://github.com/facebook/react-native/pull/7264 Differential Revision: D3240924 Pulled By: nicklockwood fb-gh-sync-id: 14a0de28abd064756320b7a74f128c255caa6b12 fbshipit-source-id: 14a0de28abd064756320b7a74f128c255caa6b12
114 lines
4.3 KiB
JavaScript
114 lines
4.3 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
var React = require('react');
|
|
var ReactNative = require('react-native');
|
|
var {
|
|
StyleSheet,
|
|
TabBarIOS,
|
|
Text,
|
|
View,
|
|
} = ReactNative;
|
|
|
|
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==';
|
|
|
|
var TabBarExample = React.createClass({
|
|
statics: {
|
|
title: '<TabBarIOS>',
|
|
description: 'Tab-based navigation.',
|
|
},
|
|
|
|
displayName: 'TabBarExample',
|
|
|
|
getInitialState: function() {
|
|
return {
|
|
selectedTab: 'redTab',
|
|
notifCount: 0,
|
|
presses: 0,
|
|
};
|
|
},
|
|
|
|
_renderContent: function(color: string, pageText: string, num?: number) {
|
|
return (
|
|
<View style={[styles.tabContent, {backgroundColor: color}]}>
|
|
<Text style={styles.tabText}>{pageText}</Text>
|
|
<Text style={styles.tabText}>{num} re-renders of the {pageText}</Text>
|
|
</View>
|
|
);
|
|
},
|
|
|
|
render: function() {
|
|
return (
|
|
<TabBarIOS
|
|
unselectedTintColor="yellow"
|
|
tintColor="white"
|
|
barTintColor="darkslateblue">
|
|
<TabBarIOS.Item
|
|
title="Blue Tab"
|
|
icon={{uri: base64Icon, scale: 3}}
|
|
selected={this.state.selectedTab === 'blueTab'}
|
|
onPress={() => {
|
|
this.setState({
|
|
selectedTab: 'blueTab',
|
|
});
|
|
}}>
|
|
{this._renderContent('#414A8C', 'Blue Tab')}
|
|
</TabBarIOS.Item>
|
|
<TabBarIOS.Item
|
|
systemIcon="history"
|
|
badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
|
|
selected={this.state.selectedTab === 'redTab'}
|
|
onPress={() => {
|
|
this.setState({
|
|
selectedTab: 'redTab',
|
|
notifCount: this.state.notifCount + 1,
|
|
});
|
|
}}>
|
|
{this._renderContent('#783E33', 'Red Tab', this.state.notifCount)}
|
|
</TabBarIOS.Item>
|
|
<TabBarIOS.Item
|
|
icon={require('./flux.png')}
|
|
renderAsOriginal
|
|
title="More"
|
|
selected={this.state.selectedTab === 'greenTab'}
|
|
onPress={() => {
|
|
this.setState({
|
|
selectedTab: 'greenTab',
|
|
presses: this.state.presses + 1
|
|
});
|
|
}}>
|
|
{this._renderContent('#21551C', 'Green Tab', this.state.presses)}
|
|
</TabBarIOS.Item>
|
|
</TabBarIOS>
|
|
);
|
|
},
|
|
|
|
});
|
|
|
|
var styles = StyleSheet.create({
|
|
tabContent: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
},
|
|
tabText: {
|
|
color: 'white',
|
|
margin: 50,
|
|
},
|
|
});
|
|
|
|
module.exports = TabBarExample;
|