Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
feat(real-world): add dynamic tabs example
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoLeBras committed Mar 15, 2018
1 parent 98a07ad commit 8a85c2c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/real-world-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class App extends React.Component<Props> {
)}
/>
<Tab
path="/profile/(likes|bookmarks)"
path="/profile/(likes|bookmarks|settings)"
component={Profile}
onIndexChange={() => history.replace('/profile/likes')}
onReset={() => history.replace('/profile/likes')}
Expand Down
65 changes: 65 additions & 0 deletions examples/real-world-app/src/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ class Profile extends React.Component<Props, State> {
>
<Text style={styles.span}>Go to bookmarks</Text>
</Link>
{tabsLength === 2 && (
<TouchableOpacity
style={styles.link}
onPress={this.handleToggleSettingsTab}
>
<Text style={styles.span}>Add settings tab</Text>
</TouchableOpacity>
)}
{tabsLength === 3 && (
<Link
style={styles.link}
replace
component={TouchableOpacity}
to="/profile/settings"
>
<Text style={styles.span}>Go to settings</Text>
</Link>
)}
</View>
)}
/>
Expand All @@ -128,9 +146,56 @@ class Profile extends React.Component<Props, State> {
>
<Text style={styles.span}>Go to likes</Text>
</Link>
{tabsLength === 2 && (
<TouchableOpacity
style={styles.link}
onPress={this.handleToggleSettingsTab}
>
<Text style={styles.span}>Add settings tab</Text>
</TouchableOpacity>
)}
{tabsLength === 3 && (
<Link
style={styles.link}
replace
component={TouchableOpacity}
to="/profile/settings"
>
<Text style={styles.span}>Go to settings</Text>
</Link>
)}
</View>
)}
/>
{tabsLength === 3 && (
<Tab
path="/profile/settings"
label="Settings"
render={() => (
<View style={styles.scene}>
<Text>
Current: <Text style={styles.strong}>settings</Text>
</Text>
<Link
style={styles.link}
replace
component={TouchableOpacity}
to="/profile/likes"
>
<Text style={styles.span}>Go to likes</Text>
</Link>
<Link
style={styles.link}
replace
component={TouchableOpacity}
to="/profile/bookmarks"
>
<Text style={styles.span}>Go to bookmarks</Text>
</Link>
</View>
)}
/>
)}
</Tabs>
)
}
Expand Down

0 comments on commit 8a85c2c

Please sign in to comment.