feat(mobile): remove preview image
This commit is contained in:
@@ -11,9 +11,8 @@ import { Galeria } from "@/src/components/ui/image/galeria"
|
||||
import type { MediaModel } from "@/src/database/schemas/types"
|
||||
import { EntryGridFooter } from "@/src/modules/entry-content/EntryGridFooter"
|
||||
|
||||
import { Image } from "../image/Image"
|
||||
import { ImageContextMenu } from "../image/ImageContextMenu"
|
||||
import { PreviewImage } from "../image/PreviewImage"
|
||||
import { ProxiedImage } from "../image/ProxiedImage"
|
||||
|
||||
export const MediaCarousel = ({
|
||||
entryId,
|
||||
@@ -70,39 +69,33 @@ export const MediaCarousel = ({
|
||||
>
|
||||
<Wrapper entryId={entryId} imageUrl={m.url}>
|
||||
<Galeria.Image onPreview={onPreview} index={index}>
|
||||
<ProxiedImage
|
||||
<Image
|
||||
proxy={{
|
||||
height: 400,
|
||||
}}
|
||||
transition={500}
|
||||
source={{ uri: m.url }}
|
||||
placeholder={{
|
||||
blurhash: m.blurhash,
|
||||
}}
|
||||
blurhash={m.blurhash}
|
||||
className="w-full"
|
||||
style={{
|
||||
aspectRatio,
|
||||
}}
|
||||
aspectRatio={aspectRatio}
|
||||
placeholderContentFit="cover"
|
||||
recyclingKey={m.url}
|
||||
/>
|
||||
</Galeria.Image>
|
||||
</Wrapper>
|
||||
</View>
|
||||
)
|
||||
} else if (m.preview_image_url) {
|
||||
// TODO: video preview
|
||||
return (
|
||||
<Image
|
||||
key={index}
|
||||
source={{ uri: m.preview_image_url }}
|
||||
aspectRatio={aspectRatio}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
// TODO: video preview
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<PreviewImage
|
||||
key={index}
|
||||
noPreview={noPreview}
|
||||
onPreview={() => {
|
||||
// open player
|
||||
}}
|
||||
imageUrl={m.url}
|
||||
aspectRatio={aspectRatio}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</ScrollView>
|
||||
</Galeria>
|
||||
|
||||
@@ -2,13 +2,10 @@ import { createBuildSafeHeaders } from "@follow/utils/src/headers"
|
||||
import { getImageProxyUrl, IMAGE_PROXY_URL } from "@follow/utils/src/img-proxy"
|
||||
import type { ImageProps as ExpoImageProps } from "expo-image"
|
||||
import { Image as ExpoImage } from "expo-image"
|
||||
import { forwardRef, useCallback, useMemo, useRef, useState } from "react"
|
||||
import { Pressable, View } from "react-native"
|
||||
import { forwardRef, useCallback, useMemo, useState } from "react"
|
||||
|
||||
import { proxyEnv } from "@/src/lib/proxy-env"
|
||||
|
||||
import { usePreviewImage } from "./PreviewPageProvider"
|
||||
|
||||
const buildSafeHeaders = createBuildSafeHeaders(proxyEnv.VITE_WEB_URL, [
|
||||
IMAGE_PROXY_URL,
|
||||
proxyEnv.VITE_API_URL,
|
||||
@@ -19,18 +16,16 @@ export type ImageProps = Omit<ExpoImageProps, "source"> & {
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
enablePreview?: boolean
|
||||
onPreview?: () => void
|
||||
source?: {
|
||||
uri: string
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
blurhash?: string
|
||||
aspectRatio: number
|
||||
aspectRatio?: number
|
||||
}
|
||||
|
||||
export const Image = forwardRef<ExpoImage, ImageProps>(
|
||||
({ proxy, source, enablePreview, onPreview, blurhash, aspectRatio, ...rest }, ref) => {
|
||||
({ proxy, source, blurhash, aspectRatio, ...rest }, ref) => {
|
||||
const safeSource: ImageProps["source"] = useMemo(() => {
|
||||
return source
|
||||
? {
|
||||
@@ -64,38 +59,18 @@ export const Image = forwardRef<ExpoImage, ImageProps>(
|
||||
setIsError(true)
|
||||
}, [])
|
||||
|
||||
const Wrapper = enablePreview ? Pressable : View
|
||||
|
||||
const { openPreview } = usePreviewImage()
|
||||
const imageRef = useRef<View>(null)
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
onPress={() => {
|
||||
if (enablePreview) {
|
||||
onPreview?.()
|
||||
openPreview({
|
||||
imageRef,
|
||||
images: [{ source, blurhash, aspectRatio, ...rest }],
|
||||
// accessoriesElement: Accessory ? <Accessory {...AccessoryProps} /> : undefined,
|
||||
})
|
||||
}
|
||||
<ExpoImage
|
||||
source={isError ? safeSource : proxiesSafeSource}
|
||||
onError={onError}
|
||||
placeholder={{ blurhash }}
|
||||
style={{
|
||||
aspectRatio,
|
||||
...(typeof rest.style === "object" && { ...rest.style }),
|
||||
}}
|
||||
>
|
||||
<View ref={imageRef}>
|
||||
<ExpoImage
|
||||
source={isError ? safeSource : proxiesSafeSource}
|
||||
onError={onError}
|
||||
placeholder={{ blurhash }}
|
||||
style={{
|
||||
aspectRatio,
|
||||
...(typeof rest.style === "object" && { ...rest.style }),
|
||||
}}
|
||||
{...rest}
|
||||
ref={ref}
|
||||
/>
|
||||
</View>
|
||||
</Wrapper>
|
||||
{...rest}
|
||||
ref={ref}
|
||||
/>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
import { cn } from "@follow/utils"
|
||||
import type { FC } from "react"
|
||||
import { useRef } from "react"
|
||||
import { Pressable, View } from "react-native"
|
||||
|
||||
import { usePreviewImage } from "./PreviewPageProvider"
|
||||
import { ProxiedImage } from "./ProxiedImage"
|
||||
|
||||
export interface PreviewImageProps {
|
||||
imageUrl: string
|
||||
blurhash?: string | undefined
|
||||
aspectRatio: number
|
||||
Accessory?: FC<any>
|
||||
AccessoryProps?: any
|
||||
onPreview?: () => void
|
||||
proxy?: {
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
noPreview?: boolean
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const PreviewImage = ({
|
||||
imageUrl,
|
||||
blurhash,
|
||||
aspectRatio,
|
||||
Accessory,
|
||||
AccessoryProps,
|
||||
onPreview,
|
||||
proxy,
|
||||
noPreview,
|
||||
className,
|
||||
}: PreviewImageProps) => {
|
||||
const imageRef = useRef<View>(null)
|
||||
|
||||
const { openPreview } = usePreviewImage()
|
||||
|
||||
const Wrapper = noPreview ? View : Pressable
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
onPress={() => {
|
||||
if (noPreview) return
|
||||
|
||||
onPreview?.()
|
||||
openPreview({
|
||||
imageRef,
|
||||
images: [
|
||||
{
|
||||
source: {
|
||||
uri: imageUrl,
|
||||
},
|
||||
aspectRatio,
|
||||
blurhash,
|
||||
recyclingKey: imageUrl,
|
||||
},
|
||||
],
|
||||
accessoriesElement: Accessory ? <Accessory {...AccessoryProps} /> : undefined,
|
||||
})
|
||||
}}
|
||||
>
|
||||
<View ref={imageRef}>
|
||||
<ProxiedImage
|
||||
proxy={{
|
||||
width: proxy?.width,
|
||||
height: proxy?.height,
|
||||
}}
|
||||
transition={500}
|
||||
source={{ uri: imageUrl }}
|
||||
placeholder={{
|
||||
blurhash,
|
||||
}}
|
||||
className={cn("w-full", className)}
|
||||
style={{
|
||||
aspectRatio,
|
||||
}}
|
||||
placeholderContentFit="cover"
|
||||
recyclingKey={imageUrl}
|
||||
/>
|
||||
</View>
|
||||
</Wrapper>
|
||||
)
|
||||
}
|
||||
@@ -1,433 +0,0 @@
|
||||
import type { RefObject } from "react"
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react"
|
||||
import { Dimensions, Modal, Pressable, useWindowDimensions, View } from "react-native"
|
||||
import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler"
|
||||
import Animated, {
|
||||
runOnJS,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
withSpring,
|
||||
withTiming,
|
||||
} from "react-native-reanimated"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { gentleSpringPreset } from "@/src/constants/spring"
|
||||
import { CloseCuteReIcon } from "@/src/icons/close_cute_re"
|
||||
|
||||
import { PortalHost } from "../portal"
|
||||
import type { ImageProps } from "./Image"
|
||||
import { Image } from "./Image"
|
||||
import { ImageContextMenu } from "./ImageContextMenu"
|
||||
|
||||
interface OpenPreviewParams {
|
||||
imageRef: RefObject<View>
|
||||
images: ImageProps[]
|
||||
initialIndex?: number
|
||||
accessoriesElement?: React.ReactNode
|
||||
}
|
||||
|
||||
interface PreviewImageContextType {
|
||||
openPreview: (params: OpenPreviewParams) => void
|
||||
}
|
||||
const PreviewImageContext = createContext<PreviewImageContextType | null>(null)
|
||||
|
||||
export const usePreviewImage = () => {
|
||||
const context = useContext(PreviewImageContext)
|
||||
if (!context) {
|
||||
throw new Error("usePreviewImage must be used within PreviewImageProvider")
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
export const PreviewImageProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const { width, height } = useWindowDimensions()
|
||||
const [previewModalOpen, setPreviewModalOpen] = useState(false)
|
||||
|
||||
const [currentState, setCurrentState] = useState<ImageProps[] | null>(null)
|
||||
const [imageRef, setImageRef] = useState<View | null>(null)
|
||||
const [currentIndex, setCurrentIndex] = useState(0)
|
||||
const [accessoriesElement, setAccessoriesElement] = useState<React.ReactNode | null>(null)
|
||||
const layoutScale = useSharedValue(1)
|
||||
const layoutTransformX = useSharedValue(0)
|
||||
const layoutTransformY = useSharedValue(0)
|
||||
|
||||
const scale = useSharedValue(1)
|
||||
const savedScale = useSharedValue(1)
|
||||
const pinchCenter = useSharedValue({ x: 0, y: 0 })
|
||||
const translateX = useSharedValue(0)
|
||||
const translateY = useSharedValue(0)
|
||||
const savedTranslateX = useSharedValue(0)
|
||||
const savedTranslateY = useSharedValue(0)
|
||||
const pinchGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Pinch()
|
||||
.onStart((e) => {
|
||||
pinchCenter.value = { x: e.focalX, y: e.focalY }
|
||||
})
|
||||
.onUpdate((e) => {
|
||||
scale.value = savedScale.value * e.scale
|
||||
// Limit scale to 1 to 3
|
||||
scale.value = Math.min(Math.max(scale.value, 1), 3)
|
||||
})
|
||||
.onEnd(() => {
|
||||
savedScale.value = scale.value
|
||||
}),
|
||||
[pinchCenter, savedScale, scale],
|
||||
)
|
||||
|
||||
// Animation closing state
|
||||
const isClosing = useSharedValue(false)
|
||||
|
||||
// Animation opacity value
|
||||
const opacity = useSharedValue(1)
|
||||
|
||||
// Overlay opacity animation value
|
||||
const overlayOpacity = useSharedValue(0)
|
||||
|
||||
const panGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Pan()
|
||||
.runOnJS(true)
|
||||
.onUpdate((e) => {
|
||||
if (isClosing.value) return
|
||||
|
||||
if (scale.value === 1 && e.translationY > 0) {
|
||||
translateY.value = savedTranslateY.value + e.translationY * 0.5
|
||||
translateX.value = savedTranslateX.value + e.translationX * 0.5
|
||||
const progress = Math.abs(e.translationY) / (height * 2)
|
||||
scale.value = Math.max(0.8, 1 - progress)
|
||||
opacity.value = Math.max(0.3, 1 - progress * 1.5)
|
||||
// Update overlay opacity simultaneously
|
||||
overlayOpacity.value = Math.max(0, 0.9 - progress * 1.5)
|
||||
} else {
|
||||
translateX.value = savedTranslateX.value + e.translationX
|
||||
translateY.value = savedTranslateY.value + e.translationY
|
||||
}
|
||||
})
|
||||
.onEnd((e) => {
|
||||
if (!currentState) return
|
||||
if (!currentState[currentIndex]) return
|
||||
const { aspectRatio } = currentState[currentIndex]
|
||||
if (isClosing.value) return
|
||||
|
||||
if (scale.value <= 1 && e.translationY > 100) {
|
||||
isClosing.value = true
|
||||
|
||||
// Measure original image position
|
||||
imageRef?.measureInWindow((pageX, pageY, w1, h1) => {
|
||||
const duration = 300
|
||||
|
||||
overlayOpacity.value = withTiming(0, {
|
||||
duration,
|
||||
})
|
||||
|
||||
opacity.value = withTiming(0, {
|
||||
duration,
|
||||
})
|
||||
|
||||
const { width: w2 } = Dimensions.get("window")
|
||||
const s = w2 / w1
|
||||
|
||||
const x1 = pageX + w1 / 2
|
||||
const y1 = pageY + h1 / 2
|
||||
const x2 = w2 / 2
|
||||
const y2 = height / 2
|
||||
|
||||
const xDelta = (x1 - x2) * s
|
||||
const yDelta = (y1 - y2) * s
|
||||
|
||||
layoutScale.value = withTiming(
|
||||
1 / s,
|
||||
{
|
||||
duration,
|
||||
},
|
||||
(finished) => {
|
||||
if (finished) {
|
||||
runOnJS(setPreviewModalOpen)(false)
|
||||
}
|
||||
},
|
||||
)
|
||||
layoutTransformX.value = withTiming(xDelta, {
|
||||
duration,
|
||||
})
|
||||
layoutTransformY.value = withTiming(yDelta, {
|
||||
duration,
|
||||
})
|
||||
|
||||
scale.value = withTiming(1, {
|
||||
duration,
|
||||
})
|
||||
translateX.value = withTiming(0, {
|
||||
duration,
|
||||
})
|
||||
translateY.value = withTiming(0, {
|
||||
duration,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// Restore opacity
|
||||
opacity.value = withTiming(1, {
|
||||
duration: 100,
|
||||
})
|
||||
overlayOpacity.value = withTiming(0.9, {
|
||||
duration: 100,
|
||||
})
|
||||
// Handle horizontal swipe
|
||||
if (e.translationX < -50 && currentIndex < currentState.length - 1) {
|
||||
setCurrentIndex((prevIndex) => prevIndex + 1)
|
||||
} else if (e.translationX > 50 && currentIndex > 0) {
|
||||
setCurrentIndex((prevIndex) => prevIndex - 1)
|
||||
}
|
||||
// Boundary check logic
|
||||
const scaledWidth = width * scale.value
|
||||
const scaledHeight = height * aspectRatio * scale.value
|
||||
|
||||
// Calculate maximum allowed offset
|
||||
const maxOffsetX = Math.max(0, (scaledWidth - width) / 2)
|
||||
const maxOffsetY = Math.max(0, (scaledHeight - height) / 2)
|
||||
|
||||
// Calculate target position (with bounce effect)
|
||||
const targetX = Math.min(Math.max(translateX.value, -maxOffsetX), maxOffsetX)
|
||||
const targetY = Math.min(Math.max(translateY.value, -maxOffsetY), maxOffsetY)
|
||||
|
||||
// If scale is less than or equal to 1, force center
|
||||
if (scale.value <= 1) {
|
||||
translateX.value = withSpring(0, gentleSpringPreset)
|
||||
translateY.value = withSpring(0, gentleSpringPreset)
|
||||
savedTranslateX.value = 0
|
||||
savedTranslateY.value = 0
|
||||
} else {
|
||||
translateX.value = withSpring(targetX, gentleSpringPreset)
|
||||
translateY.value = withSpring(targetY, gentleSpringPreset)
|
||||
savedTranslateX.value = targetX
|
||||
savedTranslateY.value = targetY
|
||||
}
|
||||
}
|
||||
}),
|
||||
[
|
||||
currentState,
|
||||
currentIndex,
|
||||
height,
|
||||
imageRef,
|
||||
isClosing,
|
||||
layoutScale,
|
||||
layoutTransformX,
|
||||
layoutTransformY,
|
||||
opacity,
|
||||
overlayOpacity,
|
||||
savedTranslateX,
|
||||
savedTranslateY,
|
||||
scale,
|
||||
translateX,
|
||||
translateY,
|
||||
width,
|
||||
],
|
||||
)
|
||||
|
||||
const fadeOutCloseAnimation = useEventCallback(() => {
|
||||
scale.value = withSpring(1.2, gentleSpringPreset, (finished) => {
|
||||
if (finished) {
|
||||
runOnJS(setPreviewModalOpen)(false)
|
||||
}
|
||||
})
|
||||
opacity.value = withSpring(0, gentleSpringPreset)
|
||||
overlayOpacity.value = withSpring(0, gentleSpringPreset)
|
||||
})
|
||||
const doubleTapGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Tap()
|
||||
.numberOfTaps(2)
|
||||
.onStart((e) => {
|
||||
if (scale.value !== 1) {
|
||||
// If current scale is not 1, reset to 1 and center
|
||||
scale.value = withSpring(1, gentleSpringPreset)
|
||||
savedScale.value = 1
|
||||
translateX.value = withSpring(0, gentleSpringPreset)
|
||||
translateY.value = withSpring(0, gentleSpringPreset)
|
||||
savedTranslateX.value = 0
|
||||
savedTranslateY.value = 0
|
||||
} else {
|
||||
// If current scale is 1, zoom to 1.5x at double tap location
|
||||
const targetScale = 1.5
|
||||
scale.value = withSpring(targetScale, {
|
||||
damping: 15,
|
||||
stiffness: 150,
|
||||
})
|
||||
savedScale.value = targetScale
|
||||
|
||||
// Calculate offset from double tap point to center
|
||||
|
||||
const centerX = width / 2
|
||||
const centerY = height / 2
|
||||
|
||||
// Calculate required offset to make double tap point the new center
|
||||
const targetX = (centerX - e.absoluteX) * targetScale
|
||||
const targetY = (centerY - e.absoluteY) * targetScale
|
||||
|
||||
translateX.value = withSpring(targetX, gentleSpringPreset)
|
||||
translateY.value = withSpring(targetY, gentleSpringPreset)
|
||||
savedTranslateX.value = targetX
|
||||
savedTranslateY.value = targetY
|
||||
}
|
||||
}),
|
||||
[height, savedScale, savedTranslateX, savedTranslateY, scale, translateX, translateY, width],
|
||||
)
|
||||
const singleTapGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Tap()
|
||||
.numberOfTaps(1)
|
||||
.runOnJS(true)
|
||||
.onStart(() => {
|
||||
fadeOutCloseAnimation()
|
||||
})
|
||||
.requireExternalGestureToFail(pinchGesture, doubleTapGesture),
|
||||
[doubleTapGesture, fadeOutCloseAnimation, pinchGesture],
|
||||
)
|
||||
|
||||
const composed = useMemo(
|
||||
() =>
|
||||
Gesture.Simultaneous(
|
||||
Gesture.Race(doubleTapGesture, panGesture, singleTapGesture),
|
||||
pinchGesture,
|
||||
),
|
||||
[doubleTapGesture, panGesture, pinchGesture, singleTapGesture],
|
||||
)
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => ({
|
||||
transform: [
|
||||
{ translateX: translateX.value },
|
||||
{ translateY: translateY.value },
|
||||
{ scale: scale.value },
|
||||
],
|
||||
}))
|
||||
|
||||
const modalStyle = useAnimatedStyle(() => ({
|
||||
opacity: opacity.value,
|
||||
}))
|
||||
|
||||
const overlayStyle = useAnimatedStyle(() => ({
|
||||
backgroundColor: "black",
|
||||
opacity: overlayOpacity.value,
|
||||
}))
|
||||
|
||||
useEffect(() => {
|
||||
let timer: NodeJS.Timeout | null = null
|
||||
if (!previewModalOpen) {
|
||||
timer = setTimeout(() => {
|
||||
resetValues()
|
||||
}, 300)
|
||||
}
|
||||
return () => {
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
}
|
||||
}, [previewModalOpen])
|
||||
|
||||
const resetValues = () => {
|
||||
"worklet"
|
||||
layoutScale.value = 1
|
||||
layoutTransformX.value = 0
|
||||
layoutTransformY.value = 0
|
||||
scale.value = 1
|
||||
savedScale.value = 1
|
||||
translateX.value = 0
|
||||
translateY.value = 0
|
||||
savedTranslateX.value = 0
|
||||
savedTranslateY.value = 0
|
||||
opacity.value = 0
|
||||
isClosing.value = false
|
||||
overlayOpacity.value = 0
|
||||
}
|
||||
|
||||
const openPreview = useCallback(
|
||||
(params: OpenPreviewParams) => {
|
||||
setCurrentState(params.images)
|
||||
setCurrentIndex(params.initialIndex || 0)
|
||||
setImageRef(params.imageRef.current)
|
||||
setAccessoriesElement(params.accessoriesElement)
|
||||
params.imageRef.current?.measureInWindow((pageX, pageY, w1, h1) => {
|
||||
setPreviewModalOpen(true)
|
||||
|
||||
overlayOpacity.value = 0
|
||||
requestAnimationFrame(() => {
|
||||
overlayOpacity.value = withSpring(0.9, gentleSpringPreset)
|
||||
})
|
||||
|
||||
const { width: w2, height: screenHeight } = Dimensions.get("window")
|
||||
|
||||
const scale = w2 / w1
|
||||
|
||||
const x1 = pageX + w1 / 2
|
||||
const y1 = pageY + h1 / 2
|
||||
|
||||
const x2 = w2 / 2
|
||||
const y2 = screenHeight / 2
|
||||
|
||||
const xDelta = (x1 - x2) * scale
|
||||
const yDelta = (y1 - y2) * scale
|
||||
|
||||
layoutScale.value = 1 / scale
|
||||
layoutTransformX.value = xDelta
|
||||
layoutTransformY.value = yDelta
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
layoutScale.value = withSpring(1, gentleSpringPreset)
|
||||
layoutTransformX.value = withSpring(0, gentleSpringPreset)
|
||||
layoutTransformY.value = withSpring(0, gentleSpringPreset)
|
||||
opacity.value = withSpring(1)
|
||||
})
|
||||
})
|
||||
},
|
||||
[layoutScale, layoutTransformX, layoutTransformY, opacity, overlayOpacity],
|
||||
)
|
||||
const ctxValue = useMemo(() => ({ openPreview }), [openPreview])
|
||||
return (
|
||||
<PreviewImageContext.Provider value={ctxValue}>
|
||||
{children}
|
||||
{currentState?.[currentIndex] && (
|
||||
<Modal transparent visible={previewModalOpen}>
|
||||
<PortalHost>
|
||||
<Animated.View style={overlayStyle} className="absolute inset-0" />
|
||||
<Animated.View style={modalStyle} className="w-full flex-1">
|
||||
<GestureHandlerRootView className="w-full flex-1">
|
||||
<View className="flex-1 items-center justify-center">
|
||||
<Pressable
|
||||
className="top-safe-offset-2 absolute right-2"
|
||||
onPress={fadeOutCloseAnimation}
|
||||
>
|
||||
<CloseCuteReIcon color="#fff" />
|
||||
</Pressable>
|
||||
<GestureDetector gesture={composed}>
|
||||
<Animated.View style={animatedStyle}>
|
||||
<Animated.View
|
||||
style={{
|
||||
transform: [
|
||||
{
|
||||
scale: layoutScale,
|
||||
},
|
||||
{
|
||||
translateX: layoutTransformX,
|
||||
},
|
||||
{
|
||||
translateY: layoutTransformY,
|
||||
},
|
||||
],
|
||||
}}
|
||||
>
|
||||
<ImageContextMenu imageUrl={currentState[currentIndex].source?.uri}>
|
||||
<Image {...currentState[currentIndex]} className="w-full" />
|
||||
</ImageContextMenu>
|
||||
</Animated.View>
|
||||
</Animated.View>
|
||||
</GestureDetector>
|
||||
</View>
|
||||
</GestureHandlerRootView>
|
||||
{accessoriesElement}
|
||||
</Animated.View>
|
||||
</PortalHost>
|
||||
</Modal>
|
||||
)}
|
||||
</PreviewImageContext.Provider>
|
||||
)
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
|
||||
import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime"
|
||||
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
|
||||
import { Galeria } from "@/src/components/ui/image/galeria"
|
||||
import { ProxiedImage } from "@/src/components/ui/image/ProxiedImage"
|
||||
import { Image } from "@/src/components/ui/image/Image"
|
||||
import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
|
||||
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
|
||||
import { gentleSpringPreset } from "@/src/constants/spring"
|
||||
@@ -110,19 +110,18 @@ export function EntrySocialItem({ entryId }: { entryId: string }) {
|
||||
<Galeria urls={memoedMediaUrlList}>
|
||||
{media.map((image, index) => {
|
||||
return (
|
||||
<Pressable key={image.url}>
|
||||
<Pressable key={`${entryId}-${image.url}`}>
|
||||
<Galeria.Image index={index}>
|
||||
<ProxiedImage
|
||||
<Image
|
||||
proxy={{
|
||||
width: 80,
|
||||
height: 80,
|
||||
}}
|
||||
source={{ uri: image.url }}
|
||||
transition={500}
|
||||
placeholder={{ blurhash: image.blurhash }}
|
||||
className="bg-system-fill ml-2 size-20 rounded-md"
|
||||
blurhash={image.blurhash}
|
||||
className="border-secondary-system-background ml-2 h-20 rounded-md border"
|
||||
contentFit="cover"
|
||||
recyclingKey={image.url}
|
||||
aspectRatio={image.width && image.height ? image.width / image.height : 1}
|
||||
/>
|
||||
</Galeria.Image>
|
||||
</Pressable>
|
||||
|
||||
@@ -12,7 +12,6 @@ import { KeyboardProvider } from "react-native-keyboard-controller"
|
||||
import { RootSiblingParent } from "react-native-root-siblings"
|
||||
import { SheetProvider } from "react-native-sheet-transitions"
|
||||
|
||||
import { PreviewImageProvider } from "../components/ui/image/PreviewPageProvider"
|
||||
import { PortalHost } from "../components/ui/portal"
|
||||
import { sqlite } from "../database"
|
||||
import { queryClient } from "../lib/query-client"
|
||||
@@ -36,11 +35,9 @@ export const RootProviders = ({ children }: { children: ReactNode }) => {
|
||||
<GestureHandlerRootView>
|
||||
<SheetProvider>
|
||||
<ActionSheetProvider>
|
||||
<PreviewImageProvider>
|
||||
<RootSiblingParent>
|
||||
<PortalHost>{children}</PortalHost>
|
||||
</RootSiblingParent>
|
||||
</PreviewImageProvider>
|
||||
<RootSiblingParent>
|
||||
<PortalHost>{children}</PortalHost>
|
||||
</RootSiblingParent>
|
||||
</ActionSheetProvider>
|
||||
</SheetProvider>
|
||||
</GestureHandlerRootView>
|
||||
|
||||
Reference in New Issue
Block a user