feat: pass exercise id to exercise screen
This commit is contained in:
parent
93f0696ad2
commit
b9abcbb82a
2 changed files with 11 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { Box, Center, Heading, HStack, Icon, Image, Text, VStack } from '@gluestack-ui/themed';
|
import { Box, Center, Heading, HStack, Icon, Image, Text, VStack } from '@gluestack-ui/themed';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
||||||
import { ArrowLeft } from 'lucide-react-native';
|
import { ArrowLeft } from 'lucide-react-native';
|
||||||
import { ScrollView, TouchableOpacity } from 'react-native';
|
import { ScrollView, TouchableOpacity } from 'react-native';
|
||||||
|
|
||||||
|
|
@ -8,9 +8,16 @@ import SeriesSvg from '@assets/series.svg';
|
||||||
import RepetitionSvg from '@assets/repetitions.svg';
|
import RepetitionSvg from '@assets/repetitions.svg';
|
||||||
import { Button } from '@components/Button';
|
import { Button } from '@components/Button';
|
||||||
|
|
||||||
|
type RouteParams = {
|
||||||
|
exerciseId: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function Exercise() {
|
export function Exercise() {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { exerciseId } = route.params as RouteParams;
|
||||||
|
|
||||||
function handleGoBack() {
|
function handleGoBack() {
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ export function Home() {
|
||||||
|
|
||||||
const navigation = useNavigation<AppNavigatorRoutesProps>();
|
const navigation = useNavigation<AppNavigatorRoutesProps>();
|
||||||
|
|
||||||
function handleOpenExerciseDetails() {
|
function handleOpenExerciseDetails(exerciseId: string) {
|
||||||
navigation.navigate('Exercise');
|
navigation.navigate('Exercise', { exerciseId });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchGroups() {
|
async function fetchGroups() {
|
||||||
|
|
@ -115,7 +115,7 @@ export function Home() {
|
||||||
data={exercises}
|
data={exercises}
|
||||||
keyExtractor={(item) => item.id}
|
keyExtractor={(item) => item.id}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<ExerciseCard data={item} onPress={handleOpenExerciseDetails} />
|
<ExerciseCard data={item} onPress={() => handleOpenExerciseDetails(item.id)} />
|
||||||
)}
|
)}
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
contentContainerStyle={{ paddingBottom: 20 }}
|
contentContainerStyle={{ paddingBottom: 20 }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue