* 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
129 lines
3.9 KiB
JavaScript
129 lines
3.9 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 {
|
|
View,
|
|
Text,
|
|
TextInput
|
|
} from 'react-native';
|
|
|
|
import FormattedText from 'app/components/formatted_text';
|
|
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
|
|
|
export default class AccountSettingsItem extends PureComponent {
|
|
static propTypes = {
|
|
disabled: PropTypes.bool,
|
|
field: PropTypes.string.isRequired,
|
|
format: PropTypes.shape({
|
|
id: PropTypes.string.isRequired,
|
|
defaultMessage: PropTypes.string.isRequired
|
|
}),
|
|
helpText: PropTypes.string,
|
|
optional: PropTypes.bool,
|
|
theme: PropTypes.object.isRequired,
|
|
updateValue: PropTypes.func.isRequired,
|
|
value: PropTypes.string.isRequired
|
|
};
|
|
|
|
static defaultProps = {
|
|
optional: false,
|
|
disabled: false
|
|
};
|
|
|
|
onChangeText = (value) => {
|
|
const {field, updateValue} = this.props;
|
|
updateValue({[field]: value});
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
theme,
|
|
format,
|
|
helpText,
|
|
optional,
|
|
disabled,
|
|
value
|
|
} = this.props;
|
|
const style = getStyleSheet(theme);
|
|
|
|
return (
|
|
<View>
|
|
<View style={style.titleContainer15}>
|
|
<FormattedText
|
|
style={style.title}
|
|
id={format.id}
|
|
defaultMessage={format.defaultMessage}
|
|
/>
|
|
{optional && (
|
|
<FormattedText
|
|
style={style.optional}
|
|
id='channel_modal.optional'
|
|
defaultMessage='(optional)'
|
|
/>
|
|
)}
|
|
</View>
|
|
<View style={style.inputContainer}>
|
|
<TextInput
|
|
ref={this.channelNameRef}
|
|
value={value}
|
|
onChangeText={this.onChangeText}
|
|
style={[style.input, disabled ? style.disabled : null]}
|
|
autoCapitalize='none'
|
|
autoCorrect={false}
|
|
editable={!disabled}
|
|
underlineColorAndroid='transparent'
|
|
disableFullscreenUI={true}
|
|
/>
|
|
{disabled &&
|
|
<Text style={style.helpText}>
|
|
{helpText}
|
|
</Text>
|
|
}
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
|
|
return {
|
|
inputContainer: {
|
|
borderTopWidth: 1,
|
|
borderBottomWidth: 1,
|
|
borderTopColor: changeOpacity(theme.centerChannelColor, 0.1),
|
|
borderBottomColor: changeOpacity(theme.centerChannelColor, 0.1),
|
|
backgroundColor: theme.centerChannelBg
|
|
},
|
|
input: {
|
|
color: theme.centerChannelColor,
|
|
fontSize: 14,
|
|
height: 40,
|
|
paddingHorizontal: 15
|
|
},
|
|
disabled: {
|
|
backgroundColor: changeOpacity(theme.centerChannelColor, 0.1)
|
|
},
|
|
title: {
|
|
fontSize: 14,
|
|
color: theme.centerChannelColor,
|
|
marginLeft: 15
|
|
},
|
|
titleContainer15: {
|
|
flexDirection: 'row',
|
|
marginTop: 15
|
|
},
|
|
optional: {
|
|
color: changeOpacity(theme.centerChannelColor, 0.5),
|
|
fontSize: 14,
|
|
marginLeft: 5
|
|
},
|
|
helpText: {
|
|
fontSize: 12,
|
|
color: changeOpacity(theme.centerChannelColor, 0.5),
|
|
marginHorizontal: 15,
|
|
marginVertical: 10
|
|
}
|
|
};
|
|
});
|