| 1 | import { useState, useEffect } from 'react';
|
| 2 | import {
|
| 3 | Link, router, useLocalSearchParams
|
| 4 | } from 'expo-router';
|
| 5 |
|
| 6 | import {
|
| 7 | View,
|
| 8 | Text,
|
| 9 | StyleSheet,
|
| 10 | ScrollView
|
| 11 | } from 'react-native';
|
| 12 |
|
| 13 | import { SafeAreaView } from 'react-native-safe-area-context';
|
| 14 | import { ThemedText } from '@/components/misc/themed-text';
|
| 15 | import { ThemedView } from '@/components/misc/themed-view';
|
| 16 | import { ScreenLayout } from '@/components/ui/ScreenLayout';
|
| 17 | import { useAuth } from '@/context/AuthContext';
|
| 18 | import { Grid, Col, Row, Between, Center } from '@/components/ui/LayoutHelpers';
|
| 19 | import { Card } from '@/components/ui/Cards';
|
| 20 | import { Button } from '@/components/ui/Button';
|
| 21 | import { Input, TextArea } from '@/components/ui/Input';
|
| 22 | import { Section, SectionHeader } from '@/components/ui/Sections';
|
| 23 | import { Spacing, Typography, Colors } from '@/constants/theme';
|
| 24 | import { ScaleSlider } from '@/components/ui/ScaleSlider';
|
| 25 | import { Ionicons } from '@expo/vector-icons';
|
| 26 | import { useThemeColor } from '@/hooks/use-theme-color';
|
| 27 | import {
|
| 28 | useMoodEntryStore,
|
| 29 | } from '@/stores/moodEntry';
|
| 30 |
|
| 31 | import {
|
| 32 | MOODS,
|
| 33 | getMood
|
| 34 | } from '@/constants/moods';
|
| 35 |
|
| 36 | export default function NewMoodEntry() {
|
| 37 | const { user } = useAuth();
|
| 38 | const tintColor = useThemeColor({}, 'tint');
|
| 39 |
|
| 40 | const { initialMood } = useLocalSearchParams();
|
| 41 | const [stress, setStress] = useState(0);
|
| 42 | const [anxiety, setAnxiety] = useState(0);
|
| 43 | const [energy, setEnergy] = useState(0);
|
| 44 |
|
| 45 | const {
|
| 46 | selectedMood,
|
| 47 | setSelectedMood,
|
| 48 | components,
|
| 49 | } = useMoodEntryStore();
|
| 50 |
|
| 51 | useEffect(() => {
|
| 52 | setSelectedMood(getMood(initialMood));
|
| 53 | }, [initialMood]);
|
| 54 |
|
| 55 | const editComponents = () => {
|
| 56 | console.log("Wants to open the components");
|
| 57 |
|
| 58 | router.push("/entry/mood-components")
|
| 59 | }
|
| 60 |
|
| 61 | return (
|
| 62 | <View>
|
| 63 | <ScrollView
|
| 64 | scrollEventThrottle={16}>
|
| 65 | <View style={styles.container}>
|
| 66 | <Center>
|
| 67 | <ThemedText style={styles.statusPrefix}>
|
| 68 | Como você está se sentindo agora?
|
| 69 | </ThemedText>
|
| 70 |
|
| 71 | <ThemedText style={styles.statusText}>
|
| 72 | {selectedMood.label || "Neutro"}
|
| 73 | </ThemedText>
|
| 74 | </Center>
|
| 75 |
|
| 76 | <Card style={styles.resumeCard}>
|
| 77 | <Col gap={24}>
|
| 78 | <ScaleSlider
|
| 79 | variant="rich"
|
| 80 | label="Energia"
|
| 81 | value={energy}
|
| 82 | onValueChange={setEnergy}
|
| 83 | icon={<Ionicons name="flower-outline" size={20} color={tintColor} />}
|
| 84 | minLabel="Baixa"
|
| 85 | maxLabel="Alta"
|
| 86 | />
|
| 87 |
|
| 88 | <ScaleSlider
|
| 89 | variant="rich"
|
| 90 | label="Ansiedade"
|
| 91 | value={anxiety}
|
| 92 | onValueChange={setAnxiety}
|
| 93 | icon={<Ionicons name="sad-outline" size={20} color="#FB923C" />}
|
| 94 | minLabel="Calmo"
|
| 95 | maxLabel="Ansioso"
|
| 96 | />
|
| 97 |
|
| 98 | <ScaleSlider
|
| 99 | variant="rich"
|
| 100 | label="Estresse"
|
| 101 | value={stress}
|
| 102 | onValueChange={setStress}
|
| 103 | icon={<Ionicons name="flame" size={20} color="#f87171" />}
|
| 104 | minLabel="Relaxado"
|
| 105 | maxLabel="Estressado"
|
| 106 | />
|
| 107 | </Col>
|
| 108 | </Card>
|
| 109 |
|
| 110 | <Card style={styles.annotationsCard}>
|
| 111 | <TextArea
|
| 112 | label="Notas sobre o dia"
|
| 113 | type="text"
|
| 114 | variant="darkGhost"
|
| 115 | onChangeText={(val) => console.log(val)}
|
| 116 | minRows={4}
|
| 117 | maxRows={6}
|
| 118 | placeholder="Escreva uma nota rápida sobre o seu dia até o momento..."
|
| 119 | />
|
| 120 | </Card>
|
| 121 |
|
| 122 | <Section>
|
| 123 | <SectionHeader title="Componentes do Humor" info="Editar" />
|
| 124 | <Grid gap={4}>
|
| 125 | <Card style={{height: 38}} />
|
| 126 | <Card style={{height: 38}} />
|
| 127 | </Grid>
|
| 128 |
|
| 129 | <Button title="Adicionar Componentes"
|
| 130 | onPress={editComponents}
|
| 131 | textStyle={{ fontWeight: 500 }}
|
| 132 | variant="dashed"
|
| 133 | />
|
| 134 | </Section>
|
| 135 | </View>
|
| 136 | </ScrollView>
|
| 137 | </View>
|
| 138 | );
|
| 139 | }
|
| 140 |
|
| 141 | const styles = StyleSheet.create({
|
| 142 | container: {
|
| 143 | gap: 24,
|
| 144 | paddingHorizontal: Spacing.containerPadding,
|
| 145 | paddingVertical: Spacing.sectionGap,
|
| 146 | },
|
| 147 | statusText: {
|
| 148 | ...Typography.headlineXg,
|
| 149 | },
|
| 150 | statusPrefix: {
|
| 151 | ...Typography.bodyMd
|
| 152 | },
|
| 153 | annotationsCard: {
|
| 154 | padding: Spacing.cardGap
|
| 155 | },
|
| 156 | resumeCard: {
|
| 157 | padding: Spacing.cardGap,
|
| 158 | }
|
| 159 | });
|