Skip to content

Commit 51c6ff9

Browse files
committed
esling fixes in DefaultTabBar
1 parent 31981d5 commit 51c6ff9

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed

DefaultTabBar.js

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,27 @@
1-
'use strict';
2-
3-
var React = require('react-native');
4-
var {
1+
const React = require('react-native');
2+
const {
53
StyleSheet,
64
Text,
75
View,
86
Animated,
97
} = React;
10-
var Button = require('./Button');
11-
12-
var styles = StyleSheet.create({
13-
tab: {
14-
flex: 1,
15-
alignItems: 'center',
16-
justifyContent: 'center',
17-
paddingBottom: 10,
18-
},
19-
20-
tabs: {
21-
height: 50,
22-
flexDirection: 'row',
23-
justifyContent: 'space-around',
24-
borderWidth: 1,
25-
borderTopWidth: 0,
26-
borderLeftWidth: 0,
27-
borderRightWidth: 0,
28-
borderBottomColor: '#ccc',
29-
},
30-
});
8+
const Button = require('./Button');
319

32-
var DefaultTabBar = React.createClass({
10+
const DefaultTabBar = React.createClass({
3311
propTypes: {
3412
goToPage: React.PropTypes.func,
3513
activeTab: React.PropTypes.number,
3614
tabs: React.PropTypes.array,
37-
underlineColor : React.PropTypes.string,
38-
backgroundColor : React.PropTypes.string,
39-
activeTextColor : React.PropTypes.string,
40-
inactiveTextColor : React.PropTypes.string,
15+
underlineColor: React.PropTypes.string,
16+
backgroundColor: React.PropTypes.string,
17+
activeTextColor: React.PropTypes.string,
18+
inactiveTextColor: React.PropTypes.string,
4119
},
4220

4321
renderTabOption(name, page) {
44-
var isTabActive = this.props.activeTab === page;
45-
var activeTextColor = this.props.activeTextColor || "navy";
46-
var inactiveTextColor = this.props.inactiveTextColor || "black";
22+
const isTabActive = this.props.activeTab === page;
23+
const activeTextColor = this.props.activeTextColor || 'navy';
24+
const inactiveTextColor = this.props.inactiveTextColor || 'black';
4725

4826
return <Button
4927
key={name}
@@ -52,36 +30,55 @@ var DefaultTabBar = React.createClass({
5230
accessibilityTraits='button'
5331
onPress={() => this.props.goToPage(page)}
5432
>
55-
<View style={[styles.tab]}>
56-
<Text style={{color: isTabActive ? activeTextColor : inactiveTextColor, fontWeight: isTabActive ? 'bold' : 'normal'}}>
33+
<View style={styles.tab}>
34+
<Text style={{color: isTabActive ? activeTextColor : inactiveTextColor, fontWeight: isTabActive ? 'bold' : 'normal', }}>
5735
{name}
5836
</Text>
5937
</View>
6038
</Button>;
6139
},
6240

6341
render() {
64-
var containerWidth = this.props.containerWidth;
65-
var numberOfTabs = this.props.tabs.length;
66-
var tabUnderlineStyle = {
42+
const containerWidth = this.props.containerWidth;
43+
const numberOfTabs = this.props.tabs.length;
44+
const tabUnderlineStyle = {
6745
position: 'absolute',
6846
width: containerWidth / numberOfTabs,
6947
height: 4,
70-
backgroundColor: this.props.underlineColor || "navy",
48+
backgroundColor: this.props.underlineColor || 'navy',
7149
bottom: 0,
7250
};
7351

74-
var left = this.props.scrollValue.interpolate({
75-
inputRange: [0, 1], outputRange: [0, containerWidth / numberOfTabs]
52+
const left = this.props.scrollValue.interpolate({
53+
inputRange: [0, 1, ], outputRange: [0, containerWidth / numberOfTabs, ],
7654
});
7755

7856
return (
79-
<View style={[styles.tabs, {backgroundColor : this.props.backgroundColor || null}, this.props.style, ]}>
57+
<View style={[styles.tabs, {backgroundColor: this.props.backgroundColor || null, }, this.props.style, ]}>
8058
{this.props.tabs.map((tab, i) => this.renderTabOption(tab, i))}
81-
<Animated.View style={[tabUnderlineStyle, {left}]} />
59+
<Animated.View style={[tabUnderlineStyle, { left, }, ]} />
8260
</View>
8361
);
8462
},
8563
});
8664

65+
const styles = StyleSheet.create({
66+
tab: {
67+
flex: 1,
68+
alignItems: 'center',
69+
justifyContent: 'center',
70+
paddingBottom: 10,
71+
},
72+
tabs: {
73+
height: 50,
74+
flexDirection: 'row',
75+
justifyContent: 'space-around',
76+
borderWidth: 1,
77+
borderTopWidth: 0,
78+
borderLeftWidth: 0,
79+
borderRightWidth: 0,
80+
borderBottomColor: '#ccc',
81+
},
82+
});
83+
8784
module.exports = DefaultTabBar;

0 commit comments

Comments
 (0)