Skip to content

Commit da9e63c

Browse files
committed
Add an example of the Facebook Android navigation bar
1 parent db1a9a4 commit da9e63c

File tree

18 files changed

+1485
-0
lines changed

18 files changed

+1485
-0
lines changed

examples/.DS_Store

6 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
10+
# Ignore react-tools where there are overlaps, but don't ignore anything that
11+
# react-native relies on
12+
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
13+
.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js
14+
.*/node_modules/react-tools/src/browser/ui/React.js
15+
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
16+
.*/node_modules/react-tools/src/event/EventPropagators.js
17+
18+
# Ignore commoner tests
19+
.*/node_modules/react-tools/node_modules/commoner/test/.*
20+
21+
# See https://github.com/facebook/flow/issues/442
22+
.*/react-tools/node_modules/commoner/lib/reader.js
23+
24+
# Ignore jest
25+
.*/react-native/node_modules/jest-cli/.*
26+
27+
[include]
28+
29+
[libs]
30+
node_modules/react-native/Libraries/react-native/react-native-interface.js
31+
32+
[options]
33+
module.system=haste
34+
35+
[version]
36+
0.11.0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# node.js
26+
#
27+
node_modules/
28+
npm-debug.log
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# node.js
25+
#
26+
node_modules/
27+
npm-debug.log
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
'use strict';
2+
3+
var React = require('react-native');
4+
var {
5+
StyleSheet,
6+
Text,
7+
View,
8+
TouchableOpacity,
9+
} = React;
10+
11+
var Icon = require('FAKIconImage');
12+
var deviceWidth = require('Dimensions').get('window').width;
13+
14+
var styles = StyleSheet.create({
15+
tab: {
16+
flex: 1,
17+
alignItems: 'center',
18+
justifyContent: 'center',
19+
paddingBottom: 10,
20+
},
21+
22+
tabs: {
23+
height: 40,
24+
flexDirection: 'row',
25+
paddingTop: 5,
26+
borderWidth: 1,
27+
borderTopWidth: 0,
28+
borderLeftWidth: 0,
29+
borderRightWidth: 0,
30+
borderBottomColor: 'rgba(0,0,0,0.05)',
31+
},
32+
});
33+
34+
var FacebookTabBar = React.createClass({
35+
selectedTabIcons: [],
36+
unselectedTabIcons: [],
37+
38+
propTypes: {
39+
goToPage: React.PropTypes.func,
40+
activeTab: React.PropTypes.number,
41+
tabs: React.PropTypes.array
42+
},
43+
44+
renderTabOption(name, page) {
45+
var isTabActive = this.props.activeTab === page;
46+
console.log(name);
47+
48+
return (
49+
<TouchableOpacity key={name} onPress={() => this.props.goToPage(page)}>
50+
<View style={[styles.tab]}>
51+
<Icon name={name} size={30} color='#3B5998' style={{width: 30, height: 30, position: 'absolute', top: 0, left: 20}}
52+
ref={(icon) => { this.selectedTabIcons[page] = icon }}/>
53+
<Icon name={name} size={30} color='#ccc' style={{width: 30, height: 30, position: 'absolute', top: 0, left: 20}}
54+
ref={(icon) => { this.unselectedTabIcons[page] = icon }}/>
55+
</View>
56+
</TouchableOpacity>
57+
);
58+
},
59+
60+
setAnimationValue(value) {
61+
var currentPage = this.props.activeTab;
62+
63+
this.unselectedTabIcons.forEach((icon, i) => {
64+
if (value - i >= 0 && value - i <= 1) {
65+
icon.setNativeProps({opacity: value - i});
66+
}
67+
if (i - value >= 0 && i - value <= 1) {
68+
icon.setNativeProps({opacity: i - value});
69+
}
70+
});
71+
},
72+
73+
render() {
74+
return (
75+
<View style={styles.tabs}>
76+
{this.props.tabs.map((tab, i) => this.renderTabOption(tab, i))}
77+
</View>
78+
);
79+
},
80+
});
81+
82+
module.exports = FacebookTabBar;

0 commit comments

Comments
 (0)