mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-27 03:14:56 +03:00
Fixed header and side menu no auth error
This commit is contained in:
parent
a8febe5ec8
commit
973ed4b0f8
@ -31,6 +31,26 @@ class HeaderView extends Component {
|
||||
|
||||
// Component Functions
|
||||
|
||||
_getNameOfUser = () => {
|
||||
const { currentAccount } = this.props;
|
||||
if (Object.keys(currentAccount).length === 0) return currentAccount.name;
|
||||
if (Object.keys(currentAccount.about).length === 0) return currentAccount.name;
|
||||
if (Object.keys(currentAccount.about.profile).length !== 0) {
|
||||
return currentAccount.about.profile.name;
|
||||
}
|
||||
return currentAccount.name;
|
||||
};
|
||||
|
||||
_getUserAvatar = () => {
|
||||
const { currentAccount } = this.props;
|
||||
if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about.profile).length !== 0) {
|
||||
return { uri: currentAccount.about.profile.profile_image };
|
||||
}
|
||||
return DEFAULT_IMAGE;
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
handleOpenDrawer,
|
||||
@ -38,10 +58,7 @@ class HeaderView extends Component {
|
||||
hideStatusBar,
|
||||
isReverse,
|
||||
currentAccount,
|
||||
isLoggedIn,
|
||||
} = this.props;
|
||||
const avatar = currentAccount && currentAccount.about && currentAccount.about.profile.profile_image;
|
||||
const name = currentAccount && currentAccount.about && currentAccount.about.profile.name;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.container, isReverse && styles.containerReverse]}>
|
||||
@ -56,12 +73,16 @@ class HeaderView extends Component {
|
||||
isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault,
|
||||
]}
|
||||
>
|
||||
<FastImage style={styles.avatar} source={{ uri: avatar }} defaultSource={DEFAULT_IMAGE} />
|
||||
<FastImage
|
||||
style={styles.avatar}
|
||||
source={this._getUserAvatar()}
|
||||
defaultSource={DEFAULT_IMAGE}
|
||||
/>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
{currentAccount && currentAccount.name ? (
|
||||
<View style={styles.titleWrapper}>
|
||||
{ name && <Text style={styles.title}>{name}</Text> }
|
||||
<Text style={styles.title}>{this._getNameOfUser()}</Text>
|
||||
<Text style={styles.subTitle}>
|
||||
@
|
||||
{currentAccount.name}
|
||||
|
@ -40,6 +40,9 @@ class SideMenuView extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Component Functions
|
||||
|
||||
_handleOnPressAddAccountIcon = () => {
|
||||
const { isAddAccountIconActive } = this.state;
|
||||
const { isLoggedIn, accounts } = this.props;
|
||||
@ -53,15 +56,31 @@ class SideMenuView extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
// Component Functions
|
||||
_getNameOfUser = () => {
|
||||
const { currentAccount } = this.props;
|
||||
if (Object.keys(currentAccount).length === 0) return currentAccount.name;
|
||||
if (Object.keys(currentAccount.about).length === 0) return currentAccount.name;
|
||||
if (Object.keys(currentAccount.about.profile).length !== 0) {
|
||||
return currentAccount.about.profile.name;
|
||||
}
|
||||
return currentAccount.name;
|
||||
};
|
||||
|
||||
_getUserAvatar = () => {
|
||||
const { currentAccount } = this.props;
|
||||
if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about.profile).length !== 0) {
|
||||
return { uri: currentAccount.about.profile.profile_image };
|
||||
}
|
||||
return DEFAULT_IMAGE;
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
navigateToRoute, currentAccount, isLoggedIn, switchAccount,
|
||||
} = this.props;
|
||||
const { menuItems, isAddAccountIconActive } = this.state;
|
||||
const avatar = currentAccount && currentAccount.about && currentAccount.about.profile.profile_image;
|
||||
const name = currentAccount && currentAccount.about && currentAccount.about.profile.name;
|
||||
|
||||
return (
|
||||
<Container style={styles.container}>
|
||||
@ -73,9 +92,9 @@ class SideMenuView extends Component {
|
||||
>
|
||||
{isLoggedIn && (
|
||||
<View style={styles.headerContentView}>
|
||||
<Thumbnail style={styles.userAvatar} source={{ uri: avatar }} />
|
||||
<Thumbnail style={styles.userAvatar} source={this._getUserAvatar()} />
|
||||
<View style={styles.userInfoView}>
|
||||
<Text style={styles.username}>{name}</Text>
|
||||
<Text style={styles.username}>{this._getNameOfUser()}</Text>
|
||||
<Text style={styles.usernick}>{`@${currentAccount.name}`}</Text>
|
||||
</View>
|
||||
<View style={styles.addAccountIconView}>
|
||||
|
Loading…
Reference in New Issue
Block a user