From 058855156eea0b04de7a596152f0404f8594581f Mon Sep 17 00:00:00 2001 From: Felix Ohnesorge Date: Tue, 16 Apr 2024 16:27:20 +0000 Subject: [PATCH] create-workout WIP --- frontend/app/home.tsx | 20 ++++++-- frontend/app/login.tsx | 6 +-- frontend/app/workout/create.tsx | 62 +++++++++++++++++++++++ frontend/components/AddCard.tsx | 14 +++++ frontend/components/AddExcerciseModal.tsx | 51 +++++++++++++++++++ frontend/components/Card.tsx | 9 ++++ frontend/styles/index.js | 12 +++++ 7 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 frontend/app/workout/create.tsx create mode 100644 frontend/components/AddCard.tsx create mode 100644 frontend/components/AddExcerciseModal.tsx create mode 100644 frontend/components/Card.tsx diff --git a/frontend/app/home.tsx b/frontend/app/home.tsx index bda2f5b..1126fd9 100644 --- a/frontend/app/home.tsx +++ b/frontend/app/home.tsx @@ -1,8 +1,10 @@ -import { View, TouchableOpacity, Text } from 'react-native'; +import { TouchableOpacity, Text, ScrollView, SafeAreaView } from 'react-native'; import { Stack, useRouter } from 'expo-router'; import React from 'react'; import ProfileButton from '../components/ProfileButton'; import styles from '../styles'; +import Card from '../components/Card'; +import AddCard from '../components/AddCard'; const HomeScreen = () => { const router = useRouter(); @@ -15,14 +17,26 @@ const HomeScreen = () => { ), }} /> - + {}}> Start Workout {}}> Create Workout - + + + Workout 1 + + router.push('workout/create')}> + + + + ); }; diff --git a/frontend/app/login.tsx b/frontend/app/login.tsx index 7bbe129..474d104 100644 --- a/frontend/app/login.tsx +++ b/frontend/app/login.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useRouter } from 'expo-router'; -import { View, Text, TextInput, TouchableOpacity } from 'react-native'; +import { Text, TextInput, TouchableOpacity, SafeAreaView } from 'react-native'; import customFetch from '../customFetch'; import styles from '../styles'; @@ -29,7 +29,7 @@ const LoginScreen = () => { }; return ( - + Login { Login - + ); }; diff --git a/frontend/app/workout/create.tsx b/frontend/app/workout/create.tsx new file mode 100644 index 0000000..1817677 --- /dev/null +++ b/frontend/app/workout/create.tsx @@ -0,0 +1,62 @@ +import React, { useState } from 'react'; +import { + Text, + TextInput, + TouchableOpacity, + ScrollView, + SafeAreaView, +} from 'react-native'; +import styles from '../../styles'; +import AddExerciseModal from '../../components/AddExcerciseModal'; +import Card from '../../components/Card'; +import AddCard from '../../components/AddCard'; + +const CreateWorkout = () => { + const [name, setName] = useState(''); + const [exercises, setExercises] = useState([]); + const [modalVisible, setModalVisible] = useState(false); + + const handleSubmit = () => { + // Handle the form submission here + // For example, you can call an API to create a workout + }; + + const handleAddExercise = (exercise) => { + setExercises([...exercises, exercise]); + setModalVisible(false); + }; + + return ( + + Create a New Workout + + + {exercises.map((exercise, index) => ( + + {exercise.name} + {exercise.reps} + {exercise.sets} + + ))} + setModalVisible(true)}> + + + + + Create Workout + + setModalVisible(false)} + onAddExercise={handleAddExercise} + /> + + ); +}; + +export default CreateWorkout; diff --git a/frontend/components/AddCard.tsx b/frontend/components/AddCard.tsx new file mode 100644 index 0000000..01a66ad --- /dev/null +++ b/frontend/components/AddCard.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { MaterialIcons } from '@expo/vector-icons'; + +import Card from './Card'; + +const AddCard = () => { + return ( + + + + ); +}; + +export default AddCard; diff --git a/frontend/components/AddExcerciseModal.tsx b/frontend/components/AddExcerciseModal.tsx new file mode 100644 index 0000000..ca0d7d0 --- /dev/null +++ b/frontend/components/AddExcerciseModal.tsx @@ -0,0 +1,51 @@ +import React, { useState } from 'react'; +import { Modal, Text, TextInput, TouchableOpacity } from 'react-native'; +import styles from '../styles'; +import { SafeAreaView } from 'react-native-safe-area-context'; + +const AddExerciseModal = ({ modalVisible, onClose, onAddExercise }) => { + const [name, setName] = useState(''); + const [reps, setReps] = useState(''); + const [sets, setSets] = useState(''); + + return ( + + + Add a New Exercise + + + + onAddExercise({ name, reps, sets })} + > + Add Exercise + + + Cancel + + + + ); +}; + +export default AddExerciseModal; diff --git a/frontend/components/Card.tsx b/frontend/components/Card.tsx new file mode 100644 index 0000000..49afcd1 --- /dev/null +++ b/frontend/components/Card.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { View } from 'react-native'; +import styles from '../styles'; + +const Card = ({ children }) => { + return {children}; +}; + +export default Card; diff --git a/frontend/styles/index.js b/frontend/styles/index.js index e8e224e..8afb41e 100644 --- a/frontend/styles/index.js +++ b/frontend/styles/index.js @@ -23,6 +23,18 @@ const styles = StyleSheet.create({ padding: 16, backgroundColor: COLORS.backgroundColor1, }, + cardsContainer: { + paddingVertical: 16, + }, + card: { + width: 100, + height: 100, + margin: 10, + borderRadius: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: COLORS.interactiveColor2, + }, title: { fontSize: 24, fontWeight: 'bold',