| 1 | import { useEffect, useState } from 'react';
|
| 2 | import {
|
| 3 | StyleSheet,
|
| 4 | View,
|
| 5 | Text
|
| 6 | } from 'react-native';
|
| 7 |
|
| 8 | import { ThemedText } from '@/components/misc/themed-text';
|
| 9 | import { ThemedView } from '@/components/misc/themed-view';
|
| 10 | import { ScreenLayout } from '@/components/ui/ScreenLayout';
|
| 11 | import { useAuth } from '@/context/AuthContext';
|
| 12 | import { Grid, Col, Row, Between } from '@/components/ui/LayoutHelpers';
|
| 13 | import { Card } from '@/components/ui/Cards';
|
| 14 | import { Badge } from '@/components/ui/Badge';
|
| 15 | import { Button } from '@/components/ui/Button';
|
| 16 | import { Section, SectionHeader } from '@/components/ui/Sections';
|
| 17 | import { MoodSelector } from '@/components/ui/EmojiSelectors';
|
| 18 | import { Typography, Spacing, Shadows, Colors } from '@/constants/theme';
|
| 19 | import { useThemeColor } from '@/hooks/use-theme-color';
|
| 20 | import { router } from 'expo-router';
|
| 21 | import {
|
| 22 | MoodDefinition, MOODS
|
| 23 | } from '@/constants/moods'
|
| 24 |
|
| 25 | const MoodEntryLog = ({ mood: MoodDefinition, moment: Date }) => {
|
| 26 | const styles = StyleSheet.create({
|
| 27 | card: {
|
| 28 | flexDirection: "row",
|
| 29 | alignItems: "center",
|
| 30 | gap: 14,
|
| 31 | overflow: "hidden",
|
| 32 | padding: Spacing.cardGap
|
| 33 | },
|
| 34 | moodIcon: {
|
| 35 | width: 48,
|
| 36 | height: 48,
|
| 37 | alignItems: "center",
|
| 38 | justifyContent: "center",
|
| 39 | flexShrink: 0,
|
| 40 | },
|
| 41 | moodIconEmoji: {
|
| 42 | fontSize: 26,
|
| 43 | },
|
| 44 | // Text
|
| 45 | moodBlock: {
|
| 46 | flex: 1,
|
| 47 | minWidth: 0,
|
| 48 | },
|
| 49 | title: {
|
| 50 | fontSize: 15,
|
| 51 | fontWeight: "700",
|
| 52 | color: Colors.light.text,
|
| 53 | letterSpacing: -0.2,
|
| 54 | marginBottom: 3,
|
| 55 | },
|
| 56 | subtitle: {
|
| 57 | fontSize: 12.5,
|
| 58 | fontWeight: "500",
|
| 59 | color: Colors.light.textSecondary,
|
| 60 | letterSpacing: 0.1,
|
| 61 | },
|
| 62 | });
|
| 63 |
|
| 64 | return (
|
| 65 | <Card style={styles.card}>
|
| 66 | <View style={styles.moodIcon}>
|
| 67 | <Text style={styles.moodIconEmoji}>😀</Text>
|
| 68 | </View>
|
| 69 |
|
| 70 | <View style={styles.moodBlock}>
|
| 71 | <Text style={styles.title} numberOfLines={1}>
|
| 72 | Neutro
|
| 73 | </Text>
|
| 74 | <ThemedText style={styles.subtitle} numberOfLines={1}>
|
| 75 | Ontem às 10h
|
| 76 | </ThemedText>
|
| 77 | </View>
|
| 78 |
|
| 79 | <Badge label="Manhã" />
|
| 80 | </Card>
|
| 81 | );
|
| 82 | }
|
| 83 |
|
| 84 | export default function New() {
|
| 85 | const { user } = useAuth();
|
| 86 | const [mood, setMood] = useState<string>('good');
|
| 87 | const [isLoading, setIsLoading] = useState<boolean>(false);
|
| 88 |
|
| 89 | const initQuickRegister = () => {
|
| 90 | // TODO: Set down on camelCase vs kebab case
|
| 91 | router.navigate(`/new/entry?initialMood=${mood}`)
|
| 92 | };
|
| 93 |
|
| 94 | return (
|
| 95 | <ScreenLayout userName={user.firstName} userAvatar={user.avatarURL}
|
| 96 | onNotificationPress={() => console.log('Notifications')}
|
| 97 | showNotificationBadge={true}>
|
| 98 | <Section>
|
| 99 | <SectionHeader
|
| 100 | title="Como você está hoje?"
|
| 101 | subtitle="Sua jornada começa agora"
|
| 102 | >
|
| 103 | </SectionHeader>
|
| 104 |
|
| 105 | <Card style={{ minHeight: 200 }}>
|
| 106 | <Col gap={16}>
|
| 107 | <Between style={styles.quickRegisterHeader}>
|
| 108 | <ThemedText style={styles.quickRegisterTitle}>
|
| 109 | Registro rápido
|
| 110 | </ThemedText>
|
| 111 |
|
| 112 | <ThemedText style={styles.quickRegisterBadge}>
|
| 113 | HOJE
|
| 114 | </ThemedText>
|
| 115 | </Between>
|
| 116 |
|
| 117 | <MoodSelector
|
| 118 | style={{paddingLeft: 8, paddingRight: 8, paddingTop: 16 }}
|
| 119 | items={MOODS}
|
| 120 | value={mood}
|
| 121 | onSelect={setMood}
|
| 122 | />
|
| 123 |
|
| 124 | <Button
|
| 125 | title="Salvar Humor"
|
| 126 | onPress={initQuickRegister}
|
| 127 | loading={isLoading}
|
| 128 | style={styles.quickRegisterButton}
|
| 129 | />
|
| 130 | </Col>
|
| 131 | </Card>
|
| 132 | </Section>
|
| 133 |
|
| 134 | {/* TODO: Check whether we gonna have to generate these on demand */}
|
| 135 | <Section>
|
| 136 | <Grid gap={4}>
|
| 137 | <Card style={{minHeight: 150, backgroundColor: 'powderblue'}}>
|
| 138 | </Card>
|
| 139 |
|
| 140 | <Card style={{minHeight: 150, backgroundColor: 'tomato'}}>
|
| 141 | </Card>
|
| 142 | </Grid>
|
| 143 | </Section>
|
| 144 |
|
| 145 | <Section>
|
| 146 | <SectionHeader title="Registros recentes" />
|
| 147 |
|
| 148 | <MoodEntryLog
|
| 149 | mood="sad"
|
| 150 | moment={new Date()}
|
| 151 | />
|
| 152 |
|
| 153 | <MoodEntryLog
|
| 154 | mood="good"
|
| 155 | moment={new Date()}
|
| 156 | />
|
| 157 | </Section>
|
| 158 | </ScreenLayout>
|
| 159 | )
|
| 160 | }
|
| 161 |
|
| 162 | const styles = StyleSheet.create({
|
| 163 | quickRegisterHeader: {
|
| 164 | marginTop: 16,
|
| 165 | paddingLeft: 16,
|
| 166 | paddingRight: 16
|
| 167 | },
|
| 168 | quickRegisterTitle: {
|
| 169 | ...Typography.bodyLg
|
| 170 | },
|
| 171 | // TODO: Replace when we have badges
|
| 172 | quickRegisterBadge: {
|
| 173 | fontSize: 12,
|
| 174 | lineHeight: 16
|
| 175 | },
|
| 176 | quickRegisterButton: {
|
| 177 | marginLeft: 16,
|
| 178 | marginRight: 16,
|
| 179 | marginBottom: 16,
|
| 180 | ...Shadows.lg
|
| 181 | }
|
| 182 | });
|