diff options
| author | Anita <ana.tqtc@gmail.com> | 2026-04-04 20:52:35 +0100 |
|---|---|---|
| committer | Anita <ana.tqtc@gmail.com> | 2026-04-04 20:52:35 +0100 |
| commit | cf8afc1ee12a51251a4795d1be6414f640f9e494 (patch) | |
| tree | d942d35bb7a248e7b8de563f3a053eebe4cc8027 | |
| parent | c4d40229201f4bc7221a90d3d458787333786131 (diff) | |
feat: menuBar, perfil y home redise帽ados y sistema de estilos global creado
| -rw-r--r-- | src/app/(protected)/(tabs)/_layout.tsx | 69 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/home.tsx | 492 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/profile/index.tsx | 701 | ||||
| -rw-r--r-- | src/theme/index.ts | 76 |
4 files changed, 1114 insertions, 224 deletions
diff --git a/src/app/(protected)/(tabs)/_layout.tsx b/src/app/(protected)/(tabs)/_layout.tsx index 0b71c6d..a4e0445 100644 --- a/src/app/(protected)/(tabs)/_layout.tsx +++ b/src/app/(protected)/(tabs)/_layout.tsx @@ -1,23 +1,76 @@ import { Tabs } from 'expo-router'; +import { Feather } from '@expo/vector-icons'; +import { MaterialIcons } from '@expo/vector-icons'; +import theme from '@/theme'; + +// accesos cortos al theme de estilos +const { colors, typography, fontWeight, layout } = theme; export default function TabsLayout() { return ( - <Tabs screenOptions={{ headerShown: false }}> + <Tabs + screenOptions={{ + headerShown: false, + tabBarActiveTintColor: colors.primary, + tabBarInactiveTintColor: colors.textSecondary, + tabBarLabelStyle: { + fontSize: typography.sm, + fontWeight: fontWeight.regular, + }, + tabBarStyle: { + height: layout.tabBarHeight, + paddingBottom: 2, + paddingTop: 6, + // ancho acotado igual que el container del home + width: '100%', + maxWidth: layout.contentWidth, + alignSelf: 'center', + backgroundColor: colors.surface, + borderTopColor: colors.border, + }, + }} + > <Tabs.Screen + /* el nombre debe coincidir con la ruta para que expo router + lo detecte bien y muestre el tabBarLabel y en el orden declarado */ name="home" - options={{ title: 'Inicio' }} + options={{ + title: 'Inicio', + tabBarLabel: 'Inicio', + tabBarIcon: ({ color, size }) => ( + <Feather name="home" size={size} color={color} /> + ), + }} /> <Tabs.Screen - name="offices" - options={{ title: 'Espacios' }} + name="offices/index" + options={{ + title: 'Espacios', + tabBarLabel: 'Espacios', + tabBarIcon: ({ color, size }) => ( + <MaterialIcons name="apartment" size={size} color={color} /> + ), + }} /> <Tabs.Screen - name="reservations" - options={{ title: 'Reservas' }} + name="reservations/index" + options={{ + title: 'Reservas', + tabBarLabel: 'Reservas', + tabBarIcon: ({ color, size }) => ( + <Feather name="calendar" size={size} color={color} /> + ), + }} /> <Tabs.Screen - name="profile" - options={{ title: 'Perfil' }} + name="profile/index" + options={{ + title: 'Perfil', + tabBarLabel: 'Perfil', + tabBarIcon: ({ color, size }) => ( + <Feather name="user" size={size} color={color} /> + ), + }} /> </Tabs> ); diff --git a/src/app/(protected)/(tabs)/home.tsx b/src/app/(protected)/(tabs)/home.tsx index 3ddad57..523283c 100644 --- a/src/app/(protected)/(tabs)/home.tsx +++ b/src/app/(protected)/(tabs)/home.tsx @@ -1,42 +1,51 @@ +import { useReservations } from '@/features/reservations/hooks/useReservations'; +import { useAuthSession } from '@/providers/AuthProvider'; +import theme from '@/theme'; +import { Feather, MaterialIcons } from '@expo/vector-icons'; import { Link } from 'expo-router'; import { useMemo } from 'react'; import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; -import { useAuthSession } from '@/providers/AuthProvider'; -import { useReservations } from '@/features/reservations/hooks/useReservations'; -import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; -function getReservationStart(date: string, startTime: string): Date { - return new Date(`${date}T${startTime}:00`); -} +function formatDate(date: string): string { + const parsedDate = new Date(date); + + return parsedDate.toLocaleDateString('es-ES', { + day: '2-digit', + month: 'short', + year: 'numeric', + }); + } + +// creacion de acceso rapidos al theme de estilos +const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; export default function HomeScreen() { const { user } = useAuthSession(); - const { reservations, activeReservations, historyReservations, loading, error } = useReservations(); - const { - favoriteOfficeIds, - isLoadingFavorites, - favoritesError, - } = useFavoriteOffices(); - - const nextReservation = useMemo(() => { - const now = new Date(); + const { reservations, activeReservations, loading, error } = useReservations(); + - return activeReservations.find((reservation) => getReservationStart(reservation.date, reservation.startTime) >= now) - ?? activeReservations[0] - ?? null; - }, [activeReservations]); + // crea el contador de reservas en el mes actual + const currentMonthReservationsCount = useMemo(() => { + const now = new Date(); + const currentMonth = now.getMonth(); + const currentYear = now.getFullYear(); - const completedReservationsCount = useMemo( - () => historyReservations.filter((reservation) => reservation.status === 'completed').length, - [historyReservations] - ); + return reservations.filter((reservation) => { + const reservationDate = new Date(reservation.date); + return ( + reservationDate.getMonth() === currentMonth && + reservationDate.getFullYear() === currentYear + ); + }).length; + }, [reservations]); - const checkedInReservationsCount = useMemo( - () => reservations.filter((reservation) => reservation.checkInAt).length, - [reservations] + // crea una lista con las 2 primeras reservas activas + const previewReservations = useMemo( + () => activeReservations.slice(0, 2), + [activeReservations] ); - if (loading || isLoadingFavorites) { + if (loading) { return ( <View style={styles.center}> <ActivityIndicator size="large" /> @@ -44,70 +53,134 @@ export default function HomeScreen() { ); } - if (error || favoritesError) { + if (error) { return ( <View style={styles.center}> - <Text style={styles.error}>{error ?? favoritesError}</Text> + <Text style={styles.error}>{error}</Text> </View> ); } return ( + // pantalla inicio <View style={styles.container}> - <Text style={styles.eyebrow}>Dashboard</Text> + {/* cabecera de bienvenida */} <Text style={styles.title}> - Bienvenido{user?.displayName ? `, ${user.displayName}` : ''} + Hola{user?.displayName ? `, ${user.displayName}` : ''} 馃憢 </Text> - <Text style={styles.email}>{user?.email}</Text> - - <View style={styles.heroCard}> - <Text style={styles.cardLabel}>Pr贸xima reserva</Text> - {nextReservation ? ( - <> - <Text style={styles.heroTitle}>{nextReservation.officeName}</Text> - <Text style={styles.heroMeta}> - {nextReservation.date} 路 {nextReservation.startTime} - {nextReservation.endTime} - </Text> - <Text style={styles.heroStatus}> - {nextReservation.checkInAt ? 'Llegada registrada' : 'Pendiente de check-in'} - </Text> - <Link href="/(protected)/(tabs)/reservations" asChild> - <Pressable style={styles.button}> - <Text style={styles.buttonText}>Ver mis reservas</Text> - </Pressable> - </Link> - </> + + <Text style={styles.subtitle}> + Bienvenido a la App Oficina + </Text> + <View style={styles.divider} /> + + {/* seccion de accesos rapidos */} + <View style={styles.quickAccessSection}> + <Text style={styles.sectionTitle}>Accesos r谩pidos</Text> + + <View style={styles.quickAccessRow}> + <Link href="/(protected)/reservations/create" asChild> + <Pressable style={styles.quickAccessButton}> + <View style={styles.quickAccessIconContainerLight}> + <MaterialIcons name="apartment" size={28} color="#fff" /> + </View> + <Text style={styles.quickAccessButtonText}> + Reservar{"\n"}espacio + </Text> + </Pressable> + </Link> + + <Link href="/(protected)/(tabs)/reservations" asChild> + <Pressable style={styles.quickAccessButtonDark}> + <View style={styles.quickAccessIconContainerDark}> + <Feather name="calendar" size={28} color="#fff" /> + </View> + <Text style={styles.quickAccessButtonText}> + Mis reservas{"\n"}activas + </Text> + </Pressable> + </Link> + </View> + </View> + + {/* secci贸n de reservas activas */} + <View style={styles.reservationsHeader}> + <Text style={styles.sectionTitle}>Reservas activas</Text> + + <Link href="/(protected)/(tabs)/reservations" asChild> + <Pressable> + <View style={styles.linkRow}> + <Text style={styles.linkText}>Ver todas</Text> + <Text style={styles.chevronSmall}>{'>'}</Text> + </View> + </Pressable> + </Link> + </View> + + <View style={styles.reservationsList}> + {previewReservations.length > 0 ? ( + previewReservations.map((reservation) => ( + <View key={reservation.id} style={styles.reservationCard}> + <View style={styles.reservationContent}> + + <View style={styles.reservationIconContainer}> + <MaterialIcons name="apartment" size={22} color={colors.primary} /> + </View> + + <View style={styles.reservationInfo}> + + <View style={styles.reservationHeader}> + <Text style={styles.reservationOffice}>{reservation.officeName}</Text> + <Text style={styles.chevron}>{'>'}</Text> + </View> + + <View style={styles.reservationMetaRow}> + <MaterialIcons name="access-time" size={14} color={colors.textSecondary} /> + <Text style={styles.reservationMeta}> + {formatDate(reservation.date)} + </Text> + </View> + + <View style={styles.reservationRow}> + <Text style={styles.reservationTime}> + {reservation.startTime} - {reservation.endTime} + </Text> + + <View style={styles.statusBadge}> + <Text style={styles.statusText}> + {reservation.checkInAt ? 'Confirmada' : 'Pendiente'} + </Text> + </View> + </View> + + </View> + </View> + </View> + )) ) : ( - <> - <Text style={styles.heroTitle}>No tienes reservas pr贸ximas</Text> - <Text style={styles.heroMeta}> - Explora espacios disponibles y reserva cuando lo necesites. + <View style={styles.emptyReservationCard}> + <Text style={styles.emptyReservationText}> + No tienes reservas activas en este momento. </Text> - <Link href="/(protected)/(tabs)/offices" asChild> - <Pressable style={styles.button}> - <Text style={styles.buttonText}>Buscar espacios</Text> - </Pressable> - </Link> - </> + </View> )} </View> + {/* seccion de estadisticas */} <View style={styles.statsGrid}> <View style={styles.statCard}> <Text style={styles.statValue}>{activeReservations.length}</Text> <Text style={styles.statLabel}>Reservas activas</Text> </View> + <View style={styles.statCard}> - <Text style={styles.statValue}>{favoriteOfficeIds.length}</Text> - <Text style={styles.statLabel}>Favoritos</Text> - </View> - <View style={styles.statCard}> - <Text style={styles.statValue}>{completedReservationsCount}</Text> - <Text style={styles.statLabel}>Completadas</Text> + <Text style={styles.statValue}>{currentMonthReservationsCount}</Text> + <Text style={styles.statLabel}>Este mes</Text> </View> + <View style={styles.statCard}> - <Text style={styles.statValue}>{checkedInReservationsCount}</Text> - <Text style={styles.statLabel}>Check-ins</Text> + <Text style={styles.statValue}>{reservations.length}</Text> + <Text style={styles.statLabel}>Total</Text> </View> </View> </View> @@ -115,96 +188,245 @@ export default function HomeScreen() { } const styles = StyleSheet.create({ + // el ancho del container esta acotado si se toca hacerlo en el menuBar tambien container: { flex: 1, - padding: 16, - gap: 16, + paddingHorizontal: spacing.xl, + paddingTop: spacing.lg, + paddingBottom: spacing.xl, + gap: 18, + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + backgroundColor: colors.background, }, center: { flex: 1, alignItems: 'center', justifyContent: 'center', - padding: 24, - }, - eyebrow: { - color: '#5a7188', - fontSize: 13, - fontWeight: '700', - textTransform: 'uppercase', - letterSpacing: 1, + padding: spacing.xxxl, + backgroundColor: colors.background, }, + + // estilos de cabecera title: { - fontSize: 32, - fontWeight: '700', + fontSize: typography.xxxl, + fontWeight: fontWeight.medium, + color: colors.text, + }, + subtitle: { + fontSize: typography.xl, + color: colors.muted, + }, + divider: { + height: 1, + backgroundColor: colors.divider, + marginVertical: spacing.md, + }, + + // estilos de la seccion de accesos rapidos + sectionTitle: { + fontSize: typography.xxl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + quickAccessSection: { + gap: spacing.lg, + }, + quickAccessRow: { + flexDirection: 'row', + gap: spacing.lg, + }, + quickAccessButton: { + flex: 1, + backgroundColor: colors.primary, + paddingVertical: spacing.xxxl, + borderRadius: radius.xl, + alignItems: 'center', + justifyContent: 'center', + gap: spacing.md, + minHeight: 120, + }, + quickAccessButtonDark: { + flex: 1, + backgroundColor: colors.primaryDark, + paddingVertical: spacing.xxxl, + borderRadius: radius.xl, + alignItems: 'center', + justifyContent: 'center', + gap: spacing.md, + minHeight: 112, + }, + + // --- estilos textos accesos rapidos + quickAccessButtonText: { + color: colors.white, + fontWeight: fontWeight.regular, + fontSize: typography.md, + textAlign: 'center', + lineHeight: 16, + }, + //---------------------------------- + + quickAccessIconContainerLight: { + width: 40, + height: 40, + borderRadius: radius.md, + backgroundColor: '#3b82f6', + alignItems: 'center', + justifyContent: 'center', + }, + quickAccessIconContainerDark: { + width: 40, + height: 40, + borderRadius: radius.md, + backgroundColor: '#334e68', + alignItems: 'center', + justifyContent: 'center', + }, + + // estilos de reservas activas + reservationsHeader: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + }, + linkRow: { + flexDirection: 'row', + alignItems: 'center', + gap: spacing.xs, + }, + chevronSmall: { + fontSize: typography.lg, + color: colors.primary, + fontWeight: fontWeight.semibold, + }, + linkText: { + color: colors.primary, + fontWeight: fontWeight.regular, + }, + reservationsList: { + gap: spacing.xl, + }, + + // estilos tarjetas de reservas activas + reservationCard: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.xl, + gap: spacing.md, + minHeight: 100, + ...shadows.card, + }, + reservationContent: { + flexDirection: 'row', + gap: spacing.lg, + }, + reservationIconContainer: { + width: 48, + height: 48, + borderRadius: radius.lg, + backgroundColor: colors.primarySoft, + alignItems: 'center', + justifyContent: 'center', + }, + reservationInfo: { + flex: 1, + gap: spacing.sm, + }, + reservationHeader: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + }, + reservationOffice: { + fontSize: 18, + fontWeight: fontWeight.medium, + color: colors.text, + }, + chevron: { + fontSize: 18, + color: colors.textSecondary, + fontWeight: fontWeight.semibold, + }, + reservationMetaRow: { + flexDirection: 'row', + alignItems: 'center', + gap: spacing.sm, + }, + reservationMeta: { + color: colors.textSecondary, + fontSize: typography.md, + }, + reservationRow: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', }, - email: { - color: '#666', + reservationTime: { + color: colors.text, + fontSize: typography.lg, + flex: 1, + }, + statusBadge: { + alignSelf: 'flex-start', + backgroundColor: colors.successBg, + paddingHorizontal: 10, + paddingVertical: spacing.xs, + borderRadius: radius.sm, }, - heroCard: { - backgroundColor: '#eff6ff', + statusText: { + color: colors.successText, + fontWeight: fontWeight.semibold, + fontSize: typography.sm, + }, + emptyReservationCard: { borderWidth: 1, - borderColor: '#c8daf7', - borderRadius: 18, - padding: 18, - gap: 10, - }, - cardLabel: { - color: '#2b5ea8', - fontSize: 13, - fontWeight: '700', - textTransform: 'uppercase', - letterSpacing: 0.8, - }, - heroTitle: { - fontSize: 24, - fontWeight: '700', - color: '#102a43', - }, - heroMeta: { - color: '#365b86', - fontSize: 15, - }, - heroStatus: { - color: '#1d4f91', - fontWeight: '600', + borderColor: colors.border, + borderRadius: radius.xxl, + padding: spacing.xl, + backgroundColor: colors.surface, }, + emptyReservationText: { + color: colors.textSecondary, + textAlign: 'center', + }, + + //estilos estadisticas statsGrid: { flexDirection: 'row', - flexWrap: 'wrap', - gap: 12, + gap: spacing.lg, }, statCard: { - width: '47%', - minWidth: 150, + flex: 1, borderWidth: 1, - borderColor: '#dde3ea', - borderRadius: 16, - padding: 16, - backgroundColor: '#fff', - gap: 4, + borderColor: colors.border, + borderRadius: radius.xxl, + paddingVertical: 18, + paddingHorizontal: spacing.lg, + minHeight: 115, + backgroundColor: colors.surface, + gap: spacing.sm, + alignItems: 'center', + justifyContent: 'space-between', }, + + // --- estilos textos estadisticas statValue: { - fontSize: 28, - fontWeight: '700', - color: '#13293d', + fontSize: typography.xxxl, + fontWeight: fontWeight.regular, + color: colors.text, }, statLabel: { - color: '#66788a', - fontSize: 13, - fontWeight: '600', - }, - button: { - backgroundColor: '#1f6feb', - paddingVertical: 14, - borderRadius: 10, - alignItems: 'center', + color: colors.textSecondary, + fontSize: typography.sm, + fontWeight: fontWeight.regular, + textAlign: 'center', }, + //-------------------------------- + error: { - color: '#9f1d35', + color: colors.error, textAlign: 'center', }, - buttonText: { - color: '#fff', - fontWeight: '600', - }, -}); +});
\ 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 760b352..660d113 100644 --- a/src/app/(protected)/(tabs)/profile/index.tsx +++ b/src/app/(protected)/(tabs)/profile/index.tsx @@ -1,22 +1,34 @@ -import { useEffect } from 'react'; +import { useEffect, useMemo, useState } from 'react'; +import theme from '@/theme'; import { ActivityIndicator, Pressable, + ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native'; +import { Feather } from '@expo/vector-icons'; import { Image } from 'expo-image'; import { useAuthSession } from '@/providers/AuthProvider'; import { useProfile } from '@/features/profile/hooks/useProfile'; import { useUpdateProfile } from '@/features/profile/hooks/useUpdateProfile'; import { router } from 'expo-router'; import { StatusMessage } from '@/shared/ui/StatusMessage'; +import { useOffices } from '@/features/offices/hooks/useOffices'; +import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; + +const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; export default function ProfileScreen() { + // hook de autenticacion const { logout } = useAuthSession(); + + // hook para cargar datos del perfil const { profile, loading, error, reload } = useProfile(); + + // hook para actualizar nombre y foto del perfil const { displayName, photoURL, @@ -28,18 +40,62 @@ export default function ProfileScreen() { submit, } = useUpdateProfile(profile?.displayName ?? '', profile?.photoURL ?? ''); + // hook de favoritos del usuario + const { + favoriteOfficeIds, + isLoadingFavorites, + favoritesError, + } = useFavoriteOffices(); + + // hook con el listado completo de oficinas + const { + offices, + loading: officesLoading, + error: officesError, + } = useOffices(); + + // estado local para alternar entre modo vista y modo edicion + const [isEditing, setIsEditing] = useState(false); + + // cruce entre ids favoritos y lista completa de oficinas + // para obtener los datos reales de las oficinas favoritas + const favoriteOffices = useMemo(() => { + return offices.filter((office) => favoriteOfficeIds.includes(office.id)); + }, [offices, favoriteOfficeIds]); + + // sincroniza el formulario con los datos cargados del perfil useEffect(() => { if (profile?.displayName) { setDisplayName(profile.displayName); } + setPhotoURL(profile?.photoURL ?? ''); }, [profile?.displayName, profile?.photoURL, setDisplayName, setPhotoURL]); + // cerrar sesion y redirigir a pantalla de bienvenida const handleLogout = async () => { await logout(); router.replace('/(auth)/welcome'); }; + // cambia entre modo vista y modo edicion + const handleToggleEditing = () => { + // si se pulsa cancelar, restauramos los valores actuales del perfil + if (isEditing) { + setDisplayName(profile?.displayName ?? ''); + setPhotoURL(profile?.photoURL ?? ''); + } + + setIsEditing((current) => !current); + }; + + // guardar cambios del perfil + const handleSaveProfile = async () => { + await submit(); + setIsEditing(false); + }; + + // estado de carga inicial del perfil if (loading) { return ( <View style={styles.center}> @@ -48,10 +104,12 @@ export default function ProfileScreen() { ); } + // estado de error general del perfil if (error || !profile) { return ( <View style={styles.center}> <Text style={styles.error}>{error ?? 'No se pudo cargar el perfil'}</Text> + <Pressable style={styles.button} onPress={reload}> <Text style={styles.buttonText}>Reintentar</Text> </Pressable> @@ -60,11 +118,19 @@ export default function ProfileScreen() { } return ( - <View style={styles.container}> - <Text style={styles.title}>Perfil</Text> - - <View style={styles.card}> - <View style={styles.avatarSection}> + <ScrollView + style={styles.container} + contentContainerStyle={styles.content} + showsVerticalScrollIndicator={false} + > + {/* cabecera superior visual dentro del scroll */} + <View style={styles.topBar}> + <Text style={styles.topBarTitle}>Perfil</Text> + </View> + {/* tarjeta cabecera del perfil */} + {/* avatar, nombre, correo y boton editar / cancelar */} + <View style={styles.headerCard}> + <View style={styles.headerRow}> {photoURL ? ( <Image source={{ uri: photoURL }} style={styles.avatar} contentFit="cover" /> ) : ( @@ -74,125 +140,598 @@ export default function ProfileScreen() { </Text> </View> )} + + <View style={styles.headerInfo}> + {/* nombre del usuario */} + <Text style={styles.profileName}>{displayName || 'Usuario'}</Text> + + {/* correo del usuario */} + <Text style={styles.profileEmail}>{profile.email}</Text> + + {/* boton editar perfil / cancelar */} + <Pressable style={styles.editButton} onPress={handleToggleEditing}> + <Text style={styles.editButtonText}> + {isEditing ? 'Cancelar' : 'Editar perfil'} + </Text> + </Pressable> + </View> </View> + </View> + + {/* seccion sobre mi */} + {/* solo visual por ahora, FALTA CONEXION CON FIREBASE PARA GUARDAR INFO */} + <View style={styles.section}> + <Text style={styles.sectionTitle}>Sobre m铆</Text> - <Text style={styles.label}>Correo</Text> - <Text style={styles.value}>{profile.email}</Text> - - <Text style={styles.label}>Nombre</Text> - <TextInput - style={styles.input} - value={displayName} - onChangeText={setDisplayName} - 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 ? <StatusMessage message={updateError} /> : null} - {successMessage ? <StatusMessage message={successMessage} tone="success" /> : null} - - <Pressable style={styles.button} onPress={submit} disabled={isSubmitting}> - <Text style={styles.buttonText}> - {isSubmitting ? 'Guardando...' : 'Guardar cambios'} + <View style={styles.card}> + <Text style={styles.aboutText}> + Espacio personal del usuario para mostrar una breve descripci贸n o + presentaci贸n dentro de la aplicaci贸n. </Text> - </Pressable> + </View> + </View> + + {/* seccion informacion personal */} + {/* en modo vista muestra datos */} + {/* en modo edicion muestra formulario */} + <View style={styles.section}> + <Text style={styles.sectionTitle}>Informaci贸n personal</Text> + + <View style={styles.card}> + {isEditing ? ( + <> + {/* formulario de edicion: nombre */} + <Text style={styles.label}>Nombre</Text> + <TextInput + style={styles.input} + value={displayName} + onChangeText={setDisplayName} + placeholder="Tu nombre" + /> + + {/* formulario de edicion: url de la foto */} + <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} + /> + + {/* mensajes de error o exito al guardar */} + {updateError ? <StatusMessage message={updateError} /> : null} + {successMessage ? ( + <StatusMessage message={successMessage} tone="success" /> + ) : null} + + {/* boton guardar cambios */} + <Pressable + style={styles.button} + onPress={handleSaveProfile} + disabled={isSubmitting} + > + <Text style={styles.buttonText}> + {isSubmitting ? 'Guardando...' : 'Guardar cambios'} + </Text> + </Pressable> + </> + ) : ( + <> + {/* fila de nombre completo */} + <View style={styles.infoRow}> + <Feather name="user" size={16} color={colors.textSecondary} /> + <View style={styles.infoContent}> + <Text style={styles.infoLabel}>Nombre completo</Text> + <Text style={styles.infoValue}>{displayName || 'Usuario'}</Text> + </View> + </View> + + {/* fila de correo electronico */} + <View style={styles.infoRow}> + <Feather name="mail" size={16} color={colors.textSecondary} /> + <View style={styles.infoContent}> + <Text style={styles.infoLabel}>Correo electr贸nico</Text> + <Text style={styles.infoValue}>{profile.email}</Text> + </View> + </View> + + {/* fila de telefono */} + {/* por ahora es solo visual, FALTA CONEXION CON FIREBASE */} + <View style={styles.infoRow}> + <Feather name="phone" size={16} color={colors.textSecondary} /> + <View style={styles.infoContent}> + <Text style={styles.infoLabel}>Tel茅fono</Text> + <Text style={styles.infoValue}>+34 600 123 456</Text> + </View> + </View> + + {/* fila de empresa */} + {/* por ahora es solo visual, FALTA CONEXION CON FIREBASE */} + <View style={styles.infoRow}> + <Feather name="briefcase" size={16} color={colors.textSecondary} /> + <View style={styles.infoContent}> + <Text style={styles.infoLabel}>Empresa</Text> + <Text style={styles.infoValue}>Empresa Innovadora S.L.</Text> + </View> + </View> + </> + )} + </View> + </View> + + {/* seccion favoritos */} + <View style={styles.section}> + <Text style={styles.sectionTitle}>Favoritos</Text> + + <View style={styles.card}> + {isLoadingFavorites || officesLoading ? ( + <Text style={styles.aboutText}>Cargando favoritos...</Text> + ) : favoritesError || officesError ? ( + <Text style={styles.errorText}> + {favoritesError ?? officesError} + </Text> + ) : favoriteOffices.length === 0 ? ( + <Text style={styles.aboutText}> + Todav铆a no has marcado oficinas como favoritas. + </Text> + ) : ( + <> + {/* cabecera resumida de favoritos */} + <View style={styles.favoriteSummaryRow}> + <Text style={styles.favoriteCount}>{favoriteOffices.length}</Text> + <Text style={styles.favoriteSummaryText}>oficinas guardadas</Text> + </View> + + {/* lista corta de favoritos, limitada a 3 */} + <View style={styles.favoritesList}> + {favoriteOffices.slice(0, 3).map((office) => ( + <View key={office.id} style={styles.favoriteRow}> + <View style={styles.favoriteIconWrap}> + <Feather name="star" size={14} color={colors.primary} /> + </View> + + <View style={styles.favoriteTextBlock}> + <Text style={styles.favoriteItemText}>{office.name}</Text> + <Text style={styles.favoriteItemMeta}>Espacio favorito</Text> + </View> + </View> + ))} + </View> + + {/* enlace visual para ver todos los favoritos + solo aparece si hay mas de 3 favoritos */} + {favoriteOffices.length > 3 ? ( + <Pressable style={styles.viewAllButton}> + <Text style={styles.viewAllText}>Ver todos</Text> + </Pressable> + ) : null} + </> + )} + </View> + </View> + + {/* seccion enlaces secundarios */} + <View style={styles.section}> + <View style={styles.card}> + <View style={styles.linkItem}> + <View style={styles.linkLeft}> + <Feather name="bell" size={16} color={colors.textSecondary} /> + <Text style={styles.linkText}>Notificaciones</Text> + </View> + <Text style={styles.chevron}>{'>'}</Text> + </View> + + <View style={styles.linkItem}> + <View style={styles.linkLeft}> + <Feather name="shield" size={16} color={colors.textSecondary} /> + <Text style={styles.linkText}>Privacidad y seguridad</Text> + </View> + <Text style={styles.chevron}>{'>'}</Text> + </View> + + <View style={styles.linkItem}> + <View style={styles.linkLeft}> + <Feather name="help-circle" size={16} color={colors.textSecondary} /> + <Text style={styles.linkText}>Ayuda y soporte</Text> + </View> + <Text style={styles.chevron}>{'>'}</Text> + </View> + </View> </View> + {/* boton cerrar sesion */} <Pressable style={styles.logoutButton} onPress={handleLogout}> - <Text style={styles.buttonText}>Cerrar sesi贸n</Text> + <View style={styles.logoutContent}> + <Feather name="log-out" size={16} color={colors.error} /> + <Text style={styles.logoutButtonText}>Cerrar sesi贸n</Text> + </View> </Pressable> - </View> + + {/* texto inferior de version */} + <Text style={styles.footerText}>App Oficina v1.0.0</Text> + </ScrollView> ); } const styles = StyleSheet.create({ + // contenedor principal de la pantalla container: { flex: 1, - padding: 16, - gap: 16, + backgroundColor: colors.background, + }, + + // contenido interno del scroll + // padding general, separacion entre bloques y el ancho maximo + // para mantener consistencia con otras pantallas + content: { + padding: spacing.xl, + paddingTop: spacing.lg, + gap: spacing.lg, + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + paddingBottom: spacing.xxxl, }, + + // estado de carga y error general center: { flex: 1, alignItems: 'center', justifyContent: 'center', - padding: 24, - gap: 12, + padding: spacing.xxxl, + gap: spacing.md, + backgroundColor: colors.background, }, - title: { - fontSize: 28, - fontWeight: '700', + + // titulo superior de la pantalla + topBar: { + backgroundColor: colors.surface, + borderBottomWidth: 1, + borderBottomColor: colors.border, + paddingHorizontal: spacing.xl, + paddingTop: spacing.lg, + paddingBottom: spacing.lg, + marginHorizontal: -spacing.xl, + marginTop: -spacing.lg, }, - card: { + topBarTitle: { + fontSize: typography.xxl, + fontWeight: fontWeight.semibold, + color: colors.text, + textAlign: 'left', + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + paddingHorizontal: spacing.xl, + }, + + // tarjeta superior de cabecera + headerCard: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.lg, borderWidth: 1, - borderColor: '#ddd', - borderRadius: 12, - padding: 16, - gap: 10, + borderColor: colors.border, + ...shadows.card, }, - avatarSection: { + + // fila interna de la cabecera + // coloca avatar a la izquierda y datos a la derecha + headerRow: { + flexDirection: 'row', alignItems: 'center', - gap: 12, - marginBottom: 8, + gap: spacing.lg, + }, + + // bloque de informacion de la cabecera + headerInfo: { + flex: 1, + gap: spacing.xs, }, + + // avatar del usuario avatar: { - width: 112, - height: 112, - borderRadius: 56, - backgroundColor: '#ddd', + width: 64, + height: 64, + borderRadius: 32, }, + + // avatar alternativo cuando no hay foto avatarPlaceholder: { + backgroundColor: colors.primary, alignItems: 'center', justifyContent: 'center', - backgroundColor: '#1f6feb', }, + + // letra dentro del avatar alternativo avatarPlaceholderText: { - color: '#fff', - fontSize: 36, - fontWeight: '700', + color: colors.white, + fontSize: 28, + fontWeight: fontWeight.semibold, }, - label: { - fontSize: 14, - fontWeight: '700', - color: '#444', + + // nombre principal del usuario + profileName: { + fontSize: typography.xl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // correo mostrado en cabecera + profileEmail: { + fontSize: typography.md, + color: colors.textSecondary, + }, + + // boton pequeno de editar / cancelar + editButton: { + marginTop: spacing.xs, + borderWidth: 1, + borderColor: colors.primary, + paddingVertical: spacing.xs, + paddingHorizontal: spacing.md, + borderRadius: radius.md, + alignSelf: 'flex-start', + }, + + // texto del boton editar / cancelar + editButtonText: { + color: colors.primary, + fontSize: typography.sm, + fontWeight: fontWeight.medium, + }, + + // separacion entre titulo de seccion y tarjeta + section: { + gap: spacing.sm, + }, + + // titulo de cada seccion + sectionTitle: { + fontSize: typography.xl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // tarjeta base reutilizable + card: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.lg, + borderWidth: 1, + borderColor: colors.border, + ...shadows.card, + gap: spacing.md, + }, + + // fila de informacion personal con icono a la izquierda + infoRow: { + flexDirection: 'row', + alignItems: 'flex-start', + gap: spacing.md, + }, + + // contenido de texto dentro de cada fila de informacion + infoContent: { + flex: 1, + gap: spacing.xs, + }, + + // bloque antiguo de informacion personal + // se mantienen por si se reutiliza sino ELIMINAR + infoBlock: { + gap: spacing.xs, + }, + + // etiqueta pequena de informacion personal + infoLabel: { + fontSize: typography.sm, + color: colors.textSecondary, + fontWeight: fontWeight.regular, + }, + + // valor mostrado en informacion personal + infoValue: { + fontSize: typography.md, + color: colors.text, + fontWeight: fontWeight.medium, + }, + + // texto general de apoyo + // usado en sobre mi, favoritos vacios y mensajes similares + aboutText: { + fontSize: typography.md, + color: colors.textSecondary, + lineHeight: 20, + }, + + // texto de error en secciones concretas + errorText: { + fontSize: typography.md, + color: colors.error, + }, + + // bloque de favoritos + // fila resumen de favoritos coloca numero y texto en la misma linea + favoriteSummaryRow: { + flexDirection: 'row', + alignItems: 'baseline', + gap: spacing.sm, + marginBottom: spacing.xs, + }, + + // numero grande de favoritos + favoriteCount: { + fontSize: typography.xxxl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // texto pequeno junto al numero + favoriteSummaryText: { + fontSize: typography.sm, + color: colors.textSecondary, + }, + + // lista interna de favoritos + favoritesList: { + gap: spacing.sm, + marginTop: spacing.xs, + }, + + // fila individual de favorito + favoriteRow: { + flexDirection: 'row', + alignItems: 'center', + gap: spacing.md, + paddingVertical: spacing.sm, + paddingHorizontal: spacing.sm, + borderRadius: radius.md, + backgroundColor: colors.background, + borderWidth: 1, + borderColor: colors.border, + }, + + // contenedor del icono del favorito + favoriteIconWrap: { + width: 28, + height: 28, + borderRadius: 14, + backgroundColor: colors.primarySoft, + alignItems: 'center', + justifyContent: 'center', + }, + + // bloque de texto del favorito + favoriteTextBlock: { + flex: 1, + gap: 2, + }, + + // texto del nombre de la oficina favorita + favoriteItemText: { + fontSize: typography.md, + color: colors.text, + fontWeight: fontWeight.medium, + }, + + // texto secundario pequeno del favorito + favoriteItemMeta: { + fontSize: typography.sm, + color: colors.textSecondary, + }, + + // boton / enlace visual para ver todos los favoritos + viewAllButton: { + marginTop: spacing.xs, + alignSelf: 'flex-start', + }, + + // texto del enlace ver todos + viewAllText: { + fontSize: typography.sm, + color: colors.primary, + fontWeight: fontWeight.medium, }, - value: { - fontSize: 16, - color: '#111', + + // formulario de edicion + // etiqueta de cada input + label: { + fontSize: typography.md, + fontWeight: fontWeight.semibold, + color: colors.text, }, + + // input de texto para campos editables input: { borderWidth: 1, - borderColor: '#ccc', - borderRadius: 10, - paddingHorizontal: 14, - paddingVertical: 12, + borderColor: colors.border, + borderRadius: radius.md, + paddingHorizontal: spacing.lg, + paddingVertical: spacing.md, + backgroundColor: colors.surface, }, + + // boton principal de guardar cambios button: { - backgroundColor: '#1f6feb', - paddingVertical: 14, - borderRadius: 10, + backgroundColor: colors.primary, + paddingVertical: spacing.lg, + borderRadius: radius.md, + alignItems: 'center', + marginTop: spacing.sm, + }, + + // texto del boton principal + buttonText: { + color: colors.white, + fontWeight: fontWeight.semibold, + }, + + // bloque de enlaces secundarios + // cada fila del bloque + linkItem: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + paddingVertical: spacing.md, + }, + + // parte izquierda del enlace: icono + texto + linkLeft: { + flexDirection: 'row', alignItems: 'center', + gap: spacing.md, + }, + + // texto del enlace + linkText: { + fontSize: typography.md, + color: colors.text, + }, + + // flecha simple a la derecha + chevron: { + fontSize: typography.md, + color: colors.textSecondary, }, + + // boton de cerrar sesion logoutButton: { - backgroundColor: '#c62828', - paddingVertical: 14, - borderRadius: 10, + borderWidth: 1, + borderColor: '#f3b4b4', + backgroundColor: colors.surface, + paddingVertical: spacing.md, + borderRadius: radius.md, alignItems: 'center', + marginTop: spacing.sm, }, - buttonText: { - color: '#fff', - fontWeight: '600', + + // texto del boton cerrar sesion + logoutButtonText: { + color: colors.error, + fontWeight: fontWeight.regular, + }, + // contenido interno del boton cerrar sesion + // alinea icono y texto en horizontal + logoutContent: { + flexDirection: 'row', + alignItems: 'center', + gap: spacing.sm, }, + + // texto inferior de version + footerText: { + textAlign: 'center', + color: colors.muted, + fontSize: typography.sm, + marginTop: spacing.sm, + }, + + // error general de pantalla error: { - color: '#9f1d35', + color: colors.error, textAlign: 'center', }, -}); +});
\ No newline at end of file diff --git a/src/theme/index.ts b/src/theme/index.ts new file mode 100644 index 0000000..c7fc54a --- /dev/null +++ b/src/theme/index.ts @@ -0,0 +1,76 @@ +export const theme = { + // estilos globales para las pantallas + colors: { + primary: '#1f6feb', + primaryDark: '#243b53', + primarySoft: '#e7f0ff', + + background: '#f8fafc', + surface: '#ffffff', + + text: '#13293d', + textSecondary: '#66788a', + muted: '#5a7188', + + border: '#dde3ea', + divider: '#e5e7eb', + + successBg: '#d1fae5', + successText: '#065f46', + + error: '#9f1d35', + white: '#ffffff', + }, + + spacing: { + xs: 4, + sm: 6, + md: 8, + lg: 12, + xl: 16, + xxl: 20, + xxxl: 24, + }, + + radius: { + sm: 8, + md: 10, + lg: 12, + xl: 14, + xxl: 16, + }, + + typography: { + xs: 9, + sm: 12, + md: 13, + lg: 14, + xl: 16, + xxl: 20, + xxxl: 26, + }, + + fontWeight: { + light: '200' as const, + regular: '400' as const, + medium: '500' as const, + semibold: '600' as const, + }, + + layout: { + contentWidth: 448, + tabBarHeight: 64, + }, + + shadows: { + card: { + shadowColor: '#000', + shadowOpacity: 0.05, + shadowRadius: 10, + shadowOffset: { width: 0, height: 4 }, + elevation: 2, + }, + }, +}; + +export default theme;
\ No newline at end of file |