| 1 | import { StyleSheet, View } from 'react-native';
|
| 2 | import { Text } from '@/components/ui/Text';
|
| 3 | import { router } from 'expo-router';
|
| 4 |
|
| 5 | import { Card } from '@/components/ui/Cards';
|
| 6 | import { Badge } from '@/components/ui/Badge';
|
| 7 | import { getMood } from '@/constants/moods';
|
| 8 | import { Colors, Spacing } from '@/constants/theme';
|
| 9 | import { MoodEntry } from '@/lib/api';
|
| 10 | import { getTimeBadge, formatMoment } from '@/lib/utils/time';
|
| 11 |
|
| 12 | interface MoodEntryLogProps {
|
| 13 | entry: MoodEntry;
|
| 14 | }
|
| 15 |
|
| 16 | const MoodEntryLog = ({ entry }: MoodEntryLogProps) => {
|
| 17 | const moment = new Date(entry.moment);
|
| 18 | const moodDef = getMood(entry.selectedMood.toLowerCase());
|
| 19 | const badge = getTimeBadge(moment);
|
| 20 |
|
| 21 | const handlePress = () => router.push(`/entry/${entry.id}`);
|
| 22 |
|
| 23 | return (
|
| 24 | <Card style={styles.card} onPress={handlePress}>
|
| 25 | <View style={styles.moodIcon}>
|
| 26 | <Text style={styles.moodIconEmoji}>{moodDef?.icon ?? '😐'}</Text>
|
| 27 | </View>
|
| 28 |
|
| 29 | <View style={styles.moodBlock}>
|
| 30 | <Text style={styles.title} numberOfLines={1}>
|
| 31 | {moodDef?.label ?? entry.selectedMood}
|
| 32 | </Text>
|
| 33 |
|
| 34 | <Text style={styles.subtitle} numberOfLines={1}>
|
| 35 | {formatMoment(moment)}
|
| 36 | </Text>
|
| 37 | </View>
|
| 38 |
|
| 39 | <Badge
|
| 40 | label={badge.label}
|
| 41 | variant={badge.variant}
|
| 42 | />
|
| 43 | </Card>
|
| 44 | );
|
| 45 | }
|
| 46 |
|
| 47 | const styles = StyleSheet.create({
|
| 48 | card: {
|
| 49 | flexDirection: "row",
|
| 50 | alignItems: "center",
|
| 51 | gap: 14,
|
| 52 | overflow: "hidden",
|
| 53 | padding: Spacing.cardGap
|
| 54 | },
|
| 55 | moodIcon: {
|
| 56 | width: 48,
|
| 57 | height: 48,
|
| 58 | alignItems: "center",
|
| 59 | justifyContent: "center",
|
| 60 | flexShrink: 0,
|
| 61 | },
|
| 62 | moodIconEmoji: {
|
| 63 | fontSize: 26,
|
| 64 | },
|
| 65 | // Text
|
| 66 | moodBlock: {
|
| 67 | flex: 1,
|
| 68 | minWidth: 0,
|
| 69 | },
|
| 70 | title: {
|
| 71 | fontSize: 15,
|
| 72 | fontWeight: "700",
|
| 73 | color: Colors.light.text,
|
| 74 | letterSpacing: -0.2,
|
| 75 | marginBottom: 3,
|
| 76 | },
|
| 77 | subtitle: {
|
| 78 | fontSize: 12.5,
|
| 79 | fontWeight: "500",
|
| 80 | color: Colors.light.textSecondary,
|
| 81 | letterSpacing: 0.1,
|
| 82 | },
|
| 83 | });
|
| 84 |
|
| 85 | export default MoodEntryLog
|