From f52886327f2ee172ed1b74b52512eb4b53135567 Mon Sep 17 00:00:00 2001 From: Felix Ohnesorge Date: Sun, 5 May 2024 11:02:08 +0000 Subject: [PATCH] use pressable instead of touchableOpacity --- frontend/app/home.tsx | 10 +++++----- frontend/app/login.tsx | 7 +++---- frontend/app/workout/[id].tsx | 6 +++--- frontend/app/workout/create.tsx | 17 +++++++---------- frontend/components/AddExerciseModal.tsx | 10 +++++----- frontend/components/HorizontalScollView.tsx | 6 +++--- frontend/components/NumericInput.tsx | 10 +++++----- frontend/components/ProfileButton.js | 6 +++--- 8 files changed, 34 insertions(+), 38 deletions(-) diff --git a/frontend/app/home.tsx b/frontend/app/home.tsx index a807f1b..7c56fd1 100644 --- a/frontend/app/home.tsx +++ b/frontend/app/home.tsx @@ -1,4 +1,4 @@ -import { TouchableOpacity, Text, SafeAreaView } from 'react-native'; +import { Text, SafeAreaView, Pressable } from 'react-native'; import { Stack, useRouter } from 'expo-router'; import React, { useState } from 'react'; import ProfileButton from '../components/ProfileButton'; @@ -50,18 +50,18 @@ const HomeScreen = () => { showAllAction={() => router.navigate('workouts')} > {workouts.map((workout, index) => ( - router.navigate(`/workout/${workout._id}`)} key={index} > {workout.name} - + ))} - router.navigate('workout/create')}> + router.navigate('workout/create')}> - + diff --git a/frontend/app/login.tsx b/frontend/app/login.tsx index bd256dd..28e87d5 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 { Text, TextInput, TouchableOpacity, SafeAreaView } from 'react-native'; +import { Text, TextInput, Pressable, SafeAreaView } from 'react-native'; import instance from '../interceptors'; import styles from '../styles'; @@ -51,10 +51,9 @@ const LoginScreen = () => { underlineColorAndroid="transparent" autoCapitalize="none" /> - {/* TODO: use Pressable */} - + Login - + ); }; diff --git a/frontend/app/workout/[id].tsx b/frontend/app/workout/[id].tsx index a6d4ec0..6d16738 100644 --- a/frontend/app/workout/[id].tsx +++ b/frontend/app/workout/[id].tsx @@ -1,6 +1,6 @@ import { useLocalSearchParams } from 'expo-router'; import React, { useEffect, useState } from 'react'; -import { SafeAreaView, Text, TouchableOpacity } from 'react-native'; +import { SafeAreaView, Text, Pressable } from 'react-native'; import styles from '../../styles'; import ExerciseCard from '../../components/ExerciseCard'; import HorizontalScrollView from '../../components/HorizontalScollView'; @@ -36,9 +36,9 @@ const WorkoutPage = () => { ))} - + Start Workout - + ); }; diff --git a/frontend/app/workout/create.tsx b/frontend/app/workout/create.tsx index 87c9fb1..46c0dc4 100644 --- a/frontend/app/workout/create.tsx +++ b/frontend/app/workout/create.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Text, TextInput, TouchableOpacity, SafeAreaView } from 'react-native'; +import { Text, TextInput, Pressable, SafeAreaView } from 'react-native'; import styles from '../../styles'; import AddExerciseModal from '../../components/AddExerciseModal'; import AddCard from '../../components/AddCard'; @@ -76,20 +76,17 @@ const CreateWorkout = () => { /> {exercises.map((exercise, index) => ( - handleExerciseClick(exercise)} - > + handleExerciseClick(exercise)}> - + ))} - setModalVisible(true)}> + setModalVisible(true)}> - + - + Create Workout - + setModalVisible(false)} diff --git a/frontend/components/AddExerciseModal.tsx b/frontend/components/AddExerciseModal.tsx index 8b9c353..650797b 100644 --- a/frontend/components/AddExerciseModal.tsx +++ b/frontend/components/AddExerciseModal.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Modal, Text, TextInput, TouchableOpacity } from 'react-native'; +import { Modal, Text, TextInput, Pressable } from 'react-native'; import styles from '../styles'; import { SafeAreaView } from 'react-native-safe-area-context'; import NumericInput from './NumericInput'; @@ -36,17 +36,17 @@ const AddExerciseModal = ({ /> - onAddExercise({ exercise: { name: exerciseName }, reps, sets }) } > Add Exercise - - + + Cancel - + ); diff --git a/frontend/components/HorizontalScollView.tsx b/frontend/components/HorizontalScollView.tsx index e282311..3f84064 100644 --- a/frontend/components/HorizontalScollView.tsx +++ b/frontend/components/HorizontalScollView.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ScrollView, View, Text, TouchableOpacity } from 'react-native'; +import { ScrollView, View, Text, Pressable } from 'react-native'; import styles from '../styles'; @@ -19,9 +19,9 @@ const HorizontalScrollView: React.FC = ({ {title} {showAllAction && ( - + Show all - + )} { justifyContent: 'center', }} > - + - + {value} - + - + ); diff --git a/frontend/components/ProfileButton.js b/frontend/components/ProfileButton.js index f6b06c0..05fc1e5 100644 --- a/frontend/components/ProfileButton.js +++ b/frontend/components/ProfileButton.js @@ -1,17 +1,17 @@ import React from 'react'; -import { TouchableOpacity } from 'react-native'; +import { Pressable } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; import styles from '../styles'; export default function ProfileButton({ onPress }) { return ( - + - + ); }