diff options
Diffstat (limited to 'src/view/com/lightbox')
5 files changed, 33 insertions, 4 deletions
diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx new file mode 100644 index 000000000..fd377dde2 --- /dev/null +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx @@ -0,0 +1,21 @@ +// default implementation fallback for web + +import React from 'react' +import {View} from 'react-native' +import {ImageSource} from '../../@types' + +type Props = { + imageSrc: ImageSource + onRequestClose: () => void + onZoom: (scaled: boolean) => void + onLongPress: (image: ImageSource) => void + delayLongPress: number + swipeToCloseEnabled?: boolean + doubleTapToZoomEnabled?: boolean +} + +const ImageItem = (_props: Props) => { + return <View /> +} + +export default React.memo(ImageItem) diff --git a/src/view/com/lightbox/ImageViewing/hooks/useImageDimensions.ts b/src/view/com/lightbox/ImageViewing/hooks/useImageDimensions.ts index bab136c50..a5b0b6bd4 100644 --- a/src/view/com/lightbox/ImageViewing/hooks/useImageDimensions.ts +++ b/src/view/com/lightbox/ImageViewing/hooks/useImageDimensions.ts @@ -47,8 +47,8 @@ const useImageDimensions = (image: ImageSource): Dimensions | null => { if (imageDimensions) { resolve(imageDimensions) } else { - // @ts-ignore Image.getSizeWithHeaders( + // @ts-ignore source.uri, source.headers, (width: number, height: number) => { diff --git a/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts b/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts index 4600cf1a8..036e7246f 100644 --- a/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts +++ b/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts @@ -61,7 +61,7 @@ const usePanResponder = ({ let tmpTranslate: Position | null = null let isDoubleTapPerformed = false let lastTapTS: number | null = null - let longPressHandlerRef: number | null = null + let longPressHandlerRef: NodeJS.Timeout | null = null const meaningfulShift = MIN_DIMENSION * 0.01 const scaleValue = new Animated.Value(initialScale) diff --git a/src/view/com/lightbox/ImageViewing/utils.ts b/src/view/com/lightbox/ImageViewing/utils.ts index 7fcdc84cf..8c9c1b34c 100644 --- a/src/view/com/lightbox/ImageViewing/utils.ts +++ b/src/view/com/lightbox/ImageViewing/utils.ts @@ -77,6 +77,7 @@ export const getImageStyles = ( const transform = translate.getTranslateTransform() if (scale) { + // @ts-ignore TODO - is scale incorrect? might need to remove -prf transform.push({scale}, {perspective: new Animated.Value(1000)}) } diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx index c777a5528..df5839783 100644 --- a/src/view/com/lightbox/Lightbox.tsx +++ b/src/view/com/lightbox/Lightbox.tsx @@ -5,6 +5,7 @@ import ImageView from './ImageViewing' import {useStores} from '../../../state' import * as models from '../../../state/models/shell-ui' import {saveImageModal} from '../../../lib/images' +import {ImageSource} from './ImageViewing/@types' export const Lightbox = observer(function Lightbox() { const store = useStores() @@ -15,8 +16,14 @@ export const Lightbox = observer(function Lightbox() { const onClose = () => { store.shell.closeLightbox() } - const onLongPress = ({uri}: {uri: string}) => { - saveImageModal({uri}) + const onLongPress = (image: ImageSource) => { + if ( + typeof image === 'object' && + 'uri' in image && + typeof image.uri === 'string' + ) { + saveImageModal({uri: image.uri}) + } } if (store.shell.activeLightbox?.name === 'profile-image') { |