diff --git a/packages/components-native/src/FormatFile/FormatFile.tsx b/packages/components-native/src/FormatFile/FormatFile.tsx index c8cc8903fd..1899f1408d 100644 --- a/packages/components-native/src/FormatFile/FormatFile.tsx +++ b/packages/components-native/src/FormatFile/FormatFile.tsx @@ -88,6 +88,13 @@ interface FormatFileContentProps { * FormatFileThumbnail. */ readonly skipContainerStyles?: boolean; + + /** + * * @internal + * A function to be called when the media has loaded. + * This is only used in FormatFileThumbnail. + */ + readonly onMediaLoadEnd?: () => void; } export function FormatFileContent({ @@ -98,6 +105,7 @@ export function FormatFileContent({ onUploadComplete, isMedia, skipContainerStyles = false, + onMediaLoadEnd, }: FormatFileContentProps) { const styles = useStyles(); @@ -109,6 +117,7 @@ export function FormatFileContent({ showError={file.error} styleInGrid={styleInGrid} onUploadComplete={onUploadComplete} + onLoadEnd={onMediaLoadEnd} /> ) : ( { * A reference to the element in the rendered output. */ readonly testID?: string; + + /** + * @internal + * A function to be called when the media has loaded. + * Not to be used for Files + */ + readonly onMediaLoadEnd?: () => void; } /** @@ -62,6 +69,7 @@ export function FormatFileThumbnail({ createThumbnail: createThumbnailProp, size, testID, + onMediaLoadEnd, }: FormatFileThumbnailProps) { const formattedFile = useMemo( () => parseFile(file, showFileTypeIndicator), @@ -98,6 +106,7 @@ export function FormatFileThumbnail({ styleInGrid={true} showOverlay={showOverlay} skipContainerStyles={true} + onMediaLoadEnd={onMediaLoadEnd} /> diff --git a/packages/components-native/src/FormatFile/components/MediaView/MediaView.tsx b/packages/components-native/src/FormatFile/components/MediaView/MediaView.tsx index d4cc45d624..f7f2bb4839 100644 --- a/packages/components-native/src/FormatFile/components/MediaView/MediaView.tsx +++ b/packages/components-native/src/FormatFile/components/MediaView/MediaView.tsx @@ -18,6 +18,7 @@ interface MediaViewProps { readonly file: FormattedFile; readonly styleInGrid: boolean; readonly onUploadComplete: () => void; + readonly onLoadEnd?: () => void; } export function MediaView({ @@ -27,6 +28,7 @@ export function MediaView({ file, styleInGrid, onUploadComplete, + onLoadEnd, }: MediaViewProps) { const { t } = useAtlantisI18n(); const { useCreateThumbnail } = useAtlantisFormatFileContext(); @@ -77,7 +79,10 @@ export function MediaView({ source={{ uri }} testID={"test-image"} onLoadStart={handleLoadStart} - onLoadEnd={handleLoadEnd} + onLoadEnd={() => { + handleLoadEnd(); + onLoadEnd?.(); + }} > void" + } } } },