Improved avatar photo in user info

This commit is contained in:
Keannu Bernasol 2023-07-17 15:36:18 +08:00
parent f9931a1fdd
commit a4d8309820
3 changed files with 20 additions and 7 deletions

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -33,6 +33,7 @@ export default function UserInfo() {
year_level: data[1].year_level, year_level: data[1].year_level,
semester: data[1].semester, semester: data[1].semester,
course: data[1].course, course: data[1].course,
avatar: data[1].avatar,
}); });
}, },
}); });
@ -45,7 +46,20 @@ export default function UserInfo() {
year_level: "", year_level: "",
semester: "", semester: "",
course: "", course: "",
avatar: "",
}); });
function Avatar() {
if (user.avatar) {
return <Image source={{ uri: user.avatar }} style={styles.profile} />;
} else {
return (
<Image
source={require("../../img/user_profile_placeholder.png")}
style={styles.profile}
/>
);
}
}
return ( return (
<ScrollView style={styles.background}> <ScrollView style={styles.background}>
<AnimatedContainer> <AnimatedContainer>
@ -53,10 +67,7 @@ export default function UserInfo() {
{user.first_name + " " + user.last_name} {user.first_name + " " + user.last_name}
</Text> </Text>
<View> <View>
<Image <Avatar />
source={require("./image/3135715.png")}
style={styles.profile}
/>
</View> </View>
<View style={styles.padding} /> <View style={styles.padding} />
<View style={styles.flex_row}> <View style={styles.flex_row}>
@ -177,7 +188,7 @@ export default function UserInfo() {
onPress={() => setIsEditable(!isEditable)} onPress={() => setIsEditable(!isEditable)}
> >
<Text style={styles.text_white_small}> <Text style={styles.text_white_small}>
{isEditable ? "Save" : "Edit Profile"} {isEditable && UserInfo.isSuccess ? "Save" : "Edit Profile"}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
</AnimatedContainer> </AnimatedContainer>

View file

@ -119,9 +119,11 @@ const styles = StyleSheet.create({
alignSelf: "center", alignSelf: "center",
}, },
profile: { profile: {
height: 80, height: 96,
width: 80, width: 96,
alignSelf: "center", alignSelf: "center",
borderRadius: 150 / 2,
overflow: "hidden",
}, },
input: { input: {
height: 40, height: 40,