eletrotupi / tcc/ frontend/app/(tabs)/new/index.tsx6b4f982cf194aa9934750aa0309b23eb2e6dccf4
3.4 KB | 114 lines Raw
1
import { useEffect, useState } from 'react';
2
import {
3
  StyleSheet
4
} from 'react-native';
5

6
import { ThemedText } from '@/components/misc/themed-text';
7
import { ThemedView } from '@/components/misc/themed-view';
8
import { ScreenLayout } from '@/components/ui/ScreenLayout';
9
import { useAuth } from '@/context/AuthContext';
10
import { Grid, Col, Row, Between } from '@/components/ui/LayoutHelpers';
11
import { Card } from '@/components/ui/Cards';
12
import { Button } from '@/components/ui/Button';
13
import { Section, SectionHeader } from '@/components/ui/Sections';
14
import { MoodSelector } from '@/components/ui/EmojiSelectors';
15
import { Typography, Spacing, Shadows } from '@/constants/theme';
16
import { useThemeColor } from '@/hooks/use-theme-color';
17
import { router } from 'expo-router';
18

19
export default function New() {
20
  const { user } = useAuth();
21
  const [mood, setMood] = useState<string>('good');
22
  const [isLoading, setIsLoading] = useState<boolean>(false);
23

24
  // TODO: Move these elsewhere
25
  const moodOptions = [
26
    { id: 'sad', icon: '😢', label: 'Triste' },
27
    { id: 'neutral', icon: '😐', label: 'Neutro' },
28
    { id: 'good', icon: '😊', label: 'Bem' },
29
    { id: 'great', icon: '🤩', label: 'Ótimo' },
30
    { id: 'angry', icon: '😠', label: 'Irritado' },
31
  ];
32

33
  const initQuickRegister = () => {
34
    // TODO: Set down on camelCase vs kebab case
35
    router.navigate(`/new/entry?initialMood=${mood}`)
36
  };
37

38
  return (
39
    <ScreenLayout userName={user.firstName} userAvatar={user.avatarURL}
40
      onNotificationPress={() => console.log('Notifications')}
41
      showNotificationBadge={true}>
42
      <ThemedView>
43
        <Section>
44
          <SectionHeader
45
            title="Como você está hoje?"
46
            subtitle="Sua jornada começa agora"
47
            >
48
          </SectionHeader>
49

50
          <Card style={{ minHeight: 200 }}>
51
            <Col gap={16}>
52
              <Between style={styles.quickRegisterHeader}>
53
                <ThemedText style={styles.quickRegisterTitle}>
54
                  Registro rápido
55
                </ThemedText>
56

57
                <ThemedText style={styles.quickRegisterBadge}>
58
                  HOJE
59
                </ThemedText>
60
              </Between>
61

62
              <MoodSelector
63
                style={{paddingLeft: 8, paddingRight: 8, paddingTop: 16 }}
64
                items={moodOptions}
65
                value={mood}
66
                onSelect={setMood}
67
              />
68

69
              <Button
70
                title="Salvar Humor"
71
                onPress={initQuickRegister}
72
                loading={isLoading}
73
                style={styles.quickRegisterButton}
74
              />
75
            </Col>
76
          </Card>
77
        </Section>
78

79
        {/* TODO: Check whether we gonna have to generate these on demand */}
80
        <Section>
81
          <Grid gap={4}>
82
            <Card style={{minHeight: 150, backgroundColor: 'powderblue'}}>
83
            </Card>
84

85
            <Card style={{minHeight: 150, backgroundColor: 'tomato'}}>
86
            </Card>
87
          </Grid>
88
        </Section>
89
      </ThemedView>
90
    </ScreenLayout>
91
  )
92
}
93

94
const styles = StyleSheet.create({
95
  quickRegisterHeader: {
96
    marginTop: 16,
97
    paddingLeft: 16,
98
    paddingRight: 16
99
  },
100
  quickRegisterTitle: {
101
    ...Typography.bodyLg
102
  },
103
  // TODO: Replace when we have badges
104
  quickRegisterBadge: {
105
    fontSize: 12,
106
    lineHeight: 16
107
  },
108
  quickRegisterButton: {
109
    marginLeft: 16,
110
    marginRight: 16,
111
    marginBottom: 16,
112
    ...Shadows.lg
113
  }
114
});