From 1f5dd2a1658cf4789ec2f2b2639e64e7f7378163 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:21:48 +0800 Subject: [PATCH] refactor(mobile): replace react-native-video with expo-video, hide control in list, close #3417 --- apps/mobile/app.config.ts | 1 - apps/mobile/package.json | 1 - .../components/ui/carousel/MediaCarousel.tsx | 74 ++++++++++--------- .../src/components/ui/video/VideoPlayer.tsx | 3 +- pnpm-lock.yaml | 36 +-------- 5 files changed, 43 insertions(+), 72 deletions(-) diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts index 5bfe79482..1a2bc44f0 100644 --- a/apps/mobile/app.config.ts +++ b/apps/mobile/app.config.ts @@ -158,7 +158,6 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ photosPermission: "Allow $(PRODUCT_NAME) to access your photos.", }, ], - "react-native-video", [ "expo-notifications", { diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 183d47a13..8ebc054b7 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -118,7 +118,6 @@ "react-native-svg": "15.11.2", "react-native-track-player": "4.1.1", "react-native-uikit-colors": "0.5.1", - "react-native-video": "6.13.0", "react-native-volume-manager": "2.0.8", "react-native-web": "0.20.0", "react-native-webview": "13.13.5", diff --git a/apps/mobile/src/components/ui/carousel/MediaCarousel.tsx b/apps/mobile/src/components/ui/carousel/MediaCarousel.tsx index 06dd12d45..63784963b 100644 --- a/apps/mobile/src/components/ui/carousel/MediaCarousel.tsx +++ b/apps/mobile/src/components/ui/carousel/MediaCarousel.tsx @@ -7,7 +7,6 @@ import Animated, { useSharedValue, withSpring, } from "react-native-reanimated" -import Video from "react-native-video" import { Galeria } from "@/src/components/ui/image/galeria" import type { MediaModel } from "@/src/database/schemas/types" @@ -15,6 +14,7 @@ import { EntryGridFooter } from "@/src/modules/entry-content/EntryGridFooter" import { Image } from "../image/Image" import { ImageContextMenu } from "../image/ImageContextMenu" +import { VideoPlayer } from "../video/VideoPlayer" export const MediaCarousel = ({ entryId, @@ -36,8 +36,6 @@ export const MediaCarousel = ({ // const activeIndex = useSharedValue(0) const [activeIndex, setActiveIndex] = useState(0) - const [isVideoInFullscreen, setIsVideoInFullscreen] = useState(false) - return ( { @@ -45,7 +43,17 @@ export const MediaCarousel = ({ }} > - media.map((m) => m.url), [media])}> + + media + .map((m) => + m.type === "video" ? m.preview_image_url : m.type === "photo" ? m.url : undefined, + ) + .filter(Boolean) as string[], + [media], + )} + > { setActiveIndex(Math.round(e.nativeEvent.contentOffset.x / containerWidth)) @@ -61,6 +69,25 @@ export const MediaCarousel = ({ style={{ height: containerHeight }} > {media.map((m, index) => { + const imageUrl = m.type === "video" ? m.preview_image_url : m.url + if (!imageUrl) { + return null + } + const ImageItem = ( + + + + ) + if (m.type === "photo") { return ( - - - - + + {ImageItem} ) } else if (m.type === "video") { return ( - -