@@ -4,7 +4,7 @@ import * as ImageManipulator from 'expo-image-manipulator';
44import * as ImagePicker from 'expo-image-picker' ;
55import { CameraIcon , ChevronLeftIcon , ChevronRightIcon , ImageIcon , PlusIcon , X } from 'lucide-react-native' ;
66import { useColorScheme } from 'nativewind' ;
7- import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
7+ import React , { memo , useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
88import { useTranslation } from 'react-i18next' ;
99import { Dimensions , Keyboard , Modal , SafeAreaView , StyleSheet , TouchableOpacity , View } from 'react-native' ;
1010import { KeyboardStickyView } from 'react-native-keyboard-controller' ;
@@ -50,7 +50,7 @@ const CallImagesModal: React.FC<CallImagesModalProps> = ({ isOpen, onClose, call
5050 const [ isAddingImage , setIsAddingImage ] = useState ( false ) ;
5151 const [ imageErrors , setImageErrors ] = useState < Set < string > > ( new Set ( ) ) ;
5252 const [ fullScreenImage , setFullScreenImage ] = useState < { source : any ; name ?: string } | null > ( null ) ;
53- const flatListRef = useRef < any > ( null ) ; // FlashList ref type
53+ const flatListRef = useRef < FlatList < CallFileResultData > > ( null ) ;
5454
5555 const { callImages, isLoadingImages, errorImages, fetchCallImages, uploadCallImage, clearImages } = useCallDetailStore ( ) ;
5656
@@ -206,6 +206,10 @@ const CallImagesModal: React.FC<CallImagesModalProps> = ({ isOpen, onClose, call
206206 setImageErrors ( ( prev ) => new Set ( [ ...prev , itemId ] ) ) ;
207207 } ;
208208
209+ const handleImagePress = useCallback ( ( source : { uri : string } , name ?: string ) => {
210+ setFullScreenImage ( { source, name } ) ;
211+ } , [ ] ) ;
212+
209213 // Reset active index when valid images change
210214
211215 const renderImageItem = ( { item, index } : { item : CallFileResultData ; index : number } ) => {
@@ -246,16 +250,7 @@ const CallImagesModal: React.FC<CallImagesModalProps> = ({ isOpen, onClose, call
246250 // At this point, imageSource is guaranteed to be non-null
247251 return (
248252 < Box className = "w-full items-center justify-center px-4" style = { { width } } >
249- < TouchableOpacity
250- onPress = { ( ) => {
251- setFullScreenImage ( { source : imageSource , name : item . Name } ) ;
252- } }
253- testID = { `image-${ item . Id } -touchable` }
254- activeOpacity = { 0.7 }
255- style = { { width : '100%' } }
256- delayPressIn = { 0 }
257- delayPressOut = { 0 }
258- >
253+ < TouchableOpacity onPress = { ( ) => handleImagePress ( imageSource , item . Name ) } testID = { `image-${ item . Id } -touchable` } activeOpacity = { 0.7 } style = { { width : '100%' } } delayPressIn = { 0 } delayPressOut = { 0 } >
259254 < Image
260255 key = { `${ item . Id } -${ index } ` }
261256 source = { imageSource }
@@ -467,12 +462,12 @@ const CallImagesModal: React.FC<CallImagesModalProps> = ({ isOpen, onClose, call
467462 < View style = { [ styles . header , isDark && styles . headerDark ] } >
468463 < Heading size = "lg" > { isAddingImage ? t ( 'callImages.add_new' ) : t ( 'callImages.title' ) } </ Heading >
469464 < HStack className = "items-center space-x-2" >
470- { ! isAddingImage && ! isLoadingImages && (
465+ { ! isAddingImage && ! isLoadingImages ? (
471466 < Button size = "sm" variant = "outline" onPress = { ( ) => setIsAddingImage ( true ) } >
472467 < ButtonIcon as = { PlusIcon } />
473468 < ButtonText > { t ( 'callImages.add' ) } </ ButtonText >
474469 </ Button >
475- ) }
470+ ) : null }
476471 < TouchableOpacity onPress = { handleClose } style = { styles . closeButton } testID = "close-button" >
477472 < X size = { 24 } color = { isDark ? '#D1D5DB' : '#374151' } />
478473 </ TouchableOpacity >
@@ -550,4 +545,4 @@ const styles = StyleSheet.create({
550545 } ,
551546} ) ;
552547
553- export default CallImagesModal ;
548+ export default memo ( CallImagesModal ) ;
0 commit comments