|
| 1 | +import { ScrollView, View } from 'react-native' |
| 2 | +import { Card, Screen, Skeleton, SkeletonStatRow } from '../ui' |
| 3 | + |
| 4 | +// A card section-header placeholder: brand-dot + title line, optional right control. |
| 5 | +function CardHeaderSkel({ right }: { right?: boolean }) { |
| 6 | + return ( |
| 7 | + <View className="mb-3 flex-row items-center justify-between"> |
| 8 | + <View className="flex-row items-center gap-2"> |
| 9 | + <Skeleton width={16} height={16} radius={5} /> |
| 10 | + <Skeleton width={110} height={15} /> |
| 11 | + </View> |
| 12 | + {right ? <Skeleton width={90} height={22} radius={10} /> : null} |
| 13 | + </View> |
| 14 | + ) |
| 15 | +} |
| 16 | + |
| 17 | +// Initial-load skeleton for the Home/Dashboard — content-shaped placeholders laid out |
| 18 | +// like the real screen (greeting + Start · KPI strip · volume trend · consistency · |
| 19 | +// last workout · nutrition · muscle balance · weight) so each section fills into its |
| 20 | +// own shape instead of popping after a blank spinner. Mirrors WorkoutsSkeleton etc. |
| 21 | +export function DashboardSkeleton() { |
| 22 | + return ( |
| 23 | + <Screen> |
| 24 | + <ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={{ paddingBottom: 32 }}> |
| 25 | + <View className="gap-4 py-4"> |
| 26 | + {/* Header: date + greeting, Start button */} |
| 27 | + <View className="flex-row items-start justify-between gap-3"> |
| 28 | + <View className="flex-1 gap-2"> |
| 29 | + <Skeleton width={150} height={11} /> |
| 30 | + <Skeleton width={210} height={26} radius={8} /> |
| 31 | + </View> |
| 32 | + <Skeleton width={92} height={36} radius={8} /> |
| 33 | + </View> |
| 34 | + |
| 35 | + {/* KPI strip */} |
| 36 | + <SkeletonStatRow count={3} /> |
| 37 | + |
| 38 | + {/* Volume Trend */} |
| 39 | + <Card> |
| 40 | + <CardHeaderSkel right /> |
| 41 | + <Skeleton height={130} radius={12} /> |
| 42 | + </Card> |
| 43 | + |
| 44 | + {/* Consistency heatmap */} |
| 45 | + <Card> |
| 46 | + <CardHeaderSkel right /> |
| 47 | + <Skeleton height={92} radius={12} /> |
| 48 | + </Card> |
| 49 | + |
| 50 | + {/* Last workout: title + exercise rows */} |
| 51 | + <Card className="gap-3"> |
| 52 | + <Skeleton width={180} height={15} /> |
| 53 | + {Array.from({ length: 3 }).map((_, i) => ( |
| 54 | + <View key={i} className="flex-row items-center gap-2.5"> |
| 55 | + <Skeleton width={44} height={44} radius={12} /> |
| 56 | + <View className="flex-1 gap-2"> |
| 57 | + <Skeleton width="60%" height={13} /> |
| 58 | + <Skeleton width={70} height={16} radius={5} /> |
| 59 | + </View> |
| 60 | + <Skeleton width={56} height={12} /> |
| 61 | + </View> |
| 62 | + ))} |
| 63 | + </Card> |
| 64 | + |
| 65 | + {/* Today's Nutrition: big number + macro bars */} |
| 66 | + <Card className="gap-3"> |
| 67 | + <Skeleton width={140} height={15} /> |
| 68 | + <Skeleton width={120} height={30} radius={8} /> |
| 69 | + {Array.from({ length: 3 }).map((_, i) => ( |
| 70 | + <Skeleton key={i} height={14} radius={7} /> |
| 71 | + ))} |
| 72 | + </Card> |
| 73 | + |
| 74 | + {/* Muscle Balance: donut + legend rows */} |
| 75 | + <Card> |
| 76 | + <CardHeaderSkel right /> |
| 77 | + <View className="items-center gap-4"> |
| 78 | + <Skeleton width={168} height={168} radius={999} /> |
| 79 | + <View className="w-full gap-3"> |
| 80 | + {Array.from({ length: 4 }).map((_, i) => ( |
| 81 | + <Skeleton key={i} height={14} radius={7} /> |
| 82 | + ))} |
| 83 | + </View> |
| 84 | + </View> |
| 85 | + </Card> |
| 86 | + |
| 87 | + {/* Weight card: number + sparkline */} |
| 88 | + <Card className="gap-3"> |
| 89 | + <CardHeaderSkel right /> |
| 90 | + <View className="flex-row items-center justify-between"> |
| 91 | + <Skeleton width={90} height={26} radius={8} /> |
| 92 | + <Skeleton width={32} height={32} radius={10} /> |
| 93 | + </View> |
| 94 | + <Skeleton height={48} radius={10} /> |
| 95 | + </Card> |
| 96 | + </View> |
| 97 | + </ScrollView> |
| 98 | + </Screen> |
| 99 | + ) |
| 100 | +} |
0 commit comments