From 515c4d472e41f99f406cd625b6db1188b780ce82 Mon Sep 17 00:00:00 2001 From: oliviaseds Date: Sun, 17 Mar 2024 11:26:30 -0400 Subject: [PATCH 01/12] feat: pass task type param to task creation screen --- client/navigation/AppNavigation.tsx | 14 +++++++++++--- client/screens/TaskCreation.tsx | 26 +++++++++++++++++++++++++ client/screens/TaskType.tsx | 6 +++++- client/types/task-creation.json | 20 +++++++++++++++++++ client/types/type.ts | 30 ++--------------------------- 5 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 client/screens/TaskCreation.tsx create mode 100644 client/types/task-creation.json diff --git a/client/navigation/AppNavigation.tsx b/client/navigation/AppNavigation.tsx index c407636..c3d05f3 100644 --- a/client/navigation/AppNavigation.tsx +++ b/client/navigation/AppNavigation.tsx @@ -4,15 +4,17 @@ import { NavigationProp } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import LoginPage from '../screens/LoginPage'; +import { TaskCreation } from '../screens/TaskCreation'; import { TaskType } from '../screens/TaskType'; import { AppStackBottomTabNavigator } from './AppStackBottomTabNavigator'; export type AppStackParamList = { + TaskType: undefined; Main: undefined; Home: undefined; Login: undefined; Profile: undefined; - TaskType: undefined; + TaskCreation: { type: string }; }; export type AppStackNavigation = NavigationProp; @@ -22,6 +24,11 @@ const AppStack = createNativeStackNavigator(); export function AppNavigation() { return ( + + ); diff --git a/client/screens/TaskCreation.tsx b/client/screens/TaskCreation.tsx new file mode 100644 index 0000000..9330f74 --- /dev/null +++ b/client/screens/TaskCreation.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { Text, View } from 'react-native'; + +import { RouteProp, useRoute } from '@react-navigation/native'; + +import { BackButton } from '../components/TaskType/BackButton'; + +type ParamList = { + mt: { + type: string; + }; +}; + +export function TaskCreation() { + const route = useRoute>(); + const { type } = route.params; + + return ( + + + + + {type} + + ); +} diff --git a/client/screens/TaskType.tsx b/client/screens/TaskType.tsx index 35bc59d..2ac1f86 100644 --- a/client/screens/TaskType.tsx +++ b/client/screens/TaskType.tsx @@ -99,7 +99,11 @@ export function TaskType() { renderItem={({ item }) => ( navigation.navigate('New ' + item + ' Task')} + onPress={() => + navigation.navigate('TaskCreation', { + type: JSON.stringify(item) + }) + } > - ( - - navigation.navigate('TaskCreation', { - taskType: JSON.stringify(item) - }) - } - > - - - )} - /> + + + )} + /> +