import { StyleConstants } from '@utils/styles/constants' import React, { useCallback, useState } from 'react' import { ImageStyle, Pressable, StyleProp, StyleSheet, ViewStyle } from 'react-native' import { Blurhash } from 'react-native-blurhash' import FastImage from 'react-native-fast-image' import { SharedElement } from 'react-navigation-shared-element' import { useTheme } from '@utils/styles/ThemeManager' export interface Props { sharedElement?: string hidden?: boolean uri: { preview?: string; original: string; remote?: string } blurhash?: string dimension?: { width: number; height: number } onPress?: () => void style?: StyleProp imageStyle?: StyleProp } const GracefullyImage: React.FC = ({ sharedElement, hidden = false, uri, blurhash, dimension, onPress, style, imageStyle }) => { const { mode, theme } = useTheme() const [imageLoaded, setImageLoaded] = useState(false) const children = useCallback(() => { return ( <> {sharedElement ? ( setImageLoaded(true)} /> ) : ( setImageLoaded(true)} /> )} {blurhash && (hidden || !imageLoaded) ? ( ) : null} ) }, [hidden, imageLoaded, mode, uri]) return (