From cf8afc1ee12a51251a4795d1be6414f640f9e494 Mon Sep 17 00:00:00 2001 From: Anita Date: Sat, 4 Apr 2026 20:52:35 +0100 Subject: feat: menuBar, perfil y home rediseñados y sistema de estilos global creado MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(protected)/(tabs)/home.tsx | 492 ++++++++++++++++++++++++++---------- 1 file changed, 357 insertions(+), 135 deletions(-) (limited to 'src/app/(protected)/(tabs)/home.tsx') 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 ( @@ -44,70 +53,134 @@ export default function HomeScreen() { ); } - if (error || favoritesError) { + if (error) { return ( - {error ?? favoritesError} + {error} ); } return ( + // pantalla inicio - Dashboard + {/* cabecera de bienvenida */} - Bienvenido{user?.displayName ? `, ${user.displayName}` : ''} + Hola{user?.displayName ? `, ${user.displayName}` : ''} 👋 - {user?.email} - - - Próxima reserva - {nextReservation ? ( - <> - {nextReservation.officeName} - - {nextReservation.date} · {nextReservation.startTime} - {nextReservation.endTime} - - - {nextReservation.checkInAt ? 'Llegada registrada' : 'Pendiente de check-in'} - - - - Ver mis reservas - - - + + + Bienvenido a la App Oficina + + + + {/* seccion de accesos rapidos */} + + Accesos rápidos + + + + + + + + + Reservar{"\n"}espacio + + + + + + + + + + + Mis reservas{"\n"}activas + + + + + + + {/* sección de reservas activas */} + + Reservas activas + + + + + Ver todas + {'>'} + + + + + + + {previewReservations.length > 0 ? ( + previewReservations.map((reservation) => ( + + + + + + + + + + + {reservation.officeName} + {'>'} + + + + + + {formatDate(reservation.date)} + + + + + + {reservation.startTime} - {reservation.endTime} + + + + + {reservation.checkInAt ? 'Confirmada' : 'Pendiente'} + + + + + + + + )) ) : ( - <> - No tienes reservas próximas - - Explora espacios disponibles y reserva cuando lo necesites. + + + No tienes reservas activas en este momento. - - - Buscar espacios - - - + )} + {/* seccion de estadisticas */} {activeReservations.length} Reservas activas + - {favoriteOfficeIds.length} - Favoritos - - - {completedReservationsCount} - Completadas + {currentMonthReservationsCount} + Este mes + - {checkedInReservationsCount} - Check-ins + {reservations.length} + Total @@ -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 -- cgit v1.2.3-54-g00ecf