summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 02:58:40 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 02:58:40 +0100
commitc927739f8f221feabb6e19af2c2667eda905a2eb (patch)
treedba3f467fda857e1ac697ee35f45d4229d829137
parentbd4a70dab890153617cad4e0be1364941993d51d (diff)
foto de perfil por url
firestore requiere pago por eso no se hace con imagen subida de galeria.
-rw-r--r--.firebaserc7
-rw-r--r--src/app/(protected)/(tabs)/profile/index.tsx51
-rw-r--r--src/features/profile/hooks/useUpdateProfile.ts7
3 files changed, 62 insertions, 3 deletions
diff --git a/.firebaserc b/.firebaserc
new file mode 100644
index 0000000..7d63602
--- /dev/null
+++ b/.firebaserc
@@ -0,0 +1,7 @@
+{
+ "projects": {
+ "appoficinas": "appoficinas-f8c8d"
+ },
+ "targets": {},
+ "etags": {}
+} \ No newline at end of file
diff --git a/src/app/(protected)/(tabs)/profile/index.tsx b/src/app/(protected)/(tabs)/profile/index.tsx
index 4af1fe0..1e87f21 100644
--- a/src/app/(protected)/(tabs)/profile/index.tsx
+++ b/src/app/(protected)/(tabs)/profile/index.tsx
@@ -7,6 +7,7 @@ import {
TextInput,
View,
} from 'react-native';
+import { Image } from 'expo-image';
import { useAuthSession } from '@/providers/AuthProvider';
import { useProfile } from '@/features/profile/hooks/useProfile';
import { useUpdateProfile } from '@/features/profile/hooks/useUpdateProfile';
@@ -17,18 +18,21 @@ export default function ProfileScreen() {
const { profile, loading, error, reload } = useProfile();
const {
displayName,
+ photoURL,
+ setPhotoURL,
setDisplayName,
isSubmitting,
error: updateError,
successMessage,
submit,
- } = useUpdateProfile(profile?.displayName ?? '');
+ } = useUpdateProfile(profile?.displayName ?? '', profile?.photoURL ?? '');
useEffect(() => {
if (profile?.displayName) {
setDisplayName(profile.displayName);
}
- }, [profile?.displayName]);
+ setPhotoURL(profile?.photoURL ?? '');
+ }, [profile?.displayName, profile?.photoURL, setDisplayName, setPhotoURL]);
const handleLogout = async () => {
await logout();
@@ -59,6 +63,18 @@ export default function ProfileScreen() {
<Text style={styles.title}>Perfil</Text>
<View style={styles.card}>
+ <View style={styles.avatarSection}>
+ {photoURL ? (
+ <Image source={{ uri: photoURL }} style={styles.avatar} contentFit="cover" />
+ ) : (
+ <View style={[styles.avatar, styles.avatarPlaceholder]}>
+ <Text style={styles.avatarPlaceholderText}>
+ {displayName.trim().charAt(0).toUpperCase() || 'U'}
+ </Text>
+ </View>
+ )}
+ </View>
+
<Text style={styles.label}>Correo</Text>
<Text style={styles.value}>{profile.email}</Text>
@@ -70,6 +86,16 @@ export default function ProfileScreen() {
placeholder="Tu nombre"
/>
+ <Text style={styles.label}>URL de la foto</Text>
+ <TextInput
+ style={styles.input}
+ value={photoURL}
+ onChangeText={setPhotoURL}
+ placeholder="https://ejemplo.com/foto.jpg"
+ autoCapitalize="none"
+ autoCorrect={false}
+ />
+
{updateError ? <Text style={styles.error}>{updateError}</Text> : null}
{successMessage ? <Text style={styles.success}>{successMessage}</Text> : null}
@@ -111,6 +137,27 @@ const styles = StyleSheet.create({
padding: 16,
gap: 10,
},
+ avatarSection: {
+ alignItems: 'center',
+ gap: 12,
+ marginBottom: 8,
+ },
+ avatar: {
+ width: 112,
+ height: 112,
+ borderRadius: 56,
+ backgroundColor: '#ddd',
+ },
+ avatarPlaceholder: {
+ alignItems: 'center',
+ justifyContent: 'center',
+ backgroundColor: '#1f6feb',
+ },
+ avatarPlaceholderText: {
+ color: '#fff',
+ fontSize: 36,
+ fontWeight: '700',
+ },
label: {
fontSize: 14,
fontWeight: '700',
diff --git a/src/features/profile/hooks/useUpdateProfile.ts b/src/features/profile/hooks/useUpdateProfile.ts
index 505bfbb..bc069dc 100644
--- a/src/features/profile/hooks/useUpdateProfile.ts
+++ b/src/features/profile/hooks/useUpdateProfile.ts
@@ -4,10 +4,11 @@ import { useState } from 'react';
import { profileService } from '@/features/profile/services/profileService';
import { useAuthSession } from '@/providers/AuthProvider';
-export function useUpdateProfile(initialDisplayName = '') {
+export function useUpdateProfile(initialDisplayName = '', initialPhotoURL = '') {
const { user } = useAuthSession();
const [displayName, setDisplayName] = useState(initialDisplayName);
+ const [photoURL, setPhotoURL] = useState(initialPhotoURL);
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
const [successMessage, setSuccessMessage] = useState<string | null>(null);
@@ -31,8 +32,10 @@ export function useUpdateProfile(initialDisplayName = '') {
await profileService.updateMyProfile({
uid: user.uid,
displayName: displayName.trim(),
+ photoURL: photoURL.trim(),
});
+ setPhotoURL(photoURL.trim());
setSuccessMessage('Perfil actualizado correctamente');
} catch (err: any) {
setError(err?.message ?? 'No se pudo actualizar el perfil');
@@ -43,7 +46,9 @@ export function useUpdateProfile(initialDisplayName = '') {
return {
displayName,
+ photoURL,
setDisplayName,
+ setPhotoURL,
isSubmitting,
error,
successMessage,