Bluesky app fork with some witchin' additions 💫
at post-text-option 148 lines 4.3 kB view raw
1import {useEffect, useState} from 'react' 2import {View} from 'react-native' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5import {useNavigation} from '@react-navigation/core' 6 7import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants' 8import {useKawaiiMode} from '#/state/preferences/kawaii' 9import {useSession} from '#/state/session' 10import {DesktopFeeds} from '#/view/shell/desktop/Feeds' 11import {DesktopSearch} from '#/view/shell/desktop/Search' 12import {SidebarTrendingTopics} from '#/view/shell/desktop/SidebarTrendingTopics' 13import { 14 atoms as a, 15 useGutters, 16 useLayoutBreakpoints, 17 useTheme, 18 web, 19} from '#/alf' 20import {AppLanguageDropdown} from '#/components/AppLanguageDropdown' 21import {Divider} from '#/components/Divider' 22import {CENTER_COLUMN_OFFSET} from '#/components/Layout' 23import {InlineLinkText} from '#/components/Link' 24import {ProgressGuideList} from '#/components/ProgressGuide/List' 25import {Text} from '#/components/Typography' 26 27function useWebQueryParams() { 28 const navigation = useNavigation() 29 const [params, setParams] = useState<Record<string, string>>({}) 30 31 useEffect(() => { 32 return navigation.addListener('state', e => { 33 try { 34 const {state} = e.data 35 const lastRoute = state.routes[state.routes.length - 1] 36 setParams(lastRoute.params) 37 } catch (err) {} 38 }) 39 }, [navigation, setParams]) 40 41 return params 42} 43 44export function DesktopRightNav({routeName}: {routeName: string}) { 45 const t = useTheme() 46 const {_} = useLingui() 47 const {hasSession, currentAccount} = useSession() 48 const kawaii = useKawaiiMode() 49 const gutters = useGutters(['base', 0, 'base', 'wide']) 50 const isSearchScreen = routeName === 'Search' 51 const webqueryParams = useWebQueryParams() 52 const searchQuery = webqueryParams?.q 53 const showTrending = !isSearchScreen || (isSearchScreen && !!searchQuery) 54 const {rightNavVisible, centerColumnOffset, leftNavMinimal} = 55 useLayoutBreakpoints() 56 57 if (!rightNavVisible) { 58 return null 59 } 60 61 const width = centerColumnOffset ? 250 : 300 62 63 return ( 64 <View 65 style={[ 66 gutters, 67 a.gap_lg, 68 a.pr_2xs, 69 web({ 70 position: 'fixed', 71 left: '50%', 72 transform: [ 73 { 74 translateX: 300 + (centerColumnOffset ? CENTER_COLUMN_OFFSET : 0), 75 }, 76 ...a.scrollbar_offset.transform, 77 ], 78 /** 79 * Compensate for the right padding above (2px) to retain intended width. 80 */ 81 width: width + gutters.paddingLeft + 2, 82 maxHeight: '100vh', 83 }), 84 ]}> 85 {!isSearchScreen && <DesktopSearch />} 86 87 {hasSession && ( 88 <> 89 <ProgressGuideList /> 90 <DesktopFeeds /> 91 <Divider /> 92 </> 93 )} 94 95 {showTrending && <SidebarTrendingTopics />} 96 97 <Text style={[a.leading_snug, t.atoms.text_contrast_low]}> 98 {hasSession && ( 99 <> 100 <InlineLinkText 101 to={FEEDBACK_FORM_URL({ 102 email: currentAccount?.email, 103 handle: currentAccount?.handle, 104 })} 105 label={_(msg`Feedback`)}> 106 {_(msg`Feedback`)} 107 </InlineLinkText> 108 {' • '} 109 </> 110 )} 111 <InlineLinkText 112 to="https://witchsky.app/about/privacy" 113 label={_(msg`Privacy`)}> 114 {_(msg`Privacy`)} 115 </InlineLinkText> 116 {' • '} 117 <InlineLinkText 118 to="https://witchsky.app/about/tos" 119 label={_(msg`Terms`)}> 120 {_(msg`Terms`)} 121 </InlineLinkText> 122 {' • '} 123 <InlineLinkText label={_(msg`Code`)} to={HELP_DESK_URL}> 124 {_(msg`Code`)} 125 </InlineLinkText> 126 </Text> 127 128 {kawaii && ( 129 <Text style={[t.atoms.text_contrast_medium, {marginTop: 12}]}> 130 <Trans> 131 Kawaii logo by{' '} 132 <InlineLinkText 133 label={_(msg`Logo by ovvie`)} 134 to="https://ovvie.neocities.org/"> 135 ovvie 136 </InlineLinkText> 137 </Trans> 138 </Text> 139 )} 140 141 {!hasSession && leftNavMinimal && ( 142 <View style={[a.w_full, {height: 32}]}> 143 <AppLanguageDropdown /> 144 </View> 145 )} 146 </View> 147 ) 148}