Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] profile edit screen #2857

Merged
merged 11 commits into from
Apr 22, 2024
15 changes: 10 additions & 5 deletions src/components/avatarHeader/avatarHeaderStyles.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import EStyleSheet from 'react-native-extended-stylesheet';

export default EStyleSheet.create({
headerView: {
backgroundColor: '$primaryBackgroundColor',
},
headerContainer: {
flexDirection: 'row',
paddingTop: 8,
paddingBottom: 8,
paddingHorizontal: 24,
paddingBottom: 24,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '$primaryBackgroundColor',
},
backIcon: {
color: '$white',
},
wrapper: {
marginLeft: 16,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '$primaryBackgroundColor',
},
textWrapper: {
marginLeft: 24,
Expand All @@ -26,9 +30,10 @@ export default EStyleSheet.create({
fontWeight: 'bold',
},
username: {
color: '$white',
fontSize: 12,
marginTop: 4,
fontSize: 16,
color: '$primaryDarkText',
fontWeight: '600',
},
addIcon: {
color: '$white',
Expand Down
91 changes: 38 additions & 53 deletions src/components/avatarHeader/avatarHeaderView.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,48 @@
import React from 'react';
import { View, Text, SafeAreaView, TouchableOpacity } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import LinearGradient from 'react-native-linear-gradient';
import { View, Text, TouchableOpacity } from 'react-native';

import { UserAvatar } from '../userAvatar';
import { IconButton } from '../iconButton';

// Styles
import styles from './avatarHeaderStyles';

const AvatarHeader =
({ username, name, reputation, avatarUrl, showImageUploadActions, isUploading }) =>
() => {
const navigation = useNavigation();
const AvatarHeader = ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if AvatarHeader is not being used anywhere else perhaps we can rename component to EditAvatar

username,
name,
reputation,
avatarUrl,
showImageUploadActions,
isUploading,
}) => {
return (
<View style={styles.headerContainer}>
<View style={styles.wrapper}>
<TouchableOpacity onPress={showImageUploadActions}>
<UserAvatar
key={`${avatarUrl}-${username}`}
noAction
size="xl"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using even larger size is possible without making alot of changes

username={username}
avatarUrl={avatarUrl}
isLoading={isUploading}
/>
<IconButton
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button background should primary blue, and perhaps use pencil icon instead plus/add, can also be slightly bigger may be.

Screenshot 2024-04-16 at 18 09 07

iconStyle={styles.addIcon}
style={styles.addButton}
iconType="MaterialCommunityIcons"
name="plus"
onPress={showImageUploadActions}
size={15}
/>
</TouchableOpacity>

return (
<LinearGradient
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
colors={['#357ce6', '#2d5aa0']}
style={styles.headerView}
>
<SafeAreaView>
<View style={styles.headerContainer}>
<IconButton
iconStyle={styles.backIcon}
iconType="MaterialIcons"
name="arrow-back"
onPress={navigation.goBack}
size={25}
/>
<View style={styles.wrapper}>
<TouchableOpacity onPress={showImageUploadActions}>
<UserAvatar
key={`${avatarUrl}-${username}`}
noAction
size="xl"
username={username}
avatarUrl={avatarUrl}
isLoading={isUploading}
/>
<IconButton
iconStyle={styles.addIcon}
style={styles.addButton}
iconType="MaterialCommunityIcons"
name="plus"
onPress={showImageUploadActions}
size={15}
/>
</TouchableOpacity>

<View style={styles.textWrapper}>
{!!name && <Text style={styles.name}>{name}</Text>}
<Text style={styles.username}>{`@${username} (${reputation})`}</Text>
</View>
</View>
</View>
</SafeAreaView>
</LinearGradient>
);
};
<View style={styles.textWrapper}>
{!!name && <Text style={styles.name}>{name}</Text>}
<Text style={styles.username}>{`@${username} (${reputation})`}</Text>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not make sense here... perhaps we can use similar header as used in profile screen without display name and reputation...

Uploading Screenshot 2024-04-16 at 18.10.47.png…

</View>
</View>
</View>
);
};
export default AvatarHeader;
2 changes: 0 additions & 2 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ import TextBoxWithCopy from './textBoxWithCopy/textBoxWithCopy';
import WebViewModal from './webViewModal/webViewModal';
import OrDivider from './orDivider/orDividerView';
import PostTranslationModal from './post-translation-modal/postTranslationModal';
import SimpleHeader from './simpleHeader/simpleHeader';

// Basic UI Elements
import {
Expand Down Expand Up @@ -258,5 +257,4 @@ export {
WebViewModal,
OrDivider,
PostTranslationModal,
SimpleHeader,
};
9 changes: 8 additions & 1 deletion src/components/profileEditForm/profileEditFormStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ export default EStyleSheet.create({
height: 30,
marginTop: 8,
},
imgLabel: {
marginTop: 8,
marginBottom: 8,
fontSize: 14,
color: '$primaryDarkText',
fontWeight: '500',
},
label: {
marginTop: 8,
fontSize: 14,
color: '$primaryDarkText',
fontWeight: '500',
},
formItem: {
marginBottom: 20,
marginBottom: 12,
},
coverImg: {
borderRadius: 5,
Expand Down
61 changes: 34 additions & 27 deletions src/components/profileEditForm/profileEditFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,42 @@ const ProfileEditFormView = ({
contentContainerStyle={styles.contentContainer}
enableOnAndroid={true}
>
<TouchableOpacity style={styles.coverImgWrapper} onPress={showImageUploadActions}>
<ExpoImage
style={styles.coverImg}
source={
coverUrl
? { uri: getResizedImage(coverUrl, 600) }
: isDarkTheme
? DARK_COVER_IMAGE
: LIGHT_COVER_IMAGE
}
/>
{isUploading && (
<ActivityIndicator
style={styles.activityIndicator}
color={EStyleSheet.value('$white')}
size="large"

<View style={styles.formItem}>
<Text style={styles.imgLabel}>
{intl.formatMessage({
id: 'profile.edit.cover_img',
})}
</Text>
<TouchableOpacity style={styles.coverImgWrapper} onPress={showImageUploadActions}>
<ExpoImage
style={styles.coverImg}
source={
coverUrl
? { uri: getResizedImage(coverUrl, 600) }
: isDarkTheme
? DARK_COVER_IMAGE
: LIGHT_COVER_IMAGE
}
/>
)}

<IconButton
iconStyle={styles.addIcon}
style={styles.addButton}
iconType="MaterialCommunityIcons"
name="plus"
onPress={showImageUploadActions}
size={15}
/>
</TouchableOpacity>
{isUploading && (
<ActivityIndicator
style={styles.activityIndicator}
color={EStyleSheet.value('$white')}
size="large"
/>
)}

<IconButton
iconStyle={styles.addIcon}
style={styles.addButton}
iconType="MaterialCommunityIcons"
name="plus"
onPress={showImageUploadActions}
size={15}
/>
</TouchableOpacity>
</View>
{formData.map((item) => (
<View style={styles.formItem} key={item.valueKey}>
<Text style={styles.label}>
Expand Down
26 changes: 0 additions & 26 deletions src/components/simpleHeader/simpleHeader.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/components/simpleHeader/simpleHeaderStyles.ts

This file was deleted.

5 changes: 4 additions & 1 deletion src/config/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
"display_name": "Display Name",
"about": "About",
"location": "Location",
"website": "Website"
"website": "Website",
"edit_profile": "Edit Profile",
"cover_img": "Cover Image",
"profile_img": "Profile Image"
}
},
"settings": {
Expand Down
8 changes: 8 additions & 0 deletions src/containers/profileEditContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class ProfileEditContainer extends Component {
.then((res) => {
if (res.data && res.data.url) {
this.setState({ [action]: res.data.url, isUploading: false, saveEnabled: true });
} else if (res && res.url) {
this.setState({ [action]: res.url, isUploading: false, saveEnabled: true });
} else {
throw Error(
intl.formatMessage({
id: 'alert.unknow_error',
}),
);
}
})
.catch((error) => {
Expand Down
7 changes: 3 additions & 4 deletions src/screens/profileEdit/screen/profileEditScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import get from 'lodash/get';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
import { ProfileEditContainer } from '../../../containers';

import { AvatarHeader, ProfileEditForm } from '../../../components';
import { AvatarHeader, ProfileEditForm } from '../../../components/index';
import { OptionsModal } from '../../../components/atoms';
import styles from './profileEditScreenStyles';
import { SimpleHeader } from '../../../components/index';
import { BasicHeader } from '../../../components/index';

class ProfileEditScreen extends PureComponent {
/* Props
Expand Down Expand Up @@ -57,10 +57,9 @@ class ProfileEditScreen extends PureComponent {
isUploading,
saveEnabled,
handleOnSubmit,
navigation,
}) => (
<View style={styles.container}>
<SimpleHeader onBackPress={() => navigation.goBack()} />
<BasicHeader title={intl.formatMessage({ id: 'profile.edit.edit_profile' })} />
<AvatarHeader
username={get(currentAccount, 'name')}
name={name}
Expand Down