Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add example where the number of tabs changes forcing it back and fort…
…h between needing to scroll and not needing to scroll
  • Loading branch information
ghuh committed Aug 5, 2016
commit a883cb850d025945c2821c888d25fa8f722a8bb6
48 changes: 48 additions & 0 deletions examples/FacebookTabsExample/ChangingScrollableTabsExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import {
Text,
View,
TouchableHighlight,
} from 'react-native';

import ScrollableTabView, { ScrollableTabBar, } from 'react-native-scrollable-tab-view';

export default React.createClass({
getInitialState() {
return {
tabs: [ 'short', 'list' ],
};
},

render() {
return (
<ScrollableTabView
renderTabBar = { () => <ScrollableTabBar /> }
>
{
this.state.tabs.map(
(tab,index) =>
(
<View
tabLabel = { tab }
key = {index}
>
<TouchableHighlight
onPress = { () => this.setState({ tabs: [ 'short', 'list' ]})}
>
<Text> { 'short' } </Text>
</TouchableHighlight>
<TouchableHighlight
onPress = { () => this.setState({ tabs: [ 'long', 'list', 'with', 'very', 'many long tabs forcing', 'it to', 'scroll', 'and even longer' ]})}
>
<Text> { 'long' } </Text>
</TouchableHighlight>

</View>
)
)
}
</ScrollableTabView>
);
},
});
10 changes: 10 additions & 0 deletions examples/FacebookTabsExample/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ScrollableTabsExample from './ScrollableTabsExample';
import OverlayExample from './OverlayExample';
import FacebookExample from './FacebookExample';
import DynamicExample from './DynamicExample';
import ChangingScrollableTabsExample from './ChangingScrollableTabsExample';

export default React.createClass({
render() {
Expand All @@ -34,6 +35,8 @@ export default React.createClass({
return <FacebookExample />;
case 'dynamic':
return <DynamicExample />;
case 'changingScrollable':
return <ChangingScrollableTabsExample />;
default:
return <View style={styles.container}>
<TouchableOpacity
Expand Down Expand Up @@ -70,6 +73,13 @@ export default React.createClass({
>
<Text>Dynamic tabs example</Text>
</TouchableOpacity>

<TouchableOpacity
style={styles.button}
onPress={() => nav.push({id: 'changingScrollable', })}
>
<Text>Changing scrollable tabs example</Text>
</TouchableOpacity>
</View>;
}
},
Expand Down