11import React , { useMemo } from 'react' ;
2- import { View , Text , TouchableOpacity } from 'react-native' ;
2+ import { Text , TouchableOpacity , View } from 'react-native' ;
3+ import Animated , { FadeIn , FadeOut , LinearTransition } from 'react-native-reanimated' ;
34import { useCSSVariable } from 'uniwind' ;
45import Icon from './Icon' ;
56import Button from './ui/Button' ;
67import SafeImage from './SafeImage' ;
78import EditableSetRow from './EditableSetRow' ;
9+ import { CATEGORY_ICON_MAP } from '../utils/workoutSession' ;
810import type { WorkoutDraftExercise } from '../types/drafts' ;
911import type { GetImageSource } from '../hooks/useExerciseImageSource' ;
1012
@@ -47,13 +49,17 @@ function EditableExerciseCard({
4749 ( ) => ( imagePath ? getImageSource ( imagePath ) : null ) ,
4850 [ getImageSource , imagePath ] ,
4951 ) ;
52+ const exerciseIcon = ( exercise . exerciseCategory && CATEGORY_ICON_MAP [ exercise . exerciseCategory ] ) || 'exercise-weights' ;
5053
5154 return (
5255 < View className = "flex-row items-start py-4" >
53- < SafeImage
54- source = { imageSource }
55- style = { { width : 48 , height : 48 , borderRadius : 8 , marginRight : 12 , marginTop : 2 , opacity : 0.8 } }
56- />
56+ < View className = "mr-3 items-center justify-center" style = { { width : 48 , height : 48 , marginTop : 2 } } >
57+ < SafeImage
58+ source = { imageSource }
59+ style = { { width : 48 , height : 48 , borderRadius : 8 , opacity : 0.8 } }
60+ fallback = { < Icon name = { exerciseIcon } size = { 28 } color = { accentPrimary } /> }
61+ />
62+ </ View >
5763 < View className = "flex-1" >
5864 < View className = "flex-row items-center justify-between" >
5965 < Text className = "text-base font-semibold text-text-primary flex-1 mr-2" numberOfLines = { 1 } >
@@ -76,7 +82,7 @@ function EditableExerciseCard({
7682 ) : null }
7783
7884 { exercise . sets . length > 0 && (
79- < View className = "mt-2" >
85+ < Animated . View className = "mt-2" layout = { LinearTransition . duration ( 300 ) } >
8086 < View className = "flex-row items-center py-1 mb-1" >
8187 < Text className = "text-xs font-semibold text-text-muted w-10 text-center" > Set</ Text >
8288 < Text className = "text-xs font-semibold text-text-muted flex-1 text-center" > Weight</ Text >
@@ -88,36 +94,42 @@ function EditableExerciseCard({
8894 const isLastSet = index === exercise . sets . length - 1 ;
8995 const nextSet = exercise . sets [ index + 1 ] ;
9096 return (
91- < EditableSetRow
97+ < Animated . View
9298 key = { set . clientId }
93- exerciseClientId = { exercise . clientId }
94- setClientId = { set . clientId }
95- weight = { set . weight }
96- reps = { set . reps }
97- setNumber = { index + 1 }
98- isActive = { activeSetKey === setKey }
99- initialFocusField = { activeSetKey === setKey ? activeSetField : undefined }
100- weightUnit = { weightUnit }
101- nextSetKey = { nextSet ? `${ exercise . clientId } :${ nextSet . clientId } ` : null }
102- onActivateSet = { onActivateSet }
103- onDeactivate = { onDeactivateSet }
104- onUpdateSetField = { onUpdateSetField }
105- onRemoveSet = { onRemoveSet }
106- onAddSet = { onAddSet }
107- isLastSet = { isLastSet }
108- />
99+ entering = { FadeIn . duration ( 200 ) }
100+ exiting = { FadeOut . duration ( 150 ) }
101+ layout = { LinearTransition . duration ( 300 ) }
102+ >
103+ < EditableSetRow
104+ exerciseClientId = { exercise . clientId }
105+ setClientId = { set . clientId }
106+ weight = { set . weight }
107+ reps = { set . reps }
108+ setNumber = { index + 1 }
109+ isActive = { activeSetKey === setKey }
110+ initialFocusField = { activeSetKey === setKey ? activeSetField : undefined }
111+ weightUnit = { weightUnit }
112+ nextSetKey = { nextSet ? `${ exercise . clientId } :${ nextSet . clientId } ` : null }
113+ onActivateSet = { onActivateSet }
114+ onDeactivate = { onDeactivateSet }
115+ onUpdateSetField = { onUpdateSetField }
116+ onRemoveSet = { onRemoveSet }
117+ onAddSet = { onAddSet }
118+ isLastSet = { isLastSet }
119+ />
120+ </ Animated . View >
109121 ) ;
110122 } ) }
111- </ View >
123+ </ Animated . View >
112124 ) }
113125
114126 < TouchableOpacity
115- className = "flex-row items-center self-start py-2 mt-1 rounded-lg "
127+ className = "flex-row items-center justify-center py-3 "
116128 onPress = { ( ) => onAddSet ( exercise . clientId ) }
117129 activeOpacity = { 0.6 }
118130 >
119- < Icon name = "add-circle " size = { 18 } color = { accentPrimary } />
120- < Text className = "text-sm font-medium ml-1" style = { { color : accentPrimary } } >
131+ < Icon name = "add" size = { 18 } color = { accentPrimary } />
132+ < Text className = "text-base font-medium ml-1" style = { { color : accentPrimary } } >
121133 Add Set
122134 </ Text >
123135 </ TouchableOpacity >
0 commit comments