diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx
index 0d0ac4df1f..27ffece7ad 100644
--- a/src/view/com/lightbox/ImageViewing/index.tsx
+++ b/src/view/com/lightbox/ImageViewing/index.tsx
@@ -8,7 +8,7 @@
// Original code copied and simplified from the link below as the codebase is currently not maintained:
// https://github.com/jobtoday/react-native-image-viewing
-import React, {ComponentType, useCallback, useMemo, useState} from 'react'
+import React, {useCallback, useMemo, useState} from 'react'
import {Platform, StyleSheet, View} from 'react-native'
import PagerView from 'react-native-pager-view'
import {MeasuredDimensions} from 'react-native-reanimated'
@@ -26,8 +26,7 @@ type Props = {
visible: boolean
onRequestClose: () => void
backgroundColor?: string
- HeaderComponent?: ComponentType<{imageIndex: number}>
- FooterComponent?: ComponentType<{imageIndex: number}>
+ renderFooter: (index: number) => React.ReactNode
}
const DEFAULT_BG_COLOR = '#000'
@@ -39,8 +38,7 @@ function ImageViewing({
visible,
onRequestClose,
backgroundColor = DEFAULT_BG_COLOR,
- HeaderComponent,
- FooterComponent,
+ renderFooter,
}: Props) {
const [isScaled, setIsScaled] = useState(false)
const [isDragging, setIsDragging] = useState(false)
@@ -96,13 +94,7 @@ function ImageViewing({
accessibilityViewIsModal>
- {typeof HeaderComponent !== 'undefined' ? (
- React.createElement(HeaderComponent, {
- imageIndex,
- })
- ) : (
-
- )}
+
))}
- {typeof FooterComponent !== 'undefined' && (
-
- {React.createElement(FooterComponent, {
- imageIndex,
- })}
-
- )}
+
+ {renderFooter(imageIndex)}
+
)
diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx
index 83ea2e941b..23da86c659 100644
--- a/src/view/com/lightbox/Lightbox.tsx
+++ b/src/view/com/lightbox/Lightbox.tsx
@@ -46,7 +46,7 @@ export function Lightbox() {
thumbDims={opts.thumbDims}
visible
onRequestClose={onClose}
- FooterComponent={LightboxFooter}
+ renderFooter={() => }
/>
)
} else if (activeLightbox.type === 'images') {
@@ -58,7 +58,12 @@ export function Lightbox() {
thumbDims={opts.thumbDims}
visible
onRequestClose={onClose}
- FooterComponent={LightboxFooter}
+ renderFooter={index => (
+
+ )}
/>
)
} else {
@@ -66,9 +71,8 @@ export function Lightbox() {
}
}
-function LightboxFooter({imageIndex}: {imageIndex: number}) {
+function LightboxFooter({altText, uri}: {altText?: string; uri: string}) {
const {_} = useLingui()
- const {activeLightbox} = useLightbox()
const [isAltExpanded, setAltExpanded] = React.useState(false)
const [permissionResponse, requestPermission] = MediaLibrary.usePermissions({
granularPermissions: ['photo'],
@@ -107,22 +111,6 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
[permissionResponse, requestPermission, _],
)
- const lightbox = activeLightbox
- if (!lightbox) {
- return null
- }
-
- let altText = ''
- let uri = ''
- if (lightbox.type === 'images') {
- const opts = lightbox
- uri = opts.images[imageIndex].uri
- altText = opts.images[imageIndex].alt || ''
- } else if (lightbox.type === 'profile-image') {
- const opts = lightbox
- uri = opts.profile.avatar || ''
- }
-
return (