Added user avatar to pin code screen

This commit is contained in:
mistikk 2018-11-08 14:00:39 +01:00
parent 486a286108
commit 200da3eedc
3 changed files with 21 additions and 4 deletions

View File

@ -12,6 +12,8 @@ import { default as INITIAL } from '../../../constants/initial';
import { PinCodeScreen } from '..'; import { PinCodeScreen } from '..';
const DEFAULT_IMAGE = require('../../../assets/esteem.png');
class PinCodeContainer extends Component { class PinCodeContainer extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -117,6 +119,16 @@ class PinCodeContainer extends Component {
} }
}); });
_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() { render() {
const { currentAccount } = this.props; const { currentAccount } = this.props;
const { informationText, isExistUser } = this.state; const { informationText, isExistUser } = this.state;
@ -126,6 +138,7 @@ class PinCodeContainer extends Component {
setPinCode={this._setPinCode} setPinCode={this._setPinCode}
showForgotButton={isExistUser} showForgotButton={isExistUser}
username={currentAccount ? currentAccount.name : 'unknow'} username={currentAccount ? currentAccount.name : 'unknow'}
avatar={this._getUserAvatar()}
/> />
); );
} }

View File

@ -1,8 +1,8 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native'; import { Text, TouchableOpacity, View } from 'react-native';
import { Container } from 'native-base'; import { Container, Thumbnail } from 'native-base';
import { Logo, NumericKeyboard, PinAnimatedInput } from '../../../components'; import { NumericKeyboard, PinAnimatedInput } from '../../../components';
import styles from './pinCodeStyles'; import styles from './pinCodeStyles';
@ -46,13 +46,15 @@ class PinCodeScreen extends Component {
}; };
render() { render() {
const { informationText, showForgotButton, username } = this.props; const {
informationText, showForgotButton, username, avatar,
} = this.props;
const { pin } = this.state; const { pin } = this.state;
return ( return (
<Container style={styles.container}> <Container style={styles.container}>
<View style={styles.logoView}> <View style={styles.logoView}>
<Logo style={styles.logo} /> <Thumbnail source={avatar} />
</View> </View>
<View style={styles.titleView}> <View style={styles.titleView}>
<Text style={styles.title}>{`@${username}`}</Text> <Text style={styles.title}>{`@${username}`}</Text>

View File

@ -7,6 +7,8 @@ export default EStyleSheet.create({
}, },
logoView: { logoView: {
flex: 2, flex: 2,
justifyContent: 'center',
alignItems: 'center',
}, },
logo: { logo: {
width: '$deviceWidth / 7', width: '$deviceWidth / 7',