frontend: make new entries behave as stacks

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 87c2c7279a81f897d50a9cef8c07aaf8fca0cc0c
Parents: 76e9483
4 file(s) changed
  • frontend/app/(tabs)/_layout.tsx +1 -1
  • frontend/app/(tabs)/new/_layout.tsx +20 -0
  • frontend/app/(tabs)/new/entry.tsx +40 -0
  • frontend/app/(tabs)/new/index.tsx +6 -1
frontend/app/(tabs)/_layout.tsx
@@ -56,7 +56,7 @@ }}
56 56 />
57 57
58 58 <Tabs.Screen
59 - name="new/index"
59 + name="new"
60 60 options={{
61 61 title: 'Novo',
62 62 tabBarIcon: ({ color }) => <IconSymbol size={28} name="add-circle" color={color} />,
frontend/app/(tabs)/new/_layout.tsx
@@ -0,0 +1,20 @@
1 + import { Stack } from 'expo-router';
2 +
3 + export const unstable_settings = {
4 + initialRouteName: 'index'
5 + };
6 +
7 + export default function MoodLayout() {
8 + return (
9 + <Stack
10 + screenOptions={{
11 + headerShown: false
12 + }}>
13 + <Stack.Screen name="index" />
14 + <Stack.Screen name="entry" options={{
15 + headerTitle: "Registrar humor",
16 + headerShown: true
17 + }} />
18 + </Stack>
19 + );
20 + }
frontend/app/(tabs)/new/entry.tsx
@@ -0,0 +1,40 @@
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 + } from 'react-native';
11 +
12 + import { SafeAreaView } from 'react-native-safe-area-context';
13 + import { ThemedText } from '@/components/misc/themed-text';
14 + import { ThemedView } from '@/components/misc/themed-view';
15 + import { ScreenLayout } from '@/components/ui/ScreenLayout';
16 + import { useAuth } from '@/context/AuthContext';
17 + import { Grid, Col, Row, Between } from '@/components/ui/LayoutHelpers';
18 + import { Card } from '@/components/ui/Cards';
19 + import { Button } from '@/components/ui/Button';
20 + import { Section, SectionHeader } from '@/components/ui/Sections';
21 +
22 + export default function NewMoodEntry() {
23 + const { user } = useAuth();
24 + // TODO: transform this into a specific mood component
25 + const { initialMood } = useLocalSearchParams();
26 +
27 + return (
28 + <SafeAreaView style={styles.container}>
29 + <ThemedText>
30 + Little black sub {initialMood}
31 + </ThemedText>
32 + </SafeAreaView>
33 + );
34 + }
35 +
36 + const styles = StyleSheet.create({
37 + container: {
38 + backgroundColor: 'pink'
39 + }
40 + });
frontend/app/(tabs)/new/index.tsx
@@ -1,5 +1,5 @@
1 1 import { useEffect, useState } from 'react';
2 - import {
2 + import {
3 3 StyleSheet
4 4 } from 'react-native';
5 5
@@ -14,12 +14,14 @@ import { Section, SectionHeader } from '@/components/ui/Sections';
14 14 import { MoodSelector } from '@/components/ui/EmojiSelectors';
15 15 import { Typography, Spacing, Shadows } from '@/constants/theme';
16 16 import { useThemeColor } from '@/hooks/use-theme-color';
17 + import { router } from 'expo-router';
17 18
18 19 export default function New() {
19 20 const { user } = useAuth();
20 21 const [mood, setMood] = useState<string>('bem');
21 22 const [isLoading, setIsLoading] = useState<boolean>(false);
22 23
24 + // TODO: Move these elsewhere
23 25 const moodOptions = [
24 26 { id: 'sad', icon: '😢', label: 'Triste' },
25 27 { id: 'neutral', icon: '😐', label: 'Neutro' },
@@ -30,6 +32,9 @@ ];
30 32
31 33 const initQuickRegister = () => {
32 34 console.log("Register: ", mood);
35 +
36 + // TODO: Set down on camelCase vs kebab case
37 + router.navigate(`/new/entry?initialMood=${mood}`)
33 38 };
34 39
35 40 return (