-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
190 frontend start existing workout functionality (#201)
* COMMIT FOR EXERCISE LIST sob * Simplify ExerciseList return logic * Update createworkout Switch code to correct file. Styled some more. * Workout list functionality Still need to add search bar, list of exercises, and select exercise to next page. * Final touches to startexisting * fix SearchBar component. Implement into workoutList.tsx. Style changes with workoutList.tsx --------- Co-authored-by: Taylor Finelli <taylorfinelli@Taylors-MacBook-Pro.local> Co-authored-by: Taylor Finelli <taylorfinelli25@gmail.com>
- Loading branch information
1 parent
db8c1d0
commit b7321a7
Showing
5 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { TouchableOpacity } from '@gorhom/bottom-sheet' | ||
import React, {useState} from 'react' | ||
import { Text, View } from 'react-native' | ||
import { ScrollView } from 'react-native-gesture-handler' | ||
|
||
import RotatingBarbellIcon from '~/components/notif/RotatingBarbellIcon' | ||
import { api } from '~/utils/api' | ||
|
||
export default function ExerciseList() { | ||
const { data, isFetched, isFetching } = api.exercise.getAllExercises.useQuery() | ||
|
||
const [selectExercise, setSelect] = useState<{[eid: number]: boolean }>({}); | ||
|
||
const selectToggle = (eid: number) => { | ||
setSelect((prevState) => ({ | ||
prevState, | ||
[eid]: !prevState[eid], | ||
})); | ||
}; | ||
|
||
const exercises = | ||
<ScrollView className='px-[15px]'> | ||
{data?.map((exercise) => | ||
<TouchableOpacity key={exercise.id} className='' | ||
style={{backgroundColor: selectExercise[exercise.id] ? "#48476D" : "#1E1E1E"}} | ||
onPress={() => selectToggle(exercise.id)}> | ||
<Text className='text-slate-200 text-[20px] my-[12px]'> | ||
{exercise.name} | ||
</Text> | ||
</TouchableOpacity>)} | ||
</ScrollView> | ||
|
||
return ( | ||
<View> | ||
{isFetching && <RotatingBarbellIcon />} | ||
{isFetched && exercises} | ||
</View> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { useState } from 'react' | ||
import { Text, TextInput, View } from 'react-native' | ||
import { ScrollView } from 'react-native-gesture-handler' | ||
|
||
import { TouchableOpacity } from '@gorhom/bottom-sheet' | ||
|
||
import RotatingBarbellIcon from '~/components/notif/RotatingBarbellIcon' | ||
import SearchBar from '~/components/ui/search-bar/SearchBar' | ||
import { api } from '~/utils/api' | ||
|
||
export default function WorkoutList() { | ||
// Query data | ||
const { data, isFetched, isFetching } = api.workout.getAllWorkouts.useQuery() | ||
|
||
// Select an exercise | ||
const [selectExercise, setSelect] = useState<{ [wid: number]: boolean }>({}) | ||
const selectToggle = (wid: number) => { | ||
setSelect((prevState) => ({ | ||
[wid]: !prevState[wid], | ||
})) | ||
} | ||
|
||
const [filteredList, setFilteredList] = useState(data) | ||
|
||
const workouts = ( | ||
<View> | ||
<SearchBar | ||
filterBy="name" | ||
list={data} | ||
placeholder="Search workout by name..." | ||
setFilteredList={setFilteredList} | ||
/> | ||
<View className="pt-3" style={{ borderBottomWidth: 1, borderBottomColor: '#737272' }} /> | ||
|
||
<ScrollView className="h-full"> | ||
{filteredList?.map((workout) => ( | ||
<View> | ||
<View className="px-3" key={workout.id}> | ||
<TouchableOpacity | ||
key={workout.id} | ||
className="pt-5" | ||
style={{ backgroundColor: selectExercise[workout.id] ? '#272727' : '#1E1E1E' }} | ||
onPress={() => selectToggle(workout.id)} | ||
> | ||
<Text className="px-2 text-[20px] text-slate-200">{workout.name}</Text> | ||
<View className="pt-2" /> | ||
<Text className="px-4 pb-4 italic text-slate-200 opacity-70">{workout.description}</Text> | ||
</TouchableOpacity> | ||
</View> | ||
<View className="ml-3 mr-3" style={{ borderBottomWidth: 1, borderBottomColor: '#737272' }} /> | ||
</View> | ||
))} | ||
</ScrollView> | ||
</View> | ||
) | ||
|
||
return ( | ||
<View> | ||
{isFetched && workouts} | ||
{isFetching && <RotatingBarbellIcon />} | ||
</View> | ||
) | ||
} |