import React from "react"; import { View, StyleSheet, ActivityIndicator } from "react-native"; import { Text } from "@/components/ui/Text"; import { Ionicons } from "@expo/vector-icons"; import { Card } from "@/components/ui/Cards"; import { useInsight } from "@/hooks/useInsights.queries"; import { useThemeColor } from "@/hooks/use-theme-color"; import { Typography } from "@/constants/theme"; export const MoodTrendWidget: React.FC = () => { const { data: insight, isLoading } = useInsight("MOOD_TREND"); const successColor = useThemeColor({}, "success"); const errorColor = useThemeColor({}, "danger"); const textSecondary = useThemeColor({}, "textSecondary"); if (isLoading) { return ( ); } if (!insight) { return ( Humor Registre mais humores para ver tendências. ); } const meta = insight.metadata as { delta: number; dominantMood: string; avgEnergy: number; }; const isPositive = meta.delta > 0; const isNeutral = meta.delta === 0; const deltaColor = isNeutral ? textSecondary : isPositive ? successColor : errorColor; const iconName = isNeutral ? "remove-outline" : isPositive ? "trending-up-outline" : "trending-down-outline"; return ( Humor {MOOD_LABEL[meta.dominantMood] ?? meta.dominantMood} {!isNeutral && ( {isPositive ? "+" : ""} {meta.delta}% vs período anterior )} ); }; const MOOD_LABEL: Record = { GREAT: "Ótimo", GOOD: "Bom", NEUTRAL: "Neutro", SAD: "Triste", ANGRY: "Irritado", }; const styles = StyleSheet.create({ container: { flex: 1, }, header: { flexDirection: "row", alignItems: "center", gap: 4, marginBottom: 10, }, label: { ...Typography.labelXs, opacity: 0.6, }, valueRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", }, value: { ...Typography.bodyLg, }, delta: { ...Typography.labelSm, marginTop: 2, }, empty: { ...Typography.labelXs, opacity: 0.5, marginTop: 4, }, });