import { ActivityIndicator, Pressable, Text, View } from "react-native";
import { StatusBar } from "expo-status-bar";
import type { RootStackScreenProps } from "@/navigation/types";
import { particlePath } from "@/lib/particle-path";
import { useLiveParticle } from "@/hooks/use-particle";
import { StreamView } from "./StreamView";
export function StreamViewScreen({
navigation,
route,
}: RootStackScreenProps<"StreamView">) {
const { networkId, streamId } = route.params;
const streamPath = particlePath(networkId, [streamId]);
const { particle, isLoading, error } = useLiveParticle(streamPath);
if (isLoading && !particle) {
return (
);
}
if (error || !particle || particle.type !== "stream") {
return (
{error
? "Couldn't load this stream."
: "This stream is no longer available."}
navigation.goBack()} className="mt-6 px-4 py-2">
Close
);
}
return (
navigation.goBack()}
/>
);
}