From f9dc79899a598ac1ee2f7a7645e5951df437ed62 Mon Sep 17 00:00:00 2001 From: nickci2002 Date: Wed, 1 May 2024 14:14:40 -0400 Subject: [PATCH 1/3] Fixed home.tsx and submit_data.tsx NOTE: Textbox will not run onChangeText() if it doesn't match the form. Do not implement checks in submit_data.tsx --- app/(tabs)/home.tsx | 281 +++++++++++++++++++++++---------- app/(tabs)/plan.tsx | 6 +- app/components/textbox.tsx | 2 +- app/submit_data.tsx | 112 +++++-------- app/utility/formValidation.tsx | 68 ++++---- 5 files changed, 276 insertions(+), 193 deletions(-) diff --git a/app/(tabs)/home.tsx b/app/(tabs)/home.tsx index 97a84c5..aeecdfb 100644 --- a/app/(tabs)/home.tsx +++ b/app/(tabs)/home.tsx @@ -1,5 +1,5 @@ import { Redirect } from 'expo-router'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Text, View, Image, ScrollView, Dimensions} from 'react-native'; import { ButtonGroup } from 'react-native-elements'; import { LineChart } from 'react-native-chart-kit'; @@ -24,7 +24,7 @@ const chartConfig = { const LineChartComponent = ({data, title}) => { return ( - + {title} { /** Determines graph type */ type GraphType = 'steps' | 'exercise' | 'weight' | undefined; /** Determines timeframe of the graph */ -type TimePeriod = 'day' | 'month'; -/** Determines the day of the week */ +type TimePeriod = 'Week' | 'Month' | 'Year'; +/** Determines the day of the week [TimePeriod 'week'] */ type Day = 'Sun' | 'Mon' | 'Tue' | 'Wed' | 'Thur' | 'Fri' | 'Sat' | undefined; -/** Determines the month of the year */ +/** Determines how many weeks have passed [TimePeriod 'month'] */ +type Week = "3 weeks" | "2 weeks" | "1 week" | "This week" | undefined; +/** Determines the month of the year [TimePeriod 'year'] */ type Month = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec' | undefined; @@ -61,7 +63,14 @@ const dayString = (d:Day) => { else if (d === 'Sat') return 'Saturday'; else return 'Error'; } - +/** Converts Week type to string */ +const weekString = (w:Week) => { + if (w === '3 weeks') return '3 weeks ago'; + else if (w === '2 weeks') return '2 weeks ago'; + else if (w === '1 week') return '1 week ago'; + else if (w === 'This week') return 'This week'; + else return 'No week'; +} /** Converts Month type to string */ const monthString = (m:Month) => { if (m === 'Jan') return 'January'; @@ -90,7 +99,6 @@ interface DayButtonProps { togglePopup: (boolean) => void; changeDay: (Day) => void; } - const DayButton: React.FC = ({togglePopup, changeDay}) => { // Chooses day to change and closes day popup const handleDayPopup = (d:Day) => { @@ -111,6 +119,33 @@ const DayButton: React.FC = ({togglePopup, changeDay}) => { } +/** + * Week Popup layout + * + * @param togglePopup - Toggles whether or not the popup is open/closed + * @param changeWeek - Changes the week to edit + */ +interface WeekButtonProps { + togglePopup: (boolean) => void; + changeWeek: (Day) => void; +} +const WeekButton: React.FC = ({togglePopup, changeWeek}) => { + // Chooses day to change and closes day popup + const handleWeekPopup = (w:Week) => { + changeWeek(w); + togglePopup(false); + } +return ( + <> + - + +