mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 10:23:24 +00:00
fix: properly support opening video via url
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import { useEffect } from "react";
|
|
||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import * as Haptics from "expo-haptics";
|
import * as Haptics from "expo-haptics";
|
||||||
import * as Linking from "expo-linking";
|
import { Tabs } from "expo-router";
|
||||||
import { Tabs, useRouter } from "expo-router";
|
|
||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
import { useTheme, View } from "tamagui";
|
import { useTheme, View } from "tamagui";
|
||||||
|
|
||||||
@@ -12,23 +10,6 @@ import TabBarIcon from "~/components/TabBarIcon";
|
|||||||
|
|
||||||
export default function TabLayout() {
|
export default function TabLayout() {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleOpenURL = (event: Linking.EventType) => {
|
|
||||||
const { hostname, queryParams } = Linking.parse(event.url);
|
|
||||||
if (hostname === "media") {
|
|
||||||
router.push({
|
|
||||||
pathname: "/videoPlayer",
|
|
||||||
params: { data: JSON.stringify(queryParams) },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Linking.addEventListener("url", handleOpenURL);
|
|
||||||
}, [router]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
sceneContainerStyle={{
|
sceneContainerStyle={{
|
||||||
|
@@ -15,9 +15,16 @@ export default function VideoPlayerWrapper() {
|
|||||||
const { presentFullscreenPlayer } = usePlayer();
|
const { presentFullscreenPlayer } = usePlayer();
|
||||||
|
|
||||||
const params = useLocalSearchParams();
|
const params = useLocalSearchParams();
|
||||||
const data = params.data
|
let data;
|
||||||
? (JSON.parse(params.data as string) as Partial<ItemData>)
|
if ("data" in params) {
|
||||||
: undefined;
|
if (typeof params.data === "string") {
|
||||||
|
data = JSON.parse(params.data) as Partial<ItemData>;
|
||||||
|
} else {
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data = params as Partial<ItemData>;
|
||||||
|
}
|
||||||
const media = params.media
|
const media = params.media
|
||||||
? (JSON.parse(params.media as string) as ScrapeMedia)
|
? (JSON.parse(params.media as string) as ScrapeMedia)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
Reference in New Issue
Block a user