frontend: rig mood component cards & reset new mood entry page when going back
Parents:
6b55ce53 file(s) changed
- frontend/app/(tabs)/new/entry.tsx +22 -11
- frontend/components/ui/MoodComponentCard.tsx +75 -0
- frontend/constants/theme.ts +1 -0
frontend/app/(tabs)/new/entry.tsx
@@ -22,6 +22,7 @@ import { Input, TextArea } from '@/components/ui/Input';
22 22 import { Section, SectionHeader } from '@/components/ui/Sections';
23 23 import { Spacing, Typography, Colors } from '@/constants/theme';
24 24 import { ScaleSlider } from '@/components/ui/ScaleSlider';
25 + import { MoodComponentCard } from '@/components/ui/MoodComponentCard';
25 26 import { Ionicons } from '@expo/vector-icons';
26 27 import { useThemeColor } from '@/hooks/use-theme-color';
27 28 import {
@@ -46,15 +47,18 @@ const {
46 47 selectedMood,
47 48 setSelectedMood,
48 49 components,
50 + reset
49 51 } = useMoodEntryStore();
50 52
51 53 useEffect(() => {
52 54 setSelectedMood(getMood(initialMood));
53 55 }, [initialMood]);
54 56
57 + useEffect(() => {
58 + return () => reset();
59 + }, []);
60 +
55 61 const editComponents = () => {
56 - console.log("Wants to open the components");
57 -
58 62 router.push("/entry/mood-components")
59 63 }
60 64
@@ -69,7 +73,7 @@ Como você está se sentindo agora?
69 73 </ThemedText>
70 74
71 75 <ThemedText style={styles.statusText}>
72 - {selectedMood.label || "Neutro"}
76 + {selectedMood?.label || "Neutro"}
73 77 </ThemedText>
74 78 </Center>
75 79
@@ -121,16 +125,23 @@ </Card>
121 125
122 126 <Section>
123 127 <SectionHeader title="Componentes do Humor" info="Editar" />
124 - <Grid gap={4}>
125 - <Card style={{height: 38}} />
126 - <Card style={{height: 38}} />
127 - </Grid>
128 + {components.length > 0 ? (
129 + <Grid gap={2} style={{ marginTop: 8 }}>
130 + {components.map((comp) => (
131 + <MoodComponentCard
132 + key={comp.id}
133 + id={comp.id}
134 + intensity={comp.intensity}
135 + />
136 + ))}
137 + </Grid>
138 + ) : null}
128 139
129 140 <Button title="Adicionar Componentes"
130 - onPress={editComponents}
131 - textStyle={{ fontWeight: 500 }}
132 - variant="dashed"
133 - />
141 + onPress={editComponents}
142 + textStyle={{ fontWeight: 500 }}
143 + variant="dashed"
144 + />
134 145 </Section>
135 146 </View>
136 147 </ScrollView>
frontend/components/ui/MoodComponentCard.tsx
@@ -0,0 +1,75 @@
1 + import React from 'react';
2 + import { View, Text, StyleSheet, ViewStyle } from 'react-native';
3 + import { Row } from '@/components/ui/LayoutHelpers';
4 + import { Card } from '@/components/ui/Cards';
5 + import { getMoodComponent, intensityLabel } from '@/constants/mood-components';
6 + import { Theme } from '@/constants/theme';
7 +
8 + interface MoodComponentCardProps {
9 + id: string;
10 + intensity: number;
11 + style?: ViewStyle;
12 + }
13 +
14 + export const MoodComponentCard: React.FC<MoodComponentCardProps> = ({
15 + id,
16 + intensity,
17 + style,
18 + }) => {
19 + const definition = getMoodComponent(id);
20 + if (!definition) return null;
21 +
22 + return (
23 + <Card style={[styles.card, style]}>
24 + <Row gap={6} style={styles.inner}>
25 + <View style={styles.mood}>
26 + <View style={[styles.dot, { backgroundColor: definition.color }]} />
27 + <Text style={styles.label} numberOfLines={1}>
28 + {definition.label}
29 + </Text>
30 + </View>
31 +
32 + <Text style={styles.intensity} numberOfLines={1}>
33 + {intensityLabel(intensity)}
34 + </Text>
35 + </Row>
36 + </Card>
37 + );
38 + };
39 +
40 + const styles = StyleSheet.create({
41 + card: {
42 + paddingHorizontal: 10,
43 + paddingVertical: 8,
44 + },
45 + mood: {
46 + flex: 1,
47 + flexDirection: 'row',
48 + alignItems: 'center',
49 + height: '100%',
50 + },
51 + inner: {
52 + alignItems: 'baseline',
53 + flexShrink: 1,
54 + },
55 + dot: {
56 + width: 8,
57 + height: 8,
58 + borderRadius: 5,
59 + flexShrink: 0,
60 + marginRight: 4,
61 + justifyContent: 'center'
62 + },
63 + label: {
64 + fontSize: Theme.typography.bodyMd.fontSize,
65 + fontWeight: '600',
66 + color: Theme.colors.light.text,
67 + flexShrink: 1,
68 + },
69 + intensity: {
70 + fontSize: Theme.typography.labelSm.fontSize,
71 + color: Theme.colors.light.moodIntensityLabel,
72 + flexShrink: 1,
73 + height: '100%',
74 + },
75 + });
frontend/constants/theme.ts
@@ -68,6 +68,7 @@
68 68 // Active / Inactive States
69 69 activeBackground: STATUS_ACTIVE_BG,
70 70 inactiveOpacity: 0.7,
71 + moodIntensityLabel: '#94a3b8',
71 72
72 73 // Semantic Accents (for categorization)
73 74 accentBlue: PILL_BLUE,