New V Needed, improves cache and image handling

This commit is contained in:
Adolfo Reyna
2024-10-04 01:34:24 -04:00
parent dc52f57424
commit 461b8c98ed
7 changed files with 4149 additions and 123 deletions

View File

@@ -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>