import { ActivityIndicator, StyleSheet, View } from "react-native"; import { Text } from "@/components/ui/Text"; import { Card } from "@/components/ui/Cards"; import { useInsight } from "@/hooks/useInsights.queries"; import { Ionicons } from "@expo/vector-icons"; import { Typography, Spacing, Colors, BorderRadius } from "@/constants/theme"; export const DailyEnergyWidget = () => { const { data: insight, isLoading } = useInsight("DAILY_ENERGY"); const metadata = insight?.metadata; const avgEnergy = metadata?.avgEnergy ?? 0; const peak = metadata?.peak ?? 0; const energyWidth = peak > 0 ? (avgEnergy / peak) * 100 : 0; const energySummary = () => { if (avgEnergy < 3) return "Energia baixa"; if (avgEnergy < 5) return "Media baixa"; if (avgEnergy < 7.5) return "Média Alta"; return "Energia alta"; }; return ( Energia {isLoading ? ( ) : insight ? ( <> {energySummary()} ) : ( <> Não há dados disponíveis para o dia de hoje )} ); }; const styles = StyleSheet.create({ container: { flex: 1, padding: Spacing.cardGap, }, empty: { ...Typography.labelSm, opacity: 0.5, }, lineTrack: { height: 6, backgroundColor: Colors.light.divider, borderRadius: BorderRadius.full, marginBottom: 4, overflow: "hidden", }, lineFill: { height: "100%", backgroundColor: Colors.light.tint, borderRadius: BorderRadius.full, }, indicatorGreen: { color: Colors.light.tint, fontSize: 11, fontWeight: 600, lineHeight: 16.5, }, });