Skip to content

Commit 10f1b6b

Browse files
committed
dynamic example
1 parent a3d17ee commit 10f1b6b

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import {
3+
Text,
4+
} from 'react-native';
5+
import TimerMixin from 'react-timer-mixin';
6+
7+
import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view';
8+
9+
export default React.createClass({
10+
mixins: [TimerMixin],
11+
12+
getInitialState() {
13+
return {
14+
tabs: [],
15+
};
16+
},
17+
18+
componentDidMount() {
19+
this.setTimeout(
20+
() => { this.setState({ tabs: [1, 2, 3, ], }); },
21+
100
22+
);
23+
},
24+
25+
render() {
26+
return <ScrollableTabView
27+
style={{marginTop: 20, }}
28+
renderTabBar={() => <DefaultTabBar />}
29+
>
30+
{this.state.tabs.map((tab, i) => {
31+
return <Text tabLabel={`tab${i}`} key={i}>{`tab${i}`}</Text>
32+
})}
33+
</ScrollableTabView>;
34+
},
35+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { AppRegistry, } from 'react-native';
2-
import FacebookTabsExample from './FacebookTabsExample';
2+
import FacebookTabsExample from './index.js';
33

44
AppRegistry.registerComponent('FacebookTabsExample', () => FacebookTabsExample);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { AppRegistry, } from 'react-native';
2-
import FacebookTabsExample from './FacebookTabsExample';
2+
import FacebookTabsExample from './index.js';
33

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

examples/FacebookTabsExample/FacebookTabsExample.js renamed to examples/FacebookTabsExample/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SimpleExample from './SimpleExample';
1111
import ScrollableTabsExample from './ScrollableTabsExample';
1212
import OverlayExample from './OverlayExample';
1313
import FacebookExample from './FacebookExample';
14+
import DynamicExample from './DynamicExample';
1415

1516
export default React.createClass({
1617
render() {
@@ -31,6 +32,8 @@ export default React.createClass({
3132
return <OverlayExample />;
3233
case 'facebook':
3334
return <FacebookExample />;
35+
case 'dynamic':
36+
return <DynamicExample />;
3437
default:
3538
return <View style={styles.container}>
3639
<TouchableOpacity
@@ -60,6 +63,13 @@ export default React.createClass({
6063
>
6164
<Text>Facebook tabs example</Text>
6265
</TouchableOpacity>
66+
67+
<TouchableOpacity
68+
style={styles.button}
69+
onPress={() => nav.push({id: 'dynamic', })}
70+
>
71+
<Text>Dynamic tabs example</Text>
72+
</TouchableOpacity>
6373
</View>;
6474
}
6575
},

examples/FacebookTabsExample/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"react": "^15.1.0",
1010
"react-native": "^0.28.0",
1111
"react-native-scrollable-tab-view": "../..",
12-
"react-native-vector-icons": "^2.0.3"
12+
"react-native-vector-icons": "^2.0.3",
13+
"react-timer-mixin": "^0.13.3"
1314
}
1415
}

0 commit comments

Comments
 (0)