@@ -54,8 +54,9 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
5454 setContainerSize ( e . nativeEvent . layout ) ;
5555 } ;
5656
57+ const isImageLoaded = imageSize . width > 0 && imageSize . height > 0 ;
5758 const imageLoadingStart = ( ) => {
58- if ( ! isLoading ) {
59+ if ( isImageLoaded ) {
5960 return ;
6061 }
6162
@@ -66,6 +67,9 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
6667
6768 const imageLoad = ( { nativeEvent : size } : ImageOnLoadEvent ) => {
6869 setImageSize ( size ) ;
70+ } ;
71+
72+ const imageLoadingEnd = ( ) => {
6973 setIsLoading ( false ) ;
7074 } ;
7175
@@ -189,6 +193,7 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
189193 isLocalToUserDeviceFile = false ;
190194 }
191195
196+ const shouldShowOfflineIndicator = isOffline && ! isLoading && ! isLocalToUserDeviceFile ;
192197 if ( canUseTouchScreen ) {
193198 return (
194199 < Lightbox
@@ -207,7 +212,7 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
207212 >
208213 < PressableWithoutFeedback
209214 style = { {
210- ...StyleUtils . getZoomSizingStyle ( { imageSize, containerSize, isZoomed, zoomScale, isLoading} ) ,
215+ ...StyleUtils . getZoomSizingStyle ( { imageSize, containerSize, isZoomed, zoomScale, isLoading : ! isImageLoaded } ) ,
211216 ...StyleUtils . getZoomCursorStyle ( isZoomed , isDragging ) ,
212217 ...( isZoomed && zoomScale >= 1 ? styles . pRelative : styles . pAbsolute ) ,
213218 ...styles . flex1 ,
@@ -224,6 +229,7 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
224229 resizeMode = { RESIZE_MODES . contain }
225230 onLoadStart = { imageLoadingStart }
226231 onLoad = { imageLoad }
232+ onLoadEnd = { imageLoadingEnd }
227233 waitForSession = { ( ) => {
228234 setImageSize ( { width : 0 , height : 0 } ) ;
229235 setIsLoading ( true ) ;
@@ -233,8 +239,8 @@ function ImageView({isAuthTokenRequired = false, url, fileName, onError}: ImageV
233239 />
234240 </ PressableWithoutFeedback >
235241
236- { isLoading && ( ! isOffline || isLocalToUserDeviceFile ) && < FullscreenLoadingIndicator style = { [ styles . opacity1 , styles . bgTransparent ] } /> }
237- { isLoading && ! isLocalToUserDeviceFile && < AttachmentOfflineIndicator /> }
242+ { ! isImageLoaded && ! shouldShowOfflineIndicator && < FullscreenLoadingIndicator style = { [ styles . opacity1 , styles . bgTransparent ] } /> }
243+ { ! isImageLoaded && shouldShowOfflineIndicator && < AttachmentOfflineIndicator /> }
238244 </ View >
239245 ) ;
240246}
0 commit comments