1- import { SurfaceText } from '@/components/presentation/surface-text ' ;
1+ import { AccordionItem } from '@/components/presentation/accordion-item ' ;
22import { spacing } from '@/hooks/useAppTheme' ;
33import { RecordedExercise } from '@/models/session-models' ;
4+ import { useState } from 'react' ;
45import { View } from 'react-native' ;
5- import { Card , Divider , Icon } from 'react-native-paper' ;
6+ import { Card , Divider , IconButton , Text } from 'react-native-paper' ;
7+ import Animated , { FadeInDown , FadeOutUp } from 'react-native-reanimated' ;
68
79interface ExerciseNotesDisplayProps {
810 exercise : RecordedExercise ;
@@ -11,36 +13,79 @@ interface ExerciseNotesDisplayProps {
1113export default function ExerciseNotesDisplay ( props : ExerciseNotesDisplayProps ) {
1214 const notes = props . exercise . notes ?? '' ;
1315 const blueprintNotes = props . exercise . blueprint . notes ?? '' ;
14- const previousNotes = props . previousExercise ?. notes ?? '' ;
16+ const previousNotes = props . previousExercise ?. notes
17+ ? 'Last time: ' + props . previousExercise . notes
18+ : '' ;
19+ const [ expanded , setExpanded ] = useState ( false ) ;
20+ const unexpandedNotes = notes || previousNotes || blueprintNotes ;
1521
16- if ( ! notes && ! blueprintNotes && ! previousNotes ) {
22+ const hasNotes = ! ( ! notes && ! blueprintNotes && ! previousNotes ) ;
23+ if ( ! hasNotes ) {
1724 return undefined ;
1825 }
1926 return (
20- < Card mode = "contained" style = { { marginTop : spacing [ 4 ] } } >
21- < Card . Content >
22- < View style = { { flexDirection : 'row' , gap : spacing [ 2 ] } } >
23- < Icon source = { 'notes' } size = { 24 } />
24- < View style = { { gap : spacing [ 2 ] , flex : 1 , paddingRight : spacing [ 2 ] } } >
25- { blueprintNotes && (
26- < Notes value = { blueprintNotes } testID = "exercise-blueprint-notes" />
27- ) }
28- { previousNotes && blueprintNotes && < Divider /> }
29- { previousNotes && (
30- < Notes
31- value = { 'Last time: ' + previousNotes }
32- testID = "exercise-previous-notes"
33- />
34- ) }
35- { notes && ( previousNotes || blueprintNotes ) && < Divider /> }
36- { notes && < Notes value = { notes } testID = "exercise-notes" /> }
37- </ View >
38- </ View >
39- </ Card . Content >
27+ < Card mode = "contained" style = { [ { marginTop : spacing [ 4 ] } ] } >
28+ { hasNotes && (
29+ < AccordionItem isExpanded = { expanded } >
30+ < Card . Content >
31+ < View
32+ style = { {
33+ flexDirection : 'row' ,
34+ gap : spacing [ 2 ] ,
35+ marginTop : spacing [ 4 ] ,
36+ } }
37+ >
38+ < View
39+ style = { { gap : spacing [ 2 ] , flex : 1 , paddingRight : spacing [ 2 ] } }
40+ >
41+ { blueprintNotes && (
42+ < Notes
43+ value = { blueprintNotes }
44+ testID = "exercise-blueprint-notes"
45+ />
46+ ) }
47+ { previousNotes && blueprintNotes && < Divider /> }
48+ { previousNotes && (
49+ < Notes
50+ value = { previousNotes }
51+ testID = "exercise-previous-notes"
52+ />
53+ ) }
54+ { notes && ( previousNotes || blueprintNotes ) && < Divider /> }
55+ { notes && < Notes value = { notes } testID = "exercise-notes" /> }
56+ </ View >
57+ </ View >
58+ </ Card . Content >
59+ </ AccordionItem >
60+ ) }
61+ < Card . Actions >
62+ { ! expanded && (
63+ < Animated . View
64+ entering = { FadeInDown }
65+ exiting = { FadeOutUp }
66+ style = { {
67+ flex : 1 ,
68+ alignItems : 'center' ,
69+ flexDirection : 'row' ,
70+ overflow : 'hidden' ,
71+ } }
72+ >
73+ < Text style = { { flex : 1 } } numberOfLines = { 1 } ellipsizeMode = "tail" >
74+ { unexpandedNotes }
75+ </ Text >
76+ </ Animated . View >
77+ ) }
78+
79+ < IconButton
80+ icon = { expanded ? 'unfoldLess' : 'unfoldMore' }
81+ animated
82+ onPress = { ( ) => setExpanded ( ( e ) => ! e ) }
83+ />
84+ </ Card . Actions >
4085 </ Card >
4186 ) ;
4287}
4388
4489function Notes ( props : { value : string ; testID : string } ) {
45- return < SurfaceText testID = { props . testID } > { props . value } </ SurfaceText > ;
90+ return < Text testID = { props . testID } > { props . value } </ Text > ;
4691}
0 commit comments