* Add set status feature Small code refactoring Add Do Not Disturb option * Add Account Settings screen Add username, nicname, and position fields Add email field get deviceHeight from redux Clean up onPress handler in Settings Refactor each account settings item to it's own component Clean up email field and updateUser action method Use mobile localization format in en.json Update profile image Clean up ProfilePicture for editing Add loading and error components in AccountSettings Refactor updateRequest state into a function Follow design specs Remove unnecessary this.state.emailUpdated Polish AccountSettings and secondary components Refactor AttachmentButton into it's own componentg Add Account Settings icon in General Settings Add TODO comments * Update user status * Edit Profile screen refactored * Fix edit profile item text color
122 lines
3.6 KiB
JavaScript
122 lines
3.6 KiB
JavaScript
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import React, {PureComponent} from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {Image, Platform, View} from 'react-native';
|
|
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
|
|
|
import UserStatus from 'app/components/user_status';
|
|
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
|
|
|
import placeholder from 'assets/images/profile.jpg';
|
|
|
|
import {Client4} from 'mattermost-redux/client';
|
|
|
|
const STATUS_BUFFER = Platform.select({
|
|
ios: 3,
|
|
android: 2
|
|
});
|
|
|
|
export default class ProfilePicture extends PureComponent {
|
|
static propTypes = {
|
|
size: PropTypes.number,
|
|
statusBorderWidth: PropTypes.number,
|
|
statusSize: PropTypes.number,
|
|
user: PropTypes.object,
|
|
showStatus: PropTypes.bool,
|
|
status: PropTypes.string,
|
|
edit: PropTypes.bool,
|
|
imageUri: PropTypes.string,
|
|
theme: PropTypes.object.isRequired,
|
|
actions: PropTypes.shape({
|
|
getStatusForId: PropTypes.func.isRequired
|
|
})
|
|
};
|
|
|
|
static defaultProps = {
|
|
showStatus: true,
|
|
size: 128,
|
|
statusBorderWidth: 2,
|
|
statusSize: 14,
|
|
edit: false
|
|
};
|
|
|
|
componentDidMount() {
|
|
if (!this.props.status && this.props.user) {
|
|
this.props.actions.getStatusForId(this.props.user.id);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const {edit, imageUri, showStatus, theme} = this.props;
|
|
const style = getStyleSheet(theme);
|
|
|
|
let pictureUrl;
|
|
if (this.props.user) {
|
|
pictureUrl = Client4.getProfilePictureUrl(this.props.user.id, this.props.user.last_picture_update);
|
|
}
|
|
|
|
if (edit && imageUri) {
|
|
pictureUrl = imageUri;
|
|
}
|
|
|
|
let statusIcon;
|
|
let statusStyle;
|
|
if (edit) {
|
|
const iconColor = changeOpacity(theme.centerChannelColor, 0.6);
|
|
statusStyle = {
|
|
width: this.props.statusSize,
|
|
height: this.props.statusSize,
|
|
backgroundColor: 'white'
|
|
};
|
|
statusIcon = (
|
|
<FontAwesomeIcon
|
|
name='camera'
|
|
size={this.props.statusSize / 1.7}
|
|
color={iconColor}
|
|
/>
|
|
);
|
|
} else if (this.props.status && !edit) {
|
|
statusIcon = (
|
|
<UserStatus
|
|
size={this.props.statusSize}
|
|
status={this.props.status}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<View style={{width: this.props.size + STATUS_BUFFER, height: this.props.size + STATUS_BUFFER}}>
|
|
<Image
|
|
key={pictureUrl}
|
|
style={{width: this.props.size, height: this.props.size, borderRadius: this.props.size / 2}}
|
|
source={{uri: pictureUrl}}
|
|
defaultSource={placeholder}
|
|
/>
|
|
{(showStatus || edit) &&
|
|
<View style={[style.statusWrapper, statusStyle, {borderRadius: this.props.statusSize / 2}]}>
|
|
{statusIcon}
|
|
</View>
|
|
}
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
|
|
return {
|
|
statusWrapper: {
|
|
position: 'absolute',
|
|
bottom: 0,
|
|
right: 0,
|
|
overflow: 'hidden',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
backgroundColor: theme.centerChannelBg
|
|
},
|
|
status: {
|
|
color: theme.centerChannelBg
|
|
}
|
|
};
|
|
});
|