mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:43:25 +00:00
feat: play video via url
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { useEffect } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import { Tabs } from "expo-router";
|
||||
import * as Linking from "expo-linking";
|
||||
import { Tabs, useRouter } from "expo-router";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import { useTheme, View } from "tamagui";
|
||||
|
||||
@@ -11,20 +13,21 @@ import TabBarIcon from "~/components/TabBarIcon";
|
||||
export default function TabLayout() {
|
||||
const theme = useTheme();
|
||||
|
||||
// const url = Linking.useURL();
|
||||
// const router = useRouter();
|
||||
//
|
||||
// if (url) {
|
||||
// const { hostname, queryParams } = Linking.parse(url);
|
||||
//
|
||||
// switch (hostname) {
|
||||
// case "media":
|
||||
// return router.push({
|
||||
// pathname: "/videoPlayer",
|
||||
// params: { data: JSON.stringify(queryParams) }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
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 (
|
||||
<Tabs
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import * as Linking from "expo-linking";
|
||||
import { Link, Stack } from "expo-router";
|
||||
import { Text, View } from "tamagui";
|
||||
|
||||
export default function NotFoundScreen() {
|
||||
if (Linking.useURL()) return null;
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={{ title: "Oops!" }} />
|
||||
|
@@ -14,13 +14,21 @@ export const BackButton = () => {
|
||||
onPress={() => {
|
||||
dismissFullscreenPlayer()
|
||||
.then(() => {
|
||||
router.back();
|
||||
if (router.canGoBack()) {
|
||||
router.back();
|
||||
} else {
|
||||
router.replace("/");
|
||||
}
|
||||
return setTimeout(() => {
|
||||
Keyboard.dismiss();
|
||||
}, 100);
|
||||
})
|
||||
.catch(() => {
|
||||
router.back();
|
||||
if (router.canGoBack()) {
|
||||
router.back();
|
||||
} else {
|
||||
router.replace("/");
|
||||
}
|
||||
return setTimeout(() => {
|
||||
Keyboard.dismiss();
|
||||
}, 100);
|
||||
|
Reference in New Issue
Block a user