diff options
Diffstat (limited to 'src/app/(protected)')
| -rw-r--r-- | src/app/(protected)/(tabs)/offices/index.tsx | 314 | ||||
| -rw-r--r-- | src/app/(protected)/offices/[officeId].tsx | 198 |
2 files changed, 267 insertions, 245 deletions
diff --git a/src/app/(protected)/(tabs)/offices/index.tsx b/src/app/(protected)/(tabs)/offices/index.tsx index c84123a..67fcd92 100644 --- a/src/app/(protected)/(tabs)/offices/index.tsx +++ b/src/app/(protected)/(tabs)/offices/index.tsx @@ -44,7 +44,7 @@ export default function OfficesScreen() { if (error) { return ( <View style={styles.center}> - <Text style={{ color: theme.colors.error }}>{error}</Text> + <Text style={styles.errorText}>{error}</Text> <Pressable style={styles.primaryButton} onPress={reload}> <Text style={styles.primaryButtonText}>Reintentar</Text> </Pressable> @@ -53,132 +53,122 @@ export default function OfficesScreen() { } return ( - <View style={styles.container}> - <View style={styles.content}> - {/* HEADER */} - <View style={styles.header}> - <Text style={styles.title}>Espacios disponibles</Text> - - {/* SEARCH */} - <TextInput - style={styles.search} - placeholder="Buscar espacios..." - value={search} - onChangeText={setSearch} - /> + <View style={styles.container}> + {/* cabecera superior de la pantalla */} + <View style={styles.topBar}> + <Text style={styles.topBarTitle}>Espacios</Text> + </View> - <Pressable - style={[ - styles.favoriteFilterButton, - showOnlyFavorites && styles.favoriteFilterButtonActive, - ]} - onPress={() => setShowOnlyFavorites((current) => !current)} - > - <MaterialIcons - name={showOnlyFavorites ? 'star' : 'star-outline'} - size={18} - color={ - showOnlyFavorites - ? theme.colors.white - : theme.colors.primary - } + <View style={styles.content}> + {/* herramientas de filtrado */} + <View style={styles.toolsCard}> + <TextInput + style={styles.search} + placeholder="Buscar espacios..." + placeholderTextColor={theme.colors.textSecondary} + value={search} + onChangeText={setSearch} /> - <Text + + <Pressable style={[ - styles.favoriteFilterText, - showOnlyFavorites && styles.favoriteFilterTextActive, + styles.favoriteFilterButton, + showOnlyFavorites && styles.favoriteFilterButtonActive, ]} + onPress={() => setShowOnlyFavorites((current) => !current)} > - Solo favoritos - </Text> - </Pressable> - </View> + <MaterialIcons + name={showOnlyFavorites ? "star" : "star-outline"} + size={18} + color={ + showOnlyFavorites ? theme.colors.white : theme.colors.primary + } + /> + <Text + style={[ + styles.favoriteFilterText, + showOnlyFavorites && styles.favoriteFilterTextActive, + ]} + > + Solo favoritos + </Text> + </Pressable> + </View> + + {/* contador de resultados */} + <Text style={styles.resultText}> + {filteredOffices.length} espacio + {filteredOffices.length !== 1 ? "s" : ""} encontrados + </Text> + + {/* lista */} + <FlatList + data={filteredOffices} + keyExtractor={(item) => item.id} + contentContainerStyle={styles.list} + renderItem={({ item }) => { + const isFav = favoriteOfficeIdsSet.has(item.id); + + return ( + <Link href={`/(protected)/offices/${item.id}`} asChild> + <Pressable style={styles.card}> + <View style={styles.cardContent}> + <View style={styles.imageBox}> + <MaterialIcons + name="business" + size={40} + color={theme.colors.primary} + /> + </View> + + <View style={styles.info}> + <View style={styles.rowBetween}> + <View style={styles.infoMain}> + <Text style={styles.cardTitle}>{item.name}</Text> + <Text style={styles.cardSubtitle}> + {item.location} + </Text> + </View> - {/* COUNT */} - <Text style={styles.resultText}> - {filteredOffices.length} espacio - {filteredOffices.length !== 1 ? 's' : ''} encontrados - </Text> - - {/* LIST */} - <FlatList - data={filteredOffices} - keyExtractor={(item) => item.id} - contentContainerStyle={styles.list} - renderItem={({ item }) => { - const isFav = favoriteOfficeIdsSet.has(item.id); - - return ( - <Link href={`/(protected)/offices/${item.id}`} asChild> - <Pressable style={styles.card}> - <View style={styles.cardContent}> - {/* IMAGE PLACEHOLDER */} - {/*<View style={styles.imageBox}> - <Text style={styles.imageIcon}>🏢</Text> - </View>*/} -<View style={styles.imageBox}> - <MaterialIcons - name="business" - size={40} - color={theme.colors.primary} - /> -</View> - {/* INFO */} - <View style={styles.info}> - <View style={styles.rowBetween}> - <View style={{ flex: 1 }}> - <Text style={styles.cardTitle}>{item.name}</Text> - <Text style={styles.cardSubtitle}> - {item.location} - </Text> + <Text style={styles.chevron}>›</Text> </View> - <Text style={styles.chevron}>›</Text> - </View> + <Text style={styles.capacity}> + {item.capacity} personas + </Text> - <Text style={styles.capacity}> - {item.capacity} personas - </Text> - - <View style={styles.footer}> - {/*<Text style={styles.price}> - {item.price ?? '—'} - </Text>*/} - - <View - style={[ - styles.badge, - isFav && styles.badgeActive, - ]} - > - <Text - style={[ - styles.badgeText, - isFav && styles.badgeTextActive, - ]} + <View style={styles.footer}> + <View + style={[styles.badge, isFav && styles.badgeActive]} > - {isFav ? 'Favorito' : 'Disponible'} - </Text> + <Text + style={[ + styles.badgeText, + isFav && styles.badgeTextActive, + ]} + > + {isFav ? "Favorito" : "Disponible"} + </Text> + </View> </View> </View> </View> - </View> - </Pressable> - </Link> - ); - }} - ListEmptyComponent={ - <View style={styles.emptyBox}> - <Text style={styles.emptyText}> - {showOnlyFavorites - ? 'No tienes espacios favoritos con estos filtros' - : 'No se encontraron espacios'} - </Text> - </View> - } - /> + </Pressable> + </Link> + ); + }} + ListEmptyComponent={ + <View style={styles.emptyBox}> + <Text style={styles.emptyText}> + {showOnlyFavorites + ? "No tienes espacios favoritos con estos filtros" + : "No se encontraron espacios"} + </Text> + </View> + } + /> + </View> </View> - </View> ); } @@ -188,31 +178,55 @@ const styles = StyleSheet.create({ backgroundColor: theme.colors.background, }, -content: { - flex: 1, - width: '100%', - maxWidth: theme.layout.contentWidth, - alignSelf: 'center', -}, + content: { + flex: 1, + width: "100%", + maxWidth: theme.layout.contentWidth, + alignSelf: "center", + }, center: { flex: 1, - justifyContent: 'center', - alignItems: 'center', + justifyContent: "center", + alignItems: "center", + padding: theme.spacing.xl, + gap: theme.spacing.md, + backgroundColor: theme.colors.background, }, - header: { + // cabecera superior de la pantalla + topBar: { backgroundColor: theme.colors.surface, - padding: theme.spacing.xl, borderBottomWidth: 1, - borderColor: theme.colors.border, + borderBottomColor: theme.colors.border, + paddingHorizontal: theme.spacing.xl, + paddingTop: theme.spacing.xxxl, + paddingBottom: theme.spacing.lg, }, - title: { - fontSize: theme.typography.xxxl, + // titulo principal de la cabecera + topBarTitle: { + fontSize: theme.typography.xxl, fontWeight: theme.fontWeight.semibold, color: theme.colors.text, - marginBottom: theme.spacing.md, + textAlign: "left", + maxWidth: theme.layout.contentWidth, + width: "100%", + alignSelf: "center", + }, + + errorText: { + color: theme.colors.error, + textAlign: "center", + }, + + // bloque de busqueda y filtros + toolsCard: { + backgroundColor: theme.colors.surface, + padding: theme.spacing.xl, + gap: theme.spacing.md, + borderBottomWidth: 1, + borderBottomColor: theme.colors.border, }, search: { @@ -222,18 +236,18 @@ content: { borderRadius: theme.radius.lg, paddingHorizontal: theme.spacing.lg, paddingVertical: theme.spacing.md, + color: theme.colors.text, }, favoriteFilterButton: { - marginTop: theme.spacing.md, borderWidth: 1, borderColor: theme.colors.primary, borderRadius: theme.radius.lg, paddingHorizontal: theme.spacing.lg, paddingVertical: theme.spacing.md, - flexDirection: 'row', - alignItems: 'center', - justifyContent: 'center', + flexDirection: "row", + alignItems: "center", + justifyContent: "center", gap: theme.spacing.sm, }, @@ -272,7 +286,7 @@ content: { }, cardContent: { - flexDirection: 'row', + flexDirection: "row", gap: theme.spacing.lg, }, @@ -281,12 +295,8 @@ content: { height: 80, borderRadius: theme.radius.lg, backgroundColor: theme.colors.primarySoft, - alignItems: 'center', - justifyContent: 'center', - }, - - imageIcon: { - fontSize: 28, + alignItems: "center", + justifyContent: "center", }, info: { @@ -295,9 +305,13 @@ content: { }, rowBetween: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'flex-start', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "flex-start", + }, + + infoMain: { + flex: 1, }, cardTitle: { @@ -322,14 +336,9 @@ content: { }, footer: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - }, - - price: { - color: theme.colors.primary, - fontWeight: theme.fontWeight.medium, + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", }, badge: { @@ -353,7 +362,7 @@ content: { }, emptyBox: { - alignItems: 'center', + alignItems: "center", padding: theme.spacing.xxxl, }, @@ -361,6 +370,11 @@ content: { color: theme.colors.textSecondary, }, + errorText: { + color: theme.colors.error, + textAlign: "center", + }, + primaryButton: { marginTop: theme.spacing.md, backgroundColor: theme.colors.primary, diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx index 91e6905..16a60cf 100644 --- a/src/app/(protected)/offices/[officeId].tsx +++ b/src/app/(protected)/offices/[officeId].tsx @@ -48,14 +48,14 @@ export default function OfficeDetailScreen() { return ( <View style={styles.center}> <Text style={{ color: theme.colors.error }}> - {error ?? 'No se pudo cargar el espacio'} + {error ?? "No se pudo cargar el espacio"} </Text> <Pressable style={styles.primaryButton} onPress={reload}> <Text style={styles.primaryButtonText}>Reintentar</Text> </Pressable> - <Link href="/offices" asChild> + <Link href="/(protected)/(tabs)/offices" asChild> <Pressable style={styles.secondaryButton}> <Text style={styles.primaryButtonText}>Volver</Text> </Pressable> @@ -68,62 +68,53 @@ export default function OfficeDetailScreen() { const isAvailable = office.available ?? true; return ( - <ScrollView contentContainerStyle={styles.container}> - <View style={styles.content}> - {/* HEADER */} - <Link href="/offices" asChild> - <Pressable> - <Text style={styles.back}>← Volver a espacios</Text> - </Pressable> - </Link> + <View style={styles.container}> + {/* cabecera superior */} + <View style={styles.topBar}> + <View style={styles.topBarContent}> + <Link href="/(protected)/(tabs)/offices" asChild> + <Pressable> + <Text style={styles.topBarBack}>← Volver a espacios</Text> + </Pressable> + </Link> + </View> + </View> + <ScrollView + style={styles.scroll} + contentContainerStyle={styles.content} + showsVerticalScrollIndicator={false} + > {/* IMAGE */} - {/*<View style={styles.imageBox}> - <Text style={styles.imageIcon}>🏢</Text> - </View>*/} -<View style={styles.imageBox}> - <MaterialIcons - name="business" - size={80} - color={theme.colors.primary} - /> -</View> + <View style={styles.imageBox}> + <MaterialIcons + name="business" + size={80} + color={theme.colors.primary} + /> + </View> {/* TITLE */} <View style={styles.titleRow}> - <View style={{ flex: 1 }}> + <View style={styles.titleBlock}> <Text style={styles.title}>{office.name}</Text> <Text style={styles.subtitle}> - {office.location ?? 'Sin ubicación'} + {office.location ?? "Sin ubicación"} </Text> </View> - <View - style={[ - styles.badge, - isAvailable && styles.badgeActive, - ]} - > + <View style={[styles.badge, isAvailable && styles.badgeActive]}> <Text - style={[ - styles.badgeText, - isAvailable && styles.badgeTextActive, - ]} + style={[styles.badgeText, isAvailable && styles.badgeTextActive]} > - {isAvailable ? 'Disponible' : 'Ocupado'} + {isAvailable ? "Disponible" : "Ocupado"} </Text> </View> </View> - {/* CAPACITY + PRICE */} + {/* CAPACITY */} <View style={styles.metaRow}> - <Text style={styles.meta}> - {office.capacity} personas - </Text> - - {/* <Text style={styles.price}> - {office.price ?? '—'} - </Text>*/} + <Text style={styles.meta}>{office.capacity} personas</Text> </View> {/* DESCRIPTION */} @@ -148,6 +139,7 @@ export default function OfficeDetailScreen() { value={selectedDate} onChangeText={setSelectedDate} placeholder="YYYY-MM-DD" + placeholderTextColor={theme.colors.textSecondary} keyboardType="number-pad" maxLength={10} /> @@ -177,9 +169,7 @@ export default function OfficeDetailScreen() { <Text style={styles.occupiedTime}> {reservation.startTime} - {reservation.endTime} </Text> - <Text style={styles.occupiedText}> - Ocupado - </Text> + <Text style={styles.occupiedText}>Ocupado</Text> </View> ))} </View> @@ -193,26 +183,23 @@ export default function OfficeDetailScreen() { {/* FAVORITE */} <Pressable - style={[ - styles.favoriteButton, - isFav && styles.favoriteButtonActive, - ]} + style={[styles.favoriteButton, isFav && styles.favoriteButtonActive]} onPress={() => toggleFavorite(office.id)} disabled={pendingOfficeId === office.id} > <Text style={styles.favoriteText}> {pendingOfficeId === office.id - ? '...' + ? "..." : isFav - ? '★ Guardado' - : '☆ Guardar como favorito'} + ? "★ Guardado" + : "☆ Guardar como favorito"} </Text> </Pressable> {/* RESERVE BUTTON */} <Link href={{ - pathname: '/(protected)/reservations/create', + pathname: "/(protected)/reservations/create", params: { officeId: office.id, officeName: office.name, @@ -221,62 +208,89 @@ export default function OfficeDetailScreen() { asChild > <Pressable style={styles.reserveButton}> - <Text style={styles.reserveText}> - Reservar ahora - </Text> + <Text style={styles.reserveText}>Reservar ahora</Text> </Pressable> </Link> - </View> - </ScrollView> + </ScrollView> + </View> ); } const styles = StyleSheet.create({ container: { - paddingVertical: theme.spacing.xl, + flex: 1, + backgroundColor: theme.colors.background, + }, + + // cabecera superior con el mismo patron que reservas + topBar: { + backgroundColor: theme.colors.surface, + borderBottomWidth: 1, + borderBottomColor: theme.colors.border, + paddingHorizontal: theme.spacing.xl, + paddingTop: theme.spacing.xxxl, + paddingBottom: theme.spacing.lg, + }, + + // contenido centrado de la cabecera + topBarContent: { + maxWidth: theme.layout.contentWidth, + width: "100%", + alignSelf: "center", + }, + + // texto para volver al listado + topBarBack: { + color: theme.colors.textSecondary, + fontSize: theme.typography.md, + }, + + // scroll principal + scroll: { + flex: 1, + backgroundColor: theme.colors.background, }, + // contenido interno del scroll content: { - width: '100%', + width: "100%", maxWidth: theme.layout.contentWidth, - alignSelf: 'center', + alignSelf: "center", paddingHorizontal: theme.spacing.xl, + paddingTop: theme.spacing.lg, + paddingBottom: theme.spacing.xxxl, gap: theme.spacing.xl, }, center: { flex: 1, - justifyContent: 'center', - alignItems: 'center', + justifyContent: "center", + alignItems: "center", padding: theme.spacing.xl, gap: theme.spacing.md, - }, - - back: { - color: theme.colors.textSecondary, - fontSize: theme.typography.md, + backgroundColor: theme.colors.background, }, imageBox: { - width: '100%', + width: "100%", height: 180, borderRadius: theme.radius.xl, backgroundColor: theme.colors.primarySoft, - alignItems: 'center', - justifyContent: 'center', - }, - - imageIcon: { - fontSize: 48, + alignItems: "center", + justifyContent: "center", }, titleRow: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'flex-start', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "flex-start", gap: theme.spacing.md, }, + titleBlock: { + flex: 1, + }, + title: { fontSize: theme.typography.xxxl, fontWeight: theme.fontWeight.semibold, @@ -289,34 +303,28 @@ const styles = StyleSheet.create({ }, metaRow: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", }, meta: { color: theme.colors.textSecondary, }, - price: { - color: theme.colors.primary, - fontSize: theme.typography.xxl, - fontWeight: theme.fontWeight.semibold, - }, - card: { backgroundColor: theme.colors.surface, - borderRadius: theme.radius.lg, + borderRadius: theme.radius.xxl, padding: theme.spacing.lg, borderWidth: 1, borderColor: theme.colors.border, + gap: theme.spacing.md, ...theme.shadows.card, }, sectionTitle: { - fontSize: theme.typography.lg, + fontSize: theme.typography.xl, fontWeight: theme.fontWeight.semibold, - marginBottom: theme.spacing.sm, color: theme.colors.text, }, @@ -347,8 +355,8 @@ const styles = StyleSheet.create({ inlineState: { marginTop: theme.spacing.md, - flexDirection: 'row', - alignItems: 'center', + flexDirection: "row", + alignItems: "center", gap: theme.spacing.sm, }, @@ -418,11 +426,11 @@ const styles = StyleSheet.create({ padding: theme.spacing.md, borderRadius: theme.radius.md, backgroundColor: theme.colors.divider, - alignItems: 'center', + alignItems: "center", }, favoriteButtonActive: { - backgroundColor: '#ffe8a3', + backgroundColor: "#ffe8a3", }, favoriteText: { @@ -434,7 +442,7 @@ const styles = StyleSheet.create({ backgroundColor: theme.colors.primary, paddingVertical: theme.spacing.lg, borderRadius: theme.radius.lg, - alignItems: 'center', + alignItems: "center", }, reserveText: { @@ -459,4 +467,4 @@ const styles = StyleSheet.create({ padding: theme.spacing.md, borderRadius: theme.radius.md, }, -}); +});
\ No newline at end of file |