// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React, {PropTypes, PureComponent} from 'react'; import { ScrollView, StyleSheet, Text, View } from 'react-native'; import ProfilePicture from 'app/components/profile_picture'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; import {getFullName} from 'mattermost-redux/utils/user_utils'; import UserProfileRow from './user_profile_row'; export default class UserProfile extends PureComponent { static propTypes = { actions: PropTypes.shape({ handleSendMessage: PropTypes.func.isRequired }).isRequired, config: PropTypes.object.isRequired, currentUserId: PropTypes.string.isRequired, theme: PropTypes.object.isRequired, user: PropTypes.object.isRequired }; state = { isFavorite: false }; getDisplayName = () => { const {theme, user} = this.props; const style = createStyleSheet(theme); const displayName = getFullName(user); if (displayName) { return {displayName}; } return null; }; buildDisplayBlock = (property) => { const {theme, user} = this.props; const style = createStyleSheet(theme); if (user.hasOwnProperty(property) && user[property].length > 0) { return ( {property.toUpperCase()} {user[property]} ); } return null; }; sendMessage = () => { this.props.actions.handleSendMessage(this.props.user.id); }; render() { const {config, currentUserId, theme, user} = this.props; const style = createStyleSheet(theme); return ( {this.getDisplayName()} {`@${user.username}`} {this.buildDisplayBlock('username')} {config.ShowEmailAddress === 'true' && this.buildDisplayBlock('email')} {this.buildDisplayBlock('position')} {currentUserId !== user.id && } ); } } const createStyleSheet = makeStyleSheetFromTheme((theme) => { return StyleSheet.create({ container: { flex: 1 }, content: { marginBottom: 25, marginHorizontal: 15 }, displayName: { marginTop: 15, color: theme.centerChannelColor, fontSize: 17, fontWeight: '600' }, header: { fontSize: 13, fontWeight: '600', color: changeOpacity(theme.centerChannelColor, 0.5), marginTop: 25, marginBottom: 10 }, scrollView: { flex: 1, backgroundColor: theme.centerChannelBg }, scrollViewContent: { flex: 1 }, text: { fontSize: 15, color: theme.centerChannelColor }, top: { padding: 25, alignItems: 'center', justifyContent: 'center' }, username: { marginTop: 15, color: theme.centerChannelColor, fontSize: 15 } }); });