Skip to content

Commit 5358fb7

Browse files
committed
fix eslint warnings in example, migrate to es6 imports
1 parent 514fd1b commit 5358fb7

File tree

4 files changed

+57
-66
lines changed

4 files changed

+57
-66
lines changed
Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,104 @@
1-
'use strict';
2-
3-
var React = require('react-native');
4-
var {
1+
import React, {
52
StyleSheet,
63
Text,
74
View,
85
TouchableOpacity,
96
Animated,
10-
} = React;
7+
} from 'react-native';
118

12-
const Icon = require('react-native-vector-icons/Ionicons');
9+
import Icon from 'react-native-vector-icons/Ionicons';
1310

14-
var styles = StyleSheet.create({
15-
tab: {
16-
flex: 1,
17-
alignItems: 'center',
18-
justifyContent: 'center',
19-
paddingBottom: 10,
20-
},
21-
tabs: {
22-
height: 45,
23-
flexDirection: 'row',
24-
paddingTop: 5,
25-
borderWidth: 1,
26-
borderTopWidth: 0,
27-
borderLeftWidth: 0,
28-
borderRightWidth: 0,
29-
borderBottomColor: 'rgba(0,0,0,0.05)',
30-
},
31-
icon: {
32-
position: 'absolute',
33-
top: 0,
34-
left: 20,
35-
},
36-
});
37-
38-
var FacebookTabBar = React.createClass({
11+
const FacebookTabBar = React.createClass({
3912
selectedTabIcons: [],
4013
unselectedTabIcons: [],
4114

4215
propTypes: {
4316
goToPage: React.PropTypes.func,
4417
activeTab: React.PropTypes.number,
45-
tabs: React.PropTypes.array
18+
tabs: React.PropTypes.array,
4619
},
4720

4821
renderTabOption(name, page) {
49-
var isTabActive = this.props.activeTab === page;
22+
const isTabActive = this.props.activeTab === page;
5023

5124
return (
5225
<TouchableOpacity key={name} onPress={() => this.props.goToPage(page)} style={styles.tab}>
5326
<Icon name={name} size={30} color='#3B5998' style={styles.icon}
54-
ref={(icon) => { this.selectedTabIcons[page] = icon }}/>
27+
ref={(icon) => { this.selectedTabIcons[page] = icon; }}/>
5528
<Icon name={name} size={30} color='#ccc' style={styles.icon}
56-
ref={(icon) => { this.unselectedTabIcons[page] = icon }}/>
29+
ref={(icon) => { this.unselectedTabIcons[page] = icon; }}/>
5730
</TouchableOpacity>
5831
);
5932
},
6033

6134
componentDidMount() {
62-
this.setAnimationValue({value: this.props.activeTab});
35+
this.setAnimationValue({ value: this.props.activeTab, });
6336
this._listener = this.props.scrollValue.addListener(this.setAnimationValue);
6437
},
6538

66-
setAnimationValue({value}) {
67-
var currentPage = this.props.activeTab;
68-
39+
setAnimationValue({ value, }) {
6940
this.unselectedTabIcons.forEach((icon, i) => {
70-
var iconRef = icon;
41+
let iconRef = icon;
7142

7243
if (!icon.setNativeProps && icon !== null) {
73-
iconRef = icon.refs.icon_image
44+
iconRef = icon.refs.icon_image;
7445
}
7546

7647
if (value - i >= 0 && value - i <= 1) {
77-
iconRef.setNativeProps({ style: {opacity: value - i} });
48+
iconRef.setNativeProps({ style: { opacity: value - i, }, });
7849
}
7950
if (i - value >= 0 && i - value <= 1) {
80-
iconRef.setNativeProps({ style: {opacity: i - value} });
51+
iconRef.setNativeProps({ style: { opacity: i - value, }, });
8152
}
8253
});
8354
},
8455

8556
render() {
86-
var containerWidth = this.props.containerWidth;
87-
var numberOfTabs = this.props.tabs.length;
88-
var tabUnderlineStyle = {
57+
const containerWidth = this.props.containerWidth;
58+
const numberOfTabs = this.props.tabs.length;
59+
const tabUnderlineStyle = {
8960
position: 'absolute',
9061
width: containerWidth / numberOfTabs,
9162
height: 3,
9263
backgroundColor: '#3b5998',
9364
bottom: 0,
9465
};
9566

96-
var left = this.props.scrollValue.interpolate({
97-
inputRange: [0, 1], outputRange: [0, containerWidth / numberOfTabs]
67+
const left = this.props.scrollValue.interpolate({
68+
inputRange: [0, 1, ], outputRange: [0, containerWidth / numberOfTabs, ],
9869
});
9970

100-
return (
101-
<View>
102-
<View style={[styles.tabs, this.props.style, ]}>
103-
{this.props.tabs.map((tab, i) => this.renderTabOption(tab, i))}
104-
</View>
105-
<Animated.View style={[tabUnderlineStyle, {left}]} />
71+
return <View>
72+
<View style={[styles.tabs, this.props.style, ]}>
73+
{this.props.tabs.map((tab, i) => this.renderTabOption(tab, i))}
10674
</View>
107-
);
75+
<Animated.View style={[tabUnderlineStyle, { left, }, ]} />
76+
</View>;
77+
},
78+
});
79+
80+
const styles = StyleSheet.create({
81+
tab: {
82+
flex: 1,
83+
alignItems: 'center',
84+
justifyContent: 'center',
85+
paddingBottom: 10,
86+
},
87+
tabs: {
88+
height: 45,
89+
flexDirection: 'row',
90+
paddingTop: 5,
91+
borderWidth: 1,
92+
borderTopWidth: 0,
93+
borderLeftWidth: 0,
94+
borderRightWidth: 0,
95+
borderBottomColor: 'rgba(0,0,0,0.05)',
96+
},
97+
icon: {
98+
position: 'absolute',
99+
top: 0,
100+
left: 20,
108101
},
109102
});
110103

111-
module.exports = FacebookTabBar;
104+
export default FacebookTabBar;

examples/FacebookTabsExample/FacebookTabsExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ const OverlayExample = React.createClass({
9090
},
9191
});
9292

93-
module.exports = FacebookTabsExample;
94-
//module.exports = SimpleExample;
95-
//module.exports = ScrollableTabsExample;
96-
//module.exports = OverlayExample;
93+
export default FacebookTabsExample;
94+
//export default SimpleExample;
95+
//export default ScrollableTabsExample;
96+
//export default OverlayExample;
9797

9898
const styles = StyleSheet.create({
9999
container: {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var React = require('react-native');
2-
var { AppRegistry, } = React;
3-
var FacebookTabsExample = require('./FacebookTabsExample');
1+
import React, { AppRegistry, } from 'react-native';
2+
import FacebookTabsExample from './FacebookTabsExample';
43

54
AppRegistry.registerComponent('FacebookTabsExample', () => FacebookTabsExample);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var React = require('react-native');
2-
var { AppRegistry, } = React;
3-
var FacebookTabsExample = require('./FacebookTabsExample');
1+
import React, { AppRegistry, } from 'react-native';
2+
import FacebookTabsExample from './FacebookTabsExample';
43

54
AppRegistry.registerComponent('FacebookTabsExample', () => FacebookTabsExample);

0 commit comments

Comments
 (0)