From 1ebd187fe5508456eb47fb56868de70edf4b2e49 Mon Sep 17 00:00:00 2001 From: erenpakelgil Date: Sat, 14 Dec 2024 14:23:16 +0300 Subject: [PATCH] Created separate JoinedProgramDetail to differentiate between details of unjoined program and joined program --- mobile/App.js | 3 + mobile/components/JoinedProgramDetail.js | 164 +++++++++++++++++++++++ mobile/components/ProgramCard.js | 2 +- mobile/components/ProgramDetail.js | 7 +- 4 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 mobile/components/JoinedProgramDetail.js diff --git a/mobile/App.js b/mobile/App.js index 0524f89..b4cdb34 100644 --- a/mobile/App.js +++ b/mobile/App.js @@ -20,6 +20,7 @@ import WorkoutDetails from './components/WorkoutDetails'; import JoinedWorkout from './components/JoinedWorkout'; import JoinedWeek from './components/JoinedWeek'; import JoinedExercise from './components/JoinedExercise'; +import JoinedProgramDetail from './components/JoinedProgramDetail'; import { Provider as ReduxProvider } from 'react-redux'; import { @@ -78,6 +79,8 @@ const App = () => { + + diff --git a/mobile/components/JoinedProgramDetail.js b/mobile/components/JoinedProgramDetail.js new file mode 100644 index 0000000..d94aef3 --- /dev/null +++ b/mobile/components/JoinedProgramDetail.js @@ -0,0 +1,164 @@ +import React,{useState} from 'react'; +import { + View, + Text, + StyleSheet, + TouchableOpacity, + FlatList, + ScrollView, +} from 'react-native'; + +const JoinedProgramDetail = ({ route }) => { + const { + trainerUsername, + title, + description, + programId, + weeks, + rating, + level, + date, + participants, + navigation + } = route.params; + const {expandedState,setExpandedState} = useState(0); + const renderWeek = ({ item, index }) => { + const workoutCount = item.workouts.length; + return ( + + Week {index + 1} + {workoutCount} Workouts + {navigation.navigate("JoinedWeek",{programId,programTitle:title,weekId:item.id,weekNumber:item.weekNumber,workouts:item.workouts, navigation:navigation})}}> + Start Workout + + 0% + + ); + }; + + return ( + + {title} + + Level: {level} + Type: BODY_BUILDING + Trainer: {trainerUsername} + Created @ {date} + + {description} + Rating: {rating}/5 (0 ratings) + + index.toString()} + /> + + + Commit to Program + + + navigation.navigate("WorkoutDetails",{weeks,navigation})}> + Show Detailed Description + + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + backgroundColor: '#fff', + }, + title: { + fontSize: 24, + fontWeight: 'bold', + marginBottom: 16, + textAlign: 'center', + }, + detailsContainer: { + marginBottom: 16, + }, + level: { + fontSize: 14, + color: 'orange', + }, + type: { + fontSize: 14, + color: 'blue', + }, + trainer: { + fontSize: 14, + color: 'red', + }, + date: { + fontSize: 12, + color: 'gray', + }, + description: { + fontSize: 16, + marginVertical: 8, + }, + rating: { + fontSize: 16, + marginBottom: 16, + textAlign: 'center', + }, + weekContainer: { + backgroundColor: '#f9f9f9', + padding: 16, + marginBottom: 8, + borderRadius: 8, + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + }, + weekTitle: { + fontSize: 16, + fontWeight: 'bold', + }, + workoutCount: { + fontSize: 14, + color: 'gray', + }, + startButton: { + backgroundColor: '#007bff', + paddingVertical: 8, + paddingHorizontal: 16, + borderRadius: 4, + }, + startButtonText: { + color: '#fff', + fontSize: 14, + }, + completionText: { + fontSize: 14, + color: 'green', + }, + commitButton: { + backgroundColor: 'green', + padding: 16, + borderRadius: 8, + alignItems: 'center', + marginTop: 16, + }, + commitButtonText: { + color: '#fff', + fontSize: 16, + fontWeight: 'bold', + }, + detailButton: { + backgroundColor: 'gray', + padding: 16, + borderRadius: 8, + alignItems: 'center', + marginTop: 8, + }, + detailButtonText: { + color: '#fff', + fontSize: 16, + }, +}); + +export default JoinedProgramDetail; diff --git a/mobile/components/ProgramCard.js b/mobile/components/ProgramCard.js index 20f3e8c..2565cc3 100644 --- a/mobile/components/ProgramCard.js +++ b/mobile/components/ProgramCard.js @@ -5,7 +5,7 @@ const ProgramCard = ({ trainerUsername, title, description, programId, weeks, ra return ( navigation.navigate('ProgramDetail', { trainerUsername, title, description, programId, weeks, rating, level, date, participants, navigation })} + onPress={() => navigation.navigate('JoinedProgramDetail', { trainerUsername, title, description, programId, weeks, rating, level, date, participants, navigation })} > navigation.navigate('UserProfile', { username: trainerUsername })}> {trainerUsername} diff --git a/mobile/components/ProgramDetail.js b/mobile/components/ProgramDetail.js index b3f2046..b74eb39 100644 --- a/mobile/components/ProgramDetail.js +++ b/mobile/components/ProgramDetail.js @@ -28,10 +28,7 @@ const ProgramDetail = ({ route }) => { Week {index + 1} {workoutCount} Workouts - {navigation.navigate("JoinedWeek",{programId,programTitle:title,weekId:item.id,weekNumber:item.weekNumber,workouts:item.workouts, navigation:navigation})}}> - Start Workout - - 0% + ); }; @@ -55,7 +52,7 @@ const ProgramDetail = ({ route }) => { /> - Commit to Program + Join Program navigation.navigate("WorkoutDetails",{weeks,navigation})}>