Skip to content

Instantly share code, notes, and snippets.

@ugened47
Created June 28, 2017 09:27
Show Gist options
  • Save ugened47/bfbcf4e16c47d4bf87e1f9f5d1c12a20 to your computer and use it in GitHub Desktop.
Save ugened47/bfbcf4e16c47d4bf87e1f9f5d1c12a20 to your computer and use it in GitHub Desktop.
React Navigation Custom Drawer Example
/* eslint-disable camelcase */
import React, { Component } from 'react'
import { Image, TouchableOpacity, Text, View } from 'react-native'
import AuthActions from '../Redux/AuthRedux'
import { connect } from 'react-redux'
import FBSDK from 'react-native-fbsdk'
import Styles from './Styles/DrawerContentStyles'
import { DrawerItems } from 'react-navigation'
const { LoginManager } = FBSDK
class DrawerContent extends Component {
onSignOut = () => {
this.props.logOut()
LoginManager.logOut()
}
render () {
const { profile } = this.props.profile
const { first_name, last_name, avatar } = profile
const profileImage = avatar ? { uri: avatar.medium.url } : null
return (
<View style={Styles.container}>
<View style={Styles.profile}>
<TouchableOpacity
onPress={() => {
this.props.navigation.navigate('EditProfile')
}}
>
<Image source={profileImage} style={Styles.avatar} />
</TouchableOpacity>
<Text style={Styles.name}>{`${first_name} ${last_name}` || ''}</Text>
</View>
<DrawerItems {...this.props} />
<TouchableOpacity
style={Styles.item}
onPress={() => this.onSignOut()}
>
<Text style={Styles.label}>Sign Out</Text>
</TouchableOpacity>
</View>
)
}
}
const mapDispatchToProps = (dispatch) => {
return {
logOut: () => dispatch(AuthActions.logOutUserRequest())
}
}
const mapStateToProps = ({ profile, auth }) => {
return { profile }
}
export default connect(mapStateToProps, mapDispatchToProps)(DrawerContent)
@ramsestom
Copy link

Could you please publish the content of ./Styles/DrawerContentStyles ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment