/* * File: StatsOverview.tsx * Description: Statistics overview component for AI predictions dashboard * Design & Developed by Tech4Biz Solutions * Copyright (c) Spurrin Innovations. All rights reserved. */ import React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Dimensions, } from 'react-native'; import Icon from 'react-native-vector-icons/Feather'; import { theme } from '../../../theme'; import type { AIPredictionStats } from '../types'; // ============================================================================ // INTERFACES // ============================================================================ interface StatsOverviewProps { stats: AIPredictionStats; onStatsPress?: (statType: string) => void; isLoading?: boolean; style?: any; } interface StatCardProps { title: string; value: string | number; subtitle?: string; iconName: string; color: string; onPress?: () => void; trend?: number; isPercentage?: boolean; } // ============================================================================ // CONSTANTS // ============================================================================ const { width } = Dimensions.get('window'); const CARD_WIDTH = (width - 48) / 2; // Two cards per row with margins // ============================================================================ // STAT CARD COMPONENT // ============================================================================ /** * StatCard Component * * Purpose: Individual statistics card */ const StatCard: React.FC = ({ title, value, subtitle, iconName, color, onPress, trend, isPercentage = false, }) => { const displayValue = typeof value === 'number' ? isPercentage ? `${Math.round(value * 100)}%` : value.toLocaleString() : value; return ( {/* Card Header */} {displayValue} {trend !== undefined && ( = 0 ? 'trending-up' : 'trending-down'} size={14} color={trend >= 0 ? theme.colors.success : theme.colors.error} /> = 0 ? theme.colors.success : theme.colors.error } ]}> {Math.abs(trend).toFixed(1)}% )} {/* Card Content */} {title} {subtitle && ( {subtitle} )} ); }; // ============================================================================ // STATS OVERVIEW COMPONENT // ============================================================================ /** * StatsOverview Component * * Purpose: Display comprehensive AI predictions statistics * * Features: * - Total cases overview * - Critical and urgent case counts * - Review progress tracking * - Average confidence metrics * - Trend indicators * - Interactive stat cards * - Responsive grid layout * - Modern card design * - Accessibility support */ const StatsOverview: React.FC = ({ stats, onStatsPress, isLoading = false, style, }) => { // ============================================================================ // EVENT HANDLERS // ============================================================================ /** * Handle Stat Press * * Purpose: Handle statistics card press */ const handleStatPress = (statType: string) => { if (onStatsPress) { onStatsPress(statType); } }; // ============================================================================ // RENDER // ============================================================================ if (isLoading) { return ( AI Predictions Overview Loading statistics... ); } return ( {/* Section Header */} AI Predictions Overview handleStatPress('all')} accessibilityRole="button" accessibilityLabel="View all statistics" > View All {/* Statistics Grid */} {/* Total Cases */} handleStatPress('total')} /> {/* Critical Cases */} handleStatPress('critical')} /> {/* Urgent Cases */} handleStatPress('urgent')} /> {/* Reviewed Cases */} handleStatPress('reviewed')} /> {/* Pending Cases */} handleStatPress('pending')} /> {/* Average Confidence */} handleStatPress('confidence')} isPercentage={true} /> {/* Today's Cases */} handleStatPress('today')} /> {/* Weekly Trend */} = 0 ? '+' : ''}${stats.weeklyTrend.toFixed(1)}%`} subtitle="vs last week" iconName={stats.weeklyTrend >= 0 ? 'trending-up' : 'trending-down'} color={stats.weeklyTrend >= 0 ? theme.colors.success : theme.colors.error} onPress={() => handleStatPress('trend')} trend={stats.weeklyTrend} /> {/* Summary Section */} Quick Insights Review Progress: {Math.round((stats.reviewedCases / stats.totalCases) * 100)}% Critical Rate: {Math.round((stats.criticalCases / stats.totalCases) * 100)}% Daily Average: {Math.round(stats.totalCases / 7)} cases ); }; // ============================================================================ // STYLES // ============================================================================ const styles = StyleSheet.create({ container: { backgroundColor: theme.colors.background, paddingVertical: theme.spacing.lg, }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: theme.spacing.md, marginBottom: theme.spacing.lg, }, sectionTitle: { fontSize: theme.typography.fontSize.displaySmall, fontWeight: theme.typography.fontWeight.bold, color: theme.colors.textPrimary, }, viewAllButton: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing.xs, }, viewAllText: { fontSize: theme.typography.fontSize.bodyMedium, color: theme.colors.primary, fontWeight: theme.typography.fontWeight.medium, }, loadingContainer: { paddingVertical: theme.spacing.xxl, alignItems: 'center', }, loadingText: { fontSize: theme.typography.fontSize.bodyMedium, color: theme.colors.textMuted, }, statsGrid: { flexDirection: 'row', flexWrap: 'wrap', paddingHorizontal: theme.spacing.md, gap: theme.spacing.md, }, statCard: { width: CARD_WIDTH, backgroundColor: theme.colors.background, borderRadius: theme.borderRadius.medium, borderLeftWidth: 4, padding: theme.spacing.md, ...theme.shadows.medium, }, cardHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: theme.spacing.sm, }, iconContainer: { width: 36, height: 36, borderRadius: 18, justifyContent: 'center', alignItems: 'center', }, trendContainer: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing.xs, }, trendText: { fontSize: theme.typography.fontSize.caption, fontWeight: theme.typography.fontWeight.medium, }, cardContent: { gap: theme.spacing.xs, }, statValue: { fontSize: theme.typography.fontSize.displayMedium, fontWeight: theme.typography.fontWeight.bold, color: theme.colors.textPrimary, }, statTitle: { fontSize: theme.typography.fontSize.bodyMedium, color: theme.colors.textSecondary, fontWeight: theme.typography.fontWeight.medium, }, statSubtitle: { fontSize: theme.typography.fontSize.bodySmall, color: theme.colors.textMuted, }, summarySection: { paddingHorizontal: theme.spacing.md, marginTop: theme.spacing.lg, }, summaryCard: { backgroundColor: theme.colors.background, borderRadius: theme.borderRadius.medium, padding: theme.spacing.lg, ...theme.shadows.small, }, summaryHeader: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm, marginBottom: theme.spacing.md, }, summaryTitle: { fontSize: theme.typography.fontSize.bodyLarge, fontWeight: theme.typography.fontWeight.bold, color: theme.colors.textPrimary, }, summaryContent: { gap: theme.spacing.sm, }, summaryItem: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, summaryLabel: { fontSize: theme.typography.fontSize.bodyMedium, color: theme.colors.textSecondary, }, summaryValue: { fontSize: theme.typography.fontSize.bodyMedium, fontWeight: theme.typography.fontWeight.bold, color: theme.colors.textPrimary, }, }); export default StatsOverview; /* * End of File: StatsOverview.tsx * Design & Developed by Tech4Biz Solutions * Copyright (c) Spurrin Innovations. All rights reserved. */