/**
* Home Screen
*
* Dashboard with quick stats and shortcuts
*/
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, RefreshControl } from 'react-native';
import { useState, useCallback } from 'react';
import { router } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';
import { useAuthStore } from '@/stores';
interface StatCardProps {
title: string;
value: string;
icon: keyof typeof Ionicons.glyphMap;
color: string;
onPress?: () => void;
}
function StatCard({ title, value, icon, color, onPress }: StatCardProps) {
return (
{value}
{title}
);
}
interface QuickActionProps {
title: string;
icon: keyof typeof Ionicons.glyphMap;
onPress: () => void;
}
function QuickAction({ title, icon, onPress }: QuickActionProps) {
return (
{title}
);
}
export default function HomeScreen() {
const [refreshing, setRefreshing] = useState(false);
const user = useAuthStore((state) => state.user);
const onRefresh = useCallback(async () => {
setRefreshing(true);
// TODO: Fetch dashboard data
await new Promise((resolve) => setTimeout(resolve, 1000));
setRefreshing(false);
}, []);
return (
}
>
{/* Welcome */}
¡Hola, {user?.fullName?.split(' ')[0] || 'Usuario'}!
Aquí está el resumen de tu negocio
{/* Stats Grid */}
router.push('/(tabs)/partners')}
/>
router.push('/(tabs)/products')}
/>
router.push('/(tabs)/invoices')}
/>
{/* Quick Actions */}
Acciones Rápidas
router.push('/(tabs)/partners')}
/>
router.push('/(tabs)/invoices')}
/>
router.push('/(tabs)/products')}
/>
{}}
/>
{/* Recent Activity */}
Actividad Reciente
Factura #INV-2024-001 pagada
Hace 2 horas
Nuevo cliente: Empresa ABC
Hace 5 horas
Factura #INV-2024-002 creada
Ayer
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f8fafc',
},
content: {
padding: 16,
paddingBottom: 32,
},
welcome: {
marginBottom: 24,
},
welcomeText: {
fontSize: 24,
fontWeight: '700',
color: '#1f2937',
},
welcomeSubtext: {
fontSize: 16,
color: '#64748b',
marginTop: 4,
},
statsGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 12,
marginBottom: 24,
},
statCard: {
backgroundColor: '#ffffff',
borderRadius: 12,
padding: 16,
width: '48%',
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.05,
shadowRadius: 2,
elevation: 1,
},
statIconContainer: {
width: 44,
height: 44,
borderRadius: 10,
justifyContent: 'center',
alignItems: 'center',
marginBottom: 12,
},
statValue: {
fontSize: 24,
fontWeight: '700',
color: '#1f2937',
},
statTitle: {
fontSize: 14,
color: '#64748b',
marginTop: 4,
},
section: {
marginBottom: 24,
},
sectionTitle: {
fontSize: 18,
fontWeight: '600',
color: '#1f2937',
marginBottom: 12,
},
quickActions: {
backgroundColor: '#ffffff',
borderRadius: 12,
overflow: 'hidden',
},
quickAction: {
flexDirection: 'row',
alignItems: 'center',
padding: 16,
borderBottomWidth: 1,
borderBottomColor: '#f1f5f9',
},
quickActionText: {
flex: 1,
fontSize: 16,
color: '#1f2937',
marginLeft: 12,
},
activityList: {
backgroundColor: '#ffffff',
borderRadius: 12,
padding: 16,
},
activityItem: {
flexDirection: 'row',
alignItems: 'flex-start',
marginBottom: 16,
},
activityDot: {
width: 8,
height: 8,
borderRadius: 4,
marginTop: 6,
marginRight: 12,
},
activityContent: {
flex: 1,
},
activityText: {
fontSize: 14,
color: '#1f2937',
},
activityTime: {
fontSize: 12,
color: '#9ca3af',
marginTop: 2,
},
});