-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GantMan/custom_drawer
add custom container and logout
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react' | ||
import { StyleSheet, Text, View, Image } from 'react-native' | ||
import { NavigationActions } from 'react-navigation' | ||
|
||
export default class DrawerContainer extends React.Component { | ||
|
||
logout = () => { | ||
// This will reset back to loginStack | ||
// https://github.com/react-community/react-navigation/issues/1127 | ||
const actionToDispatch = NavigationActions.reset({ | ||
index: 0, | ||
key: null, // black magic | ||
actions: [NavigationActions.navigate({ routeName: 'loginStack' })] | ||
}) | ||
this.props.navigation.dispatch(actionToDispatch) | ||
} | ||
|
||
render() { | ||
const { navigation } = this.props | ||
return ( | ||
<View style={styles.container}> | ||
<Text | ||
onPress={() => navigation.navigate('screen1')} | ||
style={styles.uglyDrawerItem}> | ||
Screen 1 | ||
</Text> | ||
<Text | ||
onPress={() => navigation.navigate('screen2')} | ||
style={styles.uglyDrawerItem}> | ||
Screen 2 | ||
</Text> | ||
<Text | ||
onPress={() => navigation.navigate('screen3')} | ||
style={styles.uglyDrawerItem}> | ||
Screen 3 | ||
</Text> | ||
<Text | ||
onPress={this.logout} | ||
style={styles.uglyDrawerItem}> | ||
Log Out | ||
</Text> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#ccc', | ||
paddingTop: 40, | ||
paddingHorizontal: 20 | ||
}, | ||
uglyDrawerItem: { | ||
fontSize: 20, | ||
color: 'blue', | ||
padding: 15, | ||
margin: 5, | ||
borderRadius: 10, | ||
borderColor: 'blue', | ||
borderWidth: 1, | ||
textAlign: 'center', | ||
backgroundColor: 'white', | ||
overflow: 'hidden' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters