feat: load image on home and profile screens
This commit is contained in:
parent
c87d6b176b
commit
7d90c66b50
2 changed files with 8 additions and 3 deletions
|
|
@ -6,6 +6,8 @@ import { UserPhoto } from './UserPhoto';
|
||||||
|
|
||||||
import defaultAvatar from '@assets/userPhotoDefault.png';
|
import defaultAvatar from '@assets/userPhotoDefault.png';
|
||||||
|
|
||||||
|
import { api } from '@services/api';
|
||||||
|
|
||||||
import { useAuth } from '@hooks/useAuth';
|
import { useAuth } from '@hooks/useAuth';
|
||||||
|
|
||||||
export function HomeHeader() {
|
export function HomeHeader() {
|
||||||
|
|
@ -17,7 +19,7 @@ export function HomeHeader() {
|
||||||
return (
|
return (
|
||||||
<HStack bg="$gray600" pt="$16" pb="$5" px="$8" alignItems="center" gap="$4">
|
<HStack bg="$gray600" pt="$16" pb="$5" px="$8" alignItems="center" gap="$4">
|
||||||
<UserPhoto
|
<UserPhoto
|
||||||
source={avatar ? { uri: avatar } : defaultAvatar}
|
source={avatar ? { uri: `${api.defaults.baseURL}/avatar/${avatar}` } : defaultAvatar}
|
||||||
alt="avatar image"
|
alt="avatar image"
|
||||||
h="$16"
|
h="$16"
|
||||||
w="$16"
|
w="$16"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ const profileSchema = yup.object({
|
||||||
|
|
||||||
export function Profile() {
|
export function Profile() {
|
||||||
const [isUpdating, setIsUpdating] = useState(false);
|
const [isUpdating, setIsUpdating] = useState(false);
|
||||||
const [userPhoto, setUserPhoto] = useState('https://i.pravatar.cc/200');
|
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { user, updateUserData } = useAuth();
|
const { user, updateUserData } = useAuth();
|
||||||
|
|
@ -194,7 +193,11 @@ export function Profile() {
|
||||||
|
|
||||||
<ScrollView contentContainerStyle={{ paddingHorizontal: 36 }}>
|
<ScrollView contentContainerStyle={{ paddingHorizontal: 36 }}>
|
||||||
<Center mt="$6" px="$10">
|
<Center mt="$6" px="$10">
|
||||||
<UserPhoto source={{ uri: userPhoto }} alt="imagem de perfil" size="xl" />
|
<UserPhoto
|
||||||
|
source={{ uri: `${api.defaults.baseURL}/avatar/${user.avatar}` }}
|
||||||
|
alt="imagem de perfil"
|
||||||
|
size="xl"
|
||||||
|
/>
|
||||||
|
|
||||||
<TouchableOpacity onPress={handleUserPhotoSelection}>
|
<TouchableOpacity onPress={handleUserPhotoSelection}>
|
||||||
<Text color="$green500" fontFamily="$heading" fontSize="$md" mt="$2" mb="$8">
|
<Text color="$green500" fontFamily="$heading" fontSize="$md" mt="$2" mb="$8">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue