2018-06-05 01:17:02 +00:00
|
|
|
import React from 'react';
|
2018-06-13 01:33:00 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2018-10-23 21:39:48 +00:00
|
|
|
View, ScrollView, Keyboard, Dimensions
|
2018-09-25 19:28:42 +00:00
|
|
|
} from 'react-native';
|
2018-06-13 01:33:00 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Dialog from 'react-native-dialog';
|
|
|
|
import SHA256 from 'js-sha256';
|
|
|
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
2018-07-17 19:10:27 +00:00
|
|
|
import ImagePicker from 'react-native-image-crop-picker';
|
2018-06-13 01:33:00 +00:00
|
|
|
import RNPickerSelect from 'react-native-picker-select';
|
2018-10-23 21:39:48 +00:00
|
|
|
import { Navigation } from 'react-native-navigation';
|
|
|
|
import SafeAreaView from 'react-native-safe-area-view';
|
2018-06-05 01:17:02 +00:00
|
|
|
|
|
|
|
import LoggedView from '../View';
|
2018-06-13 01:33:00 +00:00
|
|
|
import KeyboardView from '../../presentation/KeyboardView';
|
|
|
|
import sharedStyles from '../Styles';
|
|
|
|
import styles from './styles';
|
|
|
|
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
|
|
|
import { showErrorAlert, showToast } from '../../utils/info';
|
|
|
|
import RocketChat from '../../lib/rocketchat';
|
|
|
|
import RCTextInput from '../../containers/TextInput';
|
|
|
|
import Loading from '../../containers/Loading';
|
|
|
|
import log from '../../utils/log';
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import Button from '../../containers/Button';
|
|
|
|
import Avatar from '../../containers/Avatar';
|
|
|
|
import Touch from '../../utils/touch';
|
2018-10-23 21:39:48 +00:00
|
|
|
import Drawer from '../../Drawer';
|
2018-11-14 21:42:03 +00:00
|
|
|
import { DEFAULT_HEADER } from '../../constants/headerOptions';
|
2018-06-05 01:17:02 +00:00
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
@connect(state => ({
|
2018-07-10 13:40:32 +00:00
|
|
|
user: {
|
|
|
|
name: state.login.user && state.login.user.name,
|
|
|
|
username: state.login.user && state.login.user.username,
|
|
|
|
customFields: state.login.user && state.login.user.customFields,
|
|
|
|
emails: state.login.user && state.login.user.emails
|
|
|
|
},
|
2018-09-11 16:32:52 +00:00
|
|
|
Accounts_CustomFields: state.settings.Accounts_CustomFields,
|
|
|
|
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
|
2018-06-13 01:33:00 +00:00
|
|
|
}))
|
2018-07-10 13:40:32 +00:00
|
|
|
/** @extends React.Component */
|
2018-06-05 01:17:02 +00:00
|
|
|
export default class ProfileView extends LoggedView {
|
2018-10-23 21:39:48 +00:00
|
|
|
static options() {
|
|
|
|
return {
|
2018-11-14 21:42:03 +00:00
|
|
|
...DEFAULT_HEADER,
|
2018-10-23 21:39:48 +00:00
|
|
|
topBar: {
|
2018-11-14 21:42:03 +00:00
|
|
|
...DEFAULT_HEADER.topBar,
|
2018-10-23 21:39:48 +00:00
|
|
|
leftButtons: [{
|
|
|
|
id: 'settings',
|
|
|
|
icon: { uri: 'settings', scale: Dimensions.get('window').scale },
|
|
|
|
testID: 'rooms-list-view-sidebar'
|
|
|
|
}],
|
|
|
|
title: {
|
2018-11-14 21:42:03 +00:00
|
|
|
...DEFAULT_HEADER.topBar.title,
|
2018-10-23 21:39:48 +00:00
|
|
|
text: I18n.t('Profile')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sideMenu: {
|
|
|
|
left: {
|
|
|
|
enabled: true
|
2018-10-29 13:54:23 +00:00
|
|
|
},
|
|
|
|
right: {
|
|
|
|
enabled: true
|
2018-10-23 21:39:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
static propTypes = {
|
2018-09-11 16:32:52 +00:00
|
|
|
baseUrl: PropTypes.string,
|
2018-10-23 21:39:48 +00:00
|
|
|
componentId: PropTypes.string,
|
2018-06-13 01:33:00 +00:00
|
|
|
user: PropTypes.object,
|
|
|
|
Accounts_CustomFields: PropTypes.string
|
2018-07-10 13:40:32 +00:00
|
|
|
}
|
2018-06-13 01:33:00 +00:00
|
|
|
|
2018-06-05 01:17:02 +00:00
|
|
|
constructor(props) {
|
|
|
|
super('ProfileView', props);
|
2018-06-13 01:33:00 +00:00
|
|
|
this.state = {
|
|
|
|
showPasswordAlert: false,
|
|
|
|
saving: false,
|
|
|
|
name: null,
|
|
|
|
username: null,
|
|
|
|
email: null,
|
|
|
|
newPassword: null,
|
|
|
|
typedPassword: null,
|
|
|
|
avatarUrl: null,
|
|
|
|
avatar: {},
|
|
|
|
avatarSuggestions: {},
|
|
|
|
customFields: {}
|
|
|
|
};
|
2018-10-23 21:39:48 +00:00
|
|
|
Navigation.events().bindComponent(this);
|
2018-06-13 01:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
|
|
|
this.init();
|
|
|
|
|
|
|
|
try {
|
|
|
|
const result = await RocketChat.getAvatarSuggestion();
|
|
|
|
this.setState({ avatarSuggestions: result });
|
|
|
|
} catch (e) {
|
|
|
|
log('getAvatarSuggestion', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { user } = this.props;
|
|
|
|
if (user !== nextProps.user) {
|
2018-06-13 01:33:00 +00:00
|
|
|
this.init(nextProps.user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 21:39:48 +00:00
|
|
|
navigationButtonPressed = ({ buttonId }) => {
|
|
|
|
if (buttonId === 'settings') {
|
|
|
|
Drawer.toggle();
|
2018-07-10 13:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setAvatar = (avatar) => {
|
|
|
|
this.setState({ avatar });
|
|
|
|
}
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
init = (user) => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { user: userProps } = this.props;
|
2018-06-13 01:33:00 +00:00
|
|
|
const {
|
|
|
|
name, username, emails, customFields
|
2018-09-25 19:28:42 +00:00
|
|
|
} = user || userProps;
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
this.setState({
|
|
|
|
name,
|
|
|
|
username,
|
|
|
|
email: emails ? emails[0].address : null,
|
|
|
|
newPassword: null,
|
|
|
|
typedPassword: null,
|
|
|
|
avatarUrl: null,
|
|
|
|
avatar: {},
|
|
|
|
customFields: customFields || {}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
formIsChanged = () => {
|
|
|
|
const {
|
|
|
|
name, username, email, newPassword, avatar, customFields
|
|
|
|
} = this.state;
|
|
|
|
const { user } = this.props;
|
|
|
|
let customFieldsChanged = false;
|
|
|
|
|
|
|
|
const customFieldsKeys = Object.keys(customFields);
|
|
|
|
if (customFieldsKeys.length) {
|
|
|
|
customFieldsKeys.forEach((key) => {
|
|
|
|
if (user.customFields[key] !== customFields[key]) {
|
|
|
|
customFieldsChanged = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
return !(user.name === name
|
|
|
|
&& user.username === username
|
|
|
|
&& !newPassword
|
|
|
|
&& (user.emails && user.emails[0].address === email)
|
|
|
|
&& !avatar.data
|
|
|
|
&& !customFieldsChanged
|
2018-06-13 01:33:00 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
closePasswordAlert = () => {
|
|
|
|
this.setState({ showPasswordAlert: false });
|
|
|
|
}
|
|
|
|
|
|
|
|
handleError = (e, func, action) => {
|
|
|
|
if (e && e.error && e.error !== 500) {
|
|
|
|
if (e.details && e.details.timeToReset) {
|
|
|
|
return showErrorAlert(I18n.t('error-too-many-requests', {
|
|
|
|
seconds: parseInt(e.details.timeToReset / 1000, 10)
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return showErrorAlert(I18n.t(e.error, e.details));
|
|
|
|
}
|
|
|
|
showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t(action) }));
|
|
|
|
log(func, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
submit = async() => {
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
|
|
|
if (!this.formIsChanged()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({ saving: true, showPasswordAlert: false });
|
|
|
|
|
|
|
|
const {
|
|
|
|
name, username, email, newPassword, typedPassword, avatar, customFields
|
|
|
|
} = this.state;
|
|
|
|
const { user } = this.props;
|
|
|
|
const params = {};
|
|
|
|
|
|
|
|
// Name
|
|
|
|
if (user.name !== name) {
|
|
|
|
params.realname = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Username
|
|
|
|
if (user.username !== username) {
|
|
|
|
params.username = username;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Email
|
|
|
|
if (user.emails && user.emails[0].address !== email) {
|
|
|
|
params.email = email;
|
|
|
|
}
|
|
|
|
|
|
|
|
// newPassword
|
|
|
|
if (newPassword) {
|
|
|
|
params.newPassword = newPassword;
|
|
|
|
}
|
|
|
|
|
|
|
|
// typedPassword
|
|
|
|
if (typedPassword) {
|
|
|
|
params.typedPassword = SHA256(typedPassword);
|
|
|
|
}
|
|
|
|
|
|
|
|
const requirePassword = !!params.email || newPassword;
|
|
|
|
if (requirePassword && !params.typedPassword) {
|
|
|
|
return this.setState({ showPasswordAlert: true, saving: false });
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (avatar.url) {
|
|
|
|
try {
|
|
|
|
await RocketChat.setAvatarFromService(avatar);
|
|
|
|
} catch (e) {
|
|
|
|
this.setState({ saving: false, typedPassword: null });
|
|
|
|
return setTimeout(() => this.handleError(e, 'setAvatarFromService', 'changing_avatar'), 300);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await RocketChat.saveUserProfile(params, customFields);
|
|
|
|
this.setState({ saving: false });
|
|
|
|
setTimeout(() => {
|
|
|
|
showToast(I18n.t('Profile_saved_successfully'));
|
|
|
|
this.init();
|
|
|
|
}, 300);
|
|
|
|
} catch (e) {
|
|
|
|
this.setState({ saving: false, typedPassword: null });
|
|
|
|
setTimeout(() => {
|
|
|
|
this.handleError(e, 'saveUserProfile', 'saving_profile');
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resetAvatar = async() => {
|
|
|
|
try {
|
|
|
|
await RocketChat.resetAvatar();
|
|
|
|
showToast(I18n.t('Avatar_changed_successfully'));
|
|
|
|
this.init();
|
|
|
|
} catch (e) {
|
|
|
|
this.handleError(e, 'resetAvatar', 'changing_avatar');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 19:10:27 +00:00
|
|
|
pickImage = async() => {
|
2018-06-13 01:33:00 +00:00
|
|
|
const options = {
|
2018-07-17 19:10:27 +00:00
|
|
|
cropping: true,
|
|
|
|
compressImageQuality: 0.8,
|
|
|
|
cropperAvoidEmptySpaceAroundImage: false,
|
|
|
|
cropperChooseText: I18n.t('Choose'),
|
|
|
|
cropperCancelText: I18n.t('Cancel'),
|
|
|
|
includeBase64: true
|
2018-06-13 01:33:00 +00:00
|
|
|
};
|
2018-07-17 19:10:27 +00:00
|
|
|
try {
|
|
|
|
const response = await ImagePicker.openPicker(options);
|
|
|
|
this.setAvatar({ url: response.path, data: `data:image/jpeg;base64,${ response.data }`, service: 'upload' });
|
|
|
|
} catch (error) {
|
|
|
|
console.warn(error);
|
|
|
|
}
|
2018-06-13 01:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderAvatarButton = ({
|
|
|
|
key, child, onPress, disabled = false
|
|
|
|
}) => (
|
|
|
|
<Touch
|
|
|
|
key={key}
|
|
|
|
testID={key}
|
|
|
|
onPress={onPress}
|
|
|
|
underlayColor='rgba(255, 255, 255, 0.5)'
|
|
|
|
activeOpacity={0.3}
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
|
|
|
<View
|
|
|
|
style={[styles.avatarButton, { opacity: disabled ? 0.5 : 1 }]}
|
|
|
|
>
|
|
|
|
{child}
|
|
|
|
</View>
|
|
|
|
</Touch>
|
|
|
|
)
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
renderAvatarButtons = () => {
|
|
|
|
const { avatarUrl, avatarSuggestions } = this.state;
|
|
|
|
const { user, baseUrl } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.avatarButtons}>
|
|
|
|
{this.renderAvatarButton({
|
2018-10-29 13:53:32 +00:00
|
|
|
child: <Avatar text={`@${ user.username }`} size={50} baseUrl={baseUrl} />,
|
2018-09-25 19:28:42 +00:00
|
|
|
onPress: () => this.resetAvatar(),
|
|
|
|
key: 'profile-view-reset-avatar'
|
|
|
|
})}
|
|
|
|
{this.renderAvatarButton({
|
|
|
|
child: <Icon name='file-upload' size={30} />,
|
|
|
|
onPress: () => this.pickImage(),
|
|
|
|
key: 'profile-view-upload-avatar'
|
|
|
|
})}
|
|
|
|
{this.renderAvatarButton({
|
|
|
|
child: <Icon name='link' size={30} />,
|
|
|
|
onPress: () => this.setAvatar({ url: avatarUrl, data: avatarUrl, service: 'url' }),
|
|
|
|
disabled: !avatarUrl,
|
|
|
|
key: 'profile-view-avatar-url-button'
|
|
|
|
})}
|
|
|
|
{Object.keys(avatarSuggestions).map((service) => {
|
|
|
|
const { url, blob, contentType } = avatarSuggestions[service];
|
|
|
|
return this.renderAvatarButton({
|
|
|
|
key: `profile-view-avatar-${ service }`,
|
|
|
|
child: <Avatar avatar={url} size={50} baseUrl={baseUrl} />,
|
|
|
|
onPress: () => this.setAvatar({
|
|
|
|
url, data: blob, service, contentType
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-06-13 01:33:00 +00:00
|
|
|
|
|
|
|
renderCustomFields = () => {
|
|
|
|
const { customFields } = this.state;
|
2018-09-25 19:28:42 +00:00
|
|
|
const { Accounts_CustomFields } = this.props;
|
|
|
|
|
|
|
|
if (!Accounts_CustomFields) {
|
2018-06-13 01:33:00 +00:00
|
|
|
return null;
|
|
|
|
}
|
2018-09-25 19:28:42 +00:00
|
|
|
const parsedCustomFields = JSON.parse(Accounts_CustomFields);
|
2018-06-13 01:33:00 +00:00
|
|
|
return Object.keys(parsedCustomFields).map((key, index, array) => {
|
|
|
|
if (parsedCustomFields[key].type === 'select') {
|
|
|
|
const options = parsedCustomFields[key].options.map(option => ({ label: option, value: option }));
|
|
|
|
return (
|
|
|
|
<RNPickerSelect
|
|
|
|
key={key}
|
|
|
|
items={options}
|
|
|
|
onValueChange={(value) => {
|
|
|
|
const newValue = {};
|
|
|
|
newValue[key] = value;
|
2018-09-25 19:28:42 +00:00
|
|
|
this.setState({ customFields: { ...customFields, ...newValue } });
|
2018-06-13 01:33:00 +00:00
|
|
|
}}
|
|
|
|
value={customFields[key]}
|
|
|
|
>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this[key] = e; }}
|
|
|
|
label={key}
|
|
|
|
placeholder={key}
|
|
|
|
value={customFields[key]}
|
|
|
|
testID='settings-view-language'
|
|
|
|
/>
|
|
|
|
</RNPickerSelect>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this[key] = e; }}
|
|
|
|
key={key}
|
|
|
|
label={key}
|
|
|
|
placeholder={key}
|
|
|
|
value={customFields[key]}
|
|
|
|
onChangeText={(value) => {
|
|
|
|
const newValue = {};
|
|
|
|
newValue[key] = value;
|
2018-09-25 19:28:42 +00:00
|
|
|
this.setState({ customFields: { ...customFields, ...newValue } });
|
2018-06-13 01:33:00 +00:00
|
|
|
}}
|
|
|
|
onSubmitEditing={() => {
|
|
|
|
if (array.length - 1 > index) {
|
|
|
|
return this[array[index + 1]].focus();
|
|
|
|
}
|
|
|
|
this.avatarUrl.focus();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
2018-06-05 01:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-06-13 01:33:00 +00:00
|
|
|
const {
|
2018-09-25 19:28:42 +00:00
|
|
|
name, username, email, newPassword, avatarUrl, customFields, avatar, saving, showPasswordAlert
|
2018-06-13 01:33:00 +00:00
|
|
|
} = this.state;
|
2018-09-25 19:28:42 +00:00
|
|
|
const { baseUrl } = this.props;
|
|
|
|
|
2018-06-05 01:17:02 +00:00
|
|
|
return (
|
2018-06-13 01:33:00 +00:00
|
|
|
<KeyboardView
|
|
|
|
contentContainerStyle={sharedStyles.container}
|
|
|
|
keyboardVerticalOffset={128}
|
|
|
|
>
|
|
|
|
<ScrollView
|
|
|
|
contentContainerStyle={sharedStyles.containerScrollView}
|
|
|
|
testID='profile-view-list'
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
>
|
2018-10-23 21:39:48 +00:00
|
|
|
<SafeAreaView style={sharedStyles.container} testID='profile-view' forceInset={{ bottom: 'never' }}>
|
2018-06-13 01:33:00 +00:00
|
|
|
<View style={styles.avatarContainer} testID='profile-view-avatar'>
|
|
|
|
<Avatar
|
|
|
|
text={username}
|
2018-09-25 19:28:42 +00:00
|
|
|
avatar={avatar && avatar.url}
|
2018-06-13 01:33:00 +00:00
|
|
|
size={100}
|
2018-09-25 19:28:42 +00:00
|
|
|
baseUrl={baseUrl}
|
2018-06-13 01:33:00 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.name = e; }}
|
|
|
|
label={I18n.t('Name')}
|
|
|
|
placeholder={I18n.t('Name')}
|
|
|
|
value={name}
|
|
|
|
onChangeText={value => this.setState({ name: value })}
|
|
|
|
onSubmitEditing={() => { this.username.focus(); }}
|
|
|
|
testID='profile-view-name'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.username = e; }}
|
|
|
|
label={I18n.t('Username')}
|
|
|
|
placeholder={I18n.t('Username')}
|
|
|
|
value={username}
|
|
|
|
onChangeText={value => this.setState({ username: value })}
|
|
|
|
onSubmitEditing={() => { this.email.focus(); }}
|
|
|
|
testID='profile-view-username'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.email = e; }}
|
|
|
|
label={I18n.t('Email')}
|
|
|
|
placeholder={I18n.t('Email')}
|
|
|
|
value={email}
|
|
|
|
onChangeText={value => this.setState({ email: value })}
|
|
|
|
onSubmitEditing={() => { this.newPassword.focus(); }}
|
|
|
|
testID='profile-view-email'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.newPassword = e; }}
|
|
|
|
label={I18n.t('New_Password')}
|
|
|
|
placeholder={I18n.t('New_Password')}
|
|
|
|
value={newPassword}
|
|
|
|
onChangeText={value => this.setState({ newPassword: value })}
|
|
|
|
onSubmitEditing={() => {
|
|
|
|
if (Object.keys(customFields).length) {
|
|
|
|
return this[Object.keys(customFields)[0]].focus();
|
|
|
|
}
|
|
|
|
this.avatarUrl.focus();
|
|
|
|
}}
|
|
|
|
secureTextEntry
|
|
|
|
testID='profile-view-new-password'
|
|
|
|
/>
|
|
|
|
{this.renderCustomFields()}
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.avatarUrl = e; }}
|
|
|
|
label={I18n.t('Avatar_Url')}
|
|
|
|
placeholder={I18n.t('Avatar_Url')}
|
|
|
|
value={avatarUrl}
|
|
|
|
onChangeText={value => this.setState({ avatarUrl: value })}
|
|
|
|
onSubmitEditing={this.submit}
|
|
|
|
testID='profile-view-avatar-url'
|
|
|
|
/>
|
|
|
|
{this.renderAvatarButtons()}
|
|
|
|
<View style={sharedStyles.alignItemsFlexStart}>
|
|
|
|
<Button
|
|
|
|
title={I18n.t('Save_Changes')}
|
|
|
|
type='primary'
|
|
|
|
onPress={this.submit}
|
|
|
|
disabled={!this.formIsChanged()}
|
|
|
|
testID='profile-view-submit'
|
|
|
|
/>
|
|
|
|
</View>
|
2018-09-25 19:28:42 +00:00
|
|
|
<Loading visible={saving} />
|
|
|
|
<Dialog.Container visible={showPasswordAlert}>
|
2018-06-13 01:33:00 +00:00
|
|
|
<Dialog.Title>
|
|
|
|
{I18n.t('Please_enter_your_password')}
|
|
|
|
</Dialog.Title>
|
|
|
|
<Dialog.Description>
|
|
|
|
{I18n.t('For_your_security_you_must_enter_your_current_password_to_continue')}
|
|
|
|
</Dialog.Description>
|
|
|
|
<Dialog.Input
|
|
|
|
onChangeText={value => this.setState({ typedPassword: value })}
|
|
|
|
secureTextEntry
|
|
|
|
testID='profile-view-typed-password'
|
2018-06-20 13:40:33 +00:00
|
|
|
style={styles.dialogInput}
|
2018-06-13 01:33:00 +00:00
|
|
|
/>
|
|
|
|
<Dialog.Button label={I18n.t('Cancel')} onPress={this.closePasswordAlert} />
|
|
|
|
<Dialog.Button label={I18n.t('Save')} onPress={this.submit} />
|
|
|
|
</Dialog.Container>
|
|
|
|
</SafeAreaView>
|
|
|
|
</ScrollView>
|
|
|
|
</KeyboardView>
|
2018-06-05 01:17:02 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|