Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

at natb/update-docs-rtmp 52 lines 1.4 kB view raw
1import { Link, useNavigation } from "@react-navigation/native"; 2import { NavigationProp, ParamListBase } from "@react-navigation/native"; 3import usePlatform from "hooks/usePlatform"; 4import { Pressable, StyleProp, ViewStyle } from "react-native"; 5import Loading from "./loading/loading"; 6import { useEffect } from "react"; 7 8export type LinkParams = { screen: string; params?: Record<string, string> }; 9 10// Web and native have some disagreements about link styling 11// so we have a custom component that handles that 12export default function AQLink({ 13 children, 14 to, 15 style, 16}: { 17 children: React.ReactNode; 18 to: LinkParams; 19 style?: StyleProp<ViewStyle>; 20}) { 21 const { isWeb } = usePlatform(); 22 const navigation = useNavigation<NavigationProp<ParamListBase>>(); 23 const baseStyle: StyleProp<ViewStyle> = { 24 display: "flex", 25 }; 26 27 if (isWeb) { 28 return ( 29 <Link style={[baseStyle, style]} to={to as any}> 30 {children} 31 </Link> 32 ); 33 } 34 35 return ( 36 <Pressable 37 style={[baseStyle, style]} 38 onPress={() => navigation.navigate(to.screen, to.params)} 39 > 40 {children} 41 </Pressable> 42 ); 43} 44 45export function Redirect({ to }: { to: LinkParams }) { 46 const navigation = useNavigation<NavigationProp<ParamListBase>>(); 47 useEffect(() => { 48 console.log("redirecting to", to); 49 navigation.navigate(to.screen, to.params); 50 }, []); 51 return <Loading />; 52}