diff --git a/api/ApiContext.tsx b/api/ApiContext.tsx index 09b3bc9..5704499 100644 --- a/api/ApiContext.tsx +++ b/api/ApiContext.tsx @@ -6,7 +6,7 @@ import { getUserInfo } from './User'; import { acceptFriendRequest } from './Friends'; import { ExpectedExercise, getExercisePlan, Plan } from './Workouts' import { WorkoutTypeType } from './Workouts'; -import { getExercise, exerciseType } from './Exercise' +import { getExercise, ExerciseType } from './Exercise' export interface ApiContextType { @@ -17,7 +17,7 @@ export interface ApiContextType { updateUserData: () => Promise; userData: UserType | null; exercisePlan: Plan | null; - exercises:Array + exercises:Array } @@ -28,7 +28,7 @@ export const ApiProvider = ({ children }: { children: ReactNode }) => { const [loggedIn, setLoggedIn] = useState(false); const [userData, setUserData] = useState(null); const [exercisePlan, setExercisePlan] = useState(null); - const [exercises, setExercises] = useState>([]); + const [exercises, setExercises] = useState>([]); diff --git a/api/Exercise.tsx b/api/Exercise.tsx index 495aa41..eef7a64 100644 --- a/api/Exercise.tsx +++ b/api/Exercise.tsx @@ -4,6 +4,8 @@ import { router } from 'expo-router'; import { ApiContextType } from './ApiContext'; import { workout_category } from './Workouts'; import { ExpectedExercise } from './Workouts'; + + export function string_to_date(input: string): Date | undefined { // Parse the input string into a Date object const date = new Date(input); @@ -18,7 +20,7 @@ export function string_to_date(input: string): Date | undefined { return date; } -export interface exerciseType{ +export interface ExerciseType{ start: Date | undefined, workout_type: WorkoutTypeType end: Date | undefined, @@ -58,7 +60,7 @@ export interface WorkoutTypeType { category: workout_category; } -export const getNextExercises = (plan_data: Plan | null, ex_data: exerciseType[]): ExpectedExercise[] => { +export const getNextExercises = (plan_data: Plan | null, ex_data: ExerciseType[]): ExpectedExercise[] => { console.log("plan data doesn't exist?"); if (!plan_data) { return []; @@ -232,10 +234,10 @@ export const getExercise = async(token:string) =>{ return []; } const data = await response.json(); - let return_list:exerciseType[] = [] + let return_list:ExerciseType[] = [] for (let i=0;i{ return null; } const data = await response.json(); - let return_list:exerciseType[] = [] + let return_list:ExerciseType[] = [] for (let i=0;i{ } const data = await response.json(); - let ret:feedType[] = [] + let ret:FeedType[] = [] for (let i=0;i { }); return( onPress_func(expect_ex)} style={style.button}> - {expect_ex.name+ "for "+returnNumberAsTime(expect_ex.time)} + {expect_ex.name+ " for "+returnNumberAsTime(expect_ex.time)} ) } @@ -115,9 +115,9 @@ export default () => { function returnButtonSelector(user:UserType|null, plan:Plan|null){ - if(user?.isWorking){ + if(user?.isWorking) { return ( - + { setisPlaying(false); return { } // repeat animation in 1.5 seconds }} - > {({ remainingTime }) => ( { - await endExercise(authToken); - await updateUserData(); - }} - > - + style={styles1.countdownTimer} + onPress={async () => { + await endExercise(authToken); + await updateUserData(); + }} + > - - - + )} - + ); } - if(workoutOptions.length > 0){ - return( - { - if(workoutOptions.length > 0){ - setWrkSlctVisible(true); - } - }}> - - - - ) + + if(workoutOptions.length > 0) { + return ( + {if(workoutOptions.length > 0) setWrkSlctVisible(true)}} + > + + + ) } - return( + + return ( @@ -175,20 +171,20 @@ export default () => { return ( <> setWrkSlctVisible(false)} - > - - - {workoutOptions.map((val,idx)=>{return renderExcerciseSelector(val)})} - setWrkSlctVisible(false)} style={styles.closeButton}> - {/* Close icon */} - - - - + animationType="fade" + transparent={true} + visible={wrkSlct} + onRequestClose={() => setWrkSlctVisible(false)} + > + + + {workoutOptions.map((val,idx)=>{return renderExcerciseSelector(val)})} + setWrkSlctVisible(false)} style={styles.closeButton}> + {/* Close icon */} + + + + ({ tabBarIcon: ({ focused, color, size }) => { let iconName; @@ -208,27 +204,23 @@ export default () => { }, tabBarActiveTintColor: theme.colors.primary, tabBarInactiveTintColor: 'gray', - }) - } - > + })}> - - { /*Order of tabs*/ } - - - - (returnButtonSelector(userData,exercisePlan) - ), - }} - /> - - - - - + { /*Order of tabs*/ } + + + + (returnButtonSelector(userData,exercisePlan)) + }} + /> + + + + + ); } diff --git a/app/(tabs)/feed.tsx b/app/(tabs)/feed.tsx index bd7e538..ea9c999 100644 --- a/app/(tabs)/feed.tsx +++ b/app/(tabs)/feed.tsx @@ -3,12 +3,12 @@ import React, { useState, useEffect } from 'react'; import { Text, StyleSheet, View, FlatList } from 'react-native'; import { useApiContext } from '../../api/ApiContext'; import { defaultPageTheme } from '../utility/style'; -import { feedType, getFriendFeed } from '../../api/Feed'; +import { FeedType, getFriendFeed } from '../../api/Feed'; import { workout_category } from '../../api/Workouts'; export default function FriendsPage() { const { authToken } = useApiContext(); - const [friendFeed, setFriendFeed] = useState([]); + const [friendFeed, setFriendFeed] = useState([]); useEffect(() => { const fetchFeed = async () => { @@ -44,7 +44,7 @@ export default function FriendsPage() { } }; - const renderFeedItem = ({item}:{item:feedType}) => { + const renderFeedItem = ({item}:{item:FeedType}) => { console.log("END TIME", item.end.toISOString()); console.log(item.expectedTime); const actualDuration = (item.end && item.start) ? Math.floor((item.end.getTime() - item.start.getTime()) / 1000) : 0; diff --git a/app/(tabs)/friends.tsx b/app/(tabs)/friends.tsx index 70ea746..32f976f 100644 --- a/app/(tabs)/friends.tsx +++ b/app/(tabs)/friends.tsx @@ -70,8 +70,8 @@ export default function FriendsPage() { placeholder='Friend Name' value={friendName} onChangeText={setFriendName} - secure={false} - style = {styles.input} + //secureTextEntry={false} + //style = {styles.input} /> - +