1- import React from 'react' ;
1+ import React , { useMemo } from 'react' ;
22import { View } from 'react-native' ;
33import type { ImageStyle , StyleProp } from 'react-native' ;
44import Animated , { SharedValue } from 'react-native-reanimated' ;
55
6+ import { useChatConfigContext } from '../../../contexts/chatConfigContext/ChatConfigContext' ;
7+ import { getResizedImageUrl } from '../../../utils/getResizedImageUrl' ;
68import { useAnimatedGalleryStyle } from '../hooks/useAnimatedGalleryStyle' ;
79
810const oneEighth = 1 / 8 ;
@@ -15,6 +17,7 @@ type Props = {
1517 previous : boolean ;
1618 scale : SharedValue < number > ;
1719 screenHeight : number ;
20+ screenWidth : number ;
1821 selected : boolean ;
1922 shouldRender : boolean ;
2023 translateX : SharedValue < number > ;
@@ -32,12 +35,23 @@ export const AnimatedGalleryImage = React.memo(
3235 previous,
3336 scale,
3437 screenHeight,
38+ screenWidth,
3539 selected,
3640 shouldRender,
3741 style,
3842 translateX,
3943 translateY,
4044 } = props ;
45+ const { resizableCDNHosts } = useChatConfigContext ( ) ;
46+
47+ const uri = useMemo ( ( ) => {
48+ return getResizedImageUrl ( {
49+ height : screenHeight ,
50+ resizableCDNHosts,
51+ url : photo . uri ,
52+ width : screenWidth ,
53+ } ) ;
54+ } , [ photo . uri , resizableCDNHosts , screenHeight , screenWidth ] ) ;
4155
4256 const animatedStyles = useAnimatedGalleryStyle ( {
4357 index,
@@ -63,7 +77,7 @@ export const AnimatedGalleryImage = React.memo(
6377 < Animated . Image
6478 accessibilityLabel = { accessibilityLabel }
6579 resizeMode = { 'contain' }
66- source = { { uri : photo . uri } }
80+ source = { { uri } }
6781 style = { [ ...animatedStyles , style ] }
6882 />
6983 ) ;
@@ -75,7 +89,8 @@ export const AnimatedGalleryImage = React.memo(
7589 prevProps . photo . uri === nextProps . photo . uri &&
7690 prevProps . previous === nextProps . previous &&
7791 prevProps . index === nextProps . index &&
78- prevProps . screenHeight === nextProps . screenHeight
92+ prevProps . screenHeight === nextProps . screenHeight &&
93+ prevProps . screenWidth === nextProps . screenWidth
7994 ) {
8095 return true ;
8196 }
0 commit comments