New V Needed, improves cache and image handling
This commit is contained in:
@@ -3,8 +3,9 @@ import { Avatar } from 'react-native-paper';
|
||||
import { View, StyleSheet, Text } from 'react-native';
|
||||
import API from './../API.js';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { Image } from 'expo-image'; // Import Image from expo-image
|
||||
|
||||
const DefaultPhoto = "https://social.emmint.com/uploads/e6f9be6d665dc43417701bf16a90122c.png";
|
||||
const DefaultPhoto = "https://social.emmint.com/uploads/e6f9be6d665dc43417701bf16a90122c.png?width=200&height=200";
|
||||
|
||||
const ProfileHeader = ({ profileid, withName = false, small = false }) => {
|
||||
let [profile, setProfile] = useState({});
|
||||
@@ -21,16 +22,20 @@ const ProfileHeader = ({ profileid, withName = false, small = false }) => {
|
||||
subscribed = false;
|
||||
};
|
||||
}, [profileid]);
|
||||
let photoUrl = profile.profile && profile.profile.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto;
|
||||
let photoUrl = profile.profile && profile.profile.photo ? 'https://social.emmint.com/' + profile.profile.photo + '?width=100&height=100' : DefaultPhoto;
|
||||
const fullName = " " + profile.profile?.firstName + " " + profile.profile?.lastName;
|
||||
const onPress = () => {
|
||||
return navigation.navigate('Profile', { profileid })
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.avatarContainer}>
|
||||
<Avatar.Image size={small ? 20 : 35} source={{ uri: photoUrl }} onPress={onPress} style={{marginLeft:-4}}/>
|
||||
</View>
|
||||
<Image source={{ uri: photoUrl }} key={photoUrl}
|
||||
style={{
|
||||
width: small ? 25 : 35,
|
||||
height: small ? 25 : 35,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 50,
|
||||
}} cachePolicy="memory-disk"/>
|
||||
<View style={styles.textContainer}>
|
||||
<Text style={small ? styles.smallProfileName : styles.profileName} onPress={onPress}>{fullName}</Text>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user