Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928import {useCallback, useMemo, useState} from 'react'import { type GestureResponderEvent, ScrollView, StyleSheet, View,} from 'react-native'import {useSafeAreaInsets} from 'react-native-safe-area-context'import {PlatformInfo} from '@bsky.app/expo-bluesky-swiss-army'import {plural} from '@lingui/core/macro'import {Trans, useLingui} from '@lingui/react/macro'import {useNavigation, useNavigationState} from '@react-navigation/native'
import {useBrand} from '#/lib/community/BrandContext'import {UNREAD_NOTIFICATION_CAP} from '#/lib/constants'import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'import {useOpenComposer} from '#/lib/hooks/useOpenComposer'import { getCurrentRoute, getTabState, isCurrentProfileRoute, isTab, TabState,} from '#/lib/routes/helpers'import {makeProfileLink} from '#/lib/routes/links'import {type SidebarTab} from '#/lib/routes/tab-to-nav-item'import { type CommonNavigatorParams, type NavigationProp,} from '#/lib/routes/types'import {sanitizeDisplayName} from '#/lib/strings/display-names'import {isInvalidHandle, sanitizeHandle} from '#/lib/strings/handles'import {emitSoftReset} from '#/state/events'import {useHomeBadge} from '#/state/home-badge'import {usePinnedFeedsInfos} from '#/state/queries/feed'import {useFetchHandle} from '#/state/queries/handle'import {useUnreadMessageCount} from '#/state/queries/messages/list-conversations'import {useModerationInboxUnreadCountQuery} from '#/state/queries/moderation-inbox'import {useUnreadNotifications} from '#/state/queries/notifications/unread'import {type FeedDescriptor} from '#/state/queries/post-feed'import {useProfilesQuery} from '#/state/queries/profile'import {type SessionAccount, useSession, useSessionApi} from '#/state/session'import {useLoggedOutViewControls} from '#/state/shell/logged-out'import {useSelectedFeed} from '#/state/shell/selected-feed'import {useCloseAllActiveElements} from '#/state/util'import {LoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'import {PressableWithHover} from '#/view/com/util/PressableWithHover'import {UserAvatar} from '#/view/com/util/UserAvatar'import {NavSignupCard} from '#/view/shell/NavSignupCard'import { atoms as a, native, tokens, useBreakpoints, useLayoutBreakpoints, useTheme, web,} from '#/alf'import {BetaTag} from '#/components/BetaTag'import {Button, ButtonIcon, ButtonText} from '#/components/Button'import {type DialogControlProps} from '#/components/Dialog'import {ArrowBoxLeft_Stroke2_Corner0_Rounded as LeaveIcon} from '#/components/icons/Arrow'import { Bell_Filled_Corner0_Rounded as BellFilledIcon, Bell_Stroke2_Corner0_Rounded as BellIcon,} from '#/components/icons/Bell'import { Bookmark_Filled_Corner0_Rounded as BookmarkFilledIcon, Bookmark_Stroke2_Corner0_Rounded as BookmarkIcon,} from '#/components/icons/Bookmark'import { BulletList_Filled_Corner0_Rounded as ListFilledIcon, BulletList_Stroke2_Corner0_Rounded as ListIcon,} from '#/components/icons/BulletList'import {type Props as SVGIconProps} from '#/components/icons/common'import {DotGrid3x1_Stroke2_Corner0_Rounded as EllipsisIcon} from '#/components/icons/DotGrid'import {Earth_Stroke2_Corner0_Rounded as EarthIcon} from '#/components/icons/Earth'import {EditBig_Stroke2_Corner2_Rounded as EditBigIcon} from '#/components/icons/EditBig'import { Hashtag_Filled_Corner0_Rounded as HashtagFilledIcon, Hashtag_Stroke2_Corner0_Rounded as HashtagIcon,} from '#/components/icons/Hashtag'import { Heart2_Filled_Stroke2_Corner0_Rounded as HeartFilledIcon, Heart2_Stroke2_Corner0_Rounded as HeartIcon,} from '#/components/icons/Heart2'import { HomeOpen_Filled_Corner0_Rounded as HomeFilledIcon, HomeOpen_Stroke2_Corner0_Rounded as HomeIcon,} from '#/components/icons/Home'import { MagnifyingGlass_Filled_Stroke2_Corner0_Rounded as MagnifyingGlassFilledIcon, MagnifyingGlass_Stroke2_Corner0_Rounded as MagnifyingGlassIcon,} from '#/components/icons/MagnifyingGlass'import { Message_Stroke2_Corner0_Rounded as MessageIcon, Message_Stroke2_Corner0_Rounded_Filled as MessageFilledIcon,} from '#/components/icons/Message'import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'import { SettingsGear2_Filled_Corner0_Rounded as SettingsFilledIcon, SettingsGear2_Stroke2_Corner0_Rounded as SettingsIcon,} from '#/components/icons/Settings'import { UserCircle_Filled_Corner0_Rounded as UserCircleFilledIcon, UserCircle_Stroke2_Corner0_Rounded as UserCircleIcon,} from '#/components/icons/UserCircle'import { CENTER_COLUMN_OFFSET, CENTER_COLUMN_WIDTH,} from '#/components/Layout/const'import * as Menu from '#/components/Menu'import * as Prompt from '#/components/Prompt'import {Text} from '#/components/Typography'import {useAnalytics} from '#/analytics'import {type Events} from '#/analytics/metrics/types'import {IS_IOS, IS_NATIVE, IS_WEB} from '#/env'import {isFollowingV2HomeDotEnabled} from '#/features/followingV2/eligibility'import {useActorStatus} from '#/features/liveNow'import {type app} from '#/lexicons'import {router} from '#/routes'import {getComposeButtonLayout} from './composeButtonLayout'
const LARGE_ELEMENT_SIZE = 48const NAV_ICON_WIDTH = 28const NAV_ITEM_TO_TAB: Partial< Record<Events['nav:click']['item'], SidebarTab>> = { home: 'Home', search: 'Search', chat: 'Messages', notifications: 'Notifications', profile: 'MyProfile', atmosphere: 'Atmosphere', feeds: 'Feeds', lists: 'Lists', saved: 'Bookmarks', settings: 'Settings',}
export const LEFT_NAV_STANDARD_WIDTH = 240export const LEFT_NAV_MINIMAL_WIDTH = 80const LEFT_NAV_PWI_WIDTH = 245
function ProfileCard({minimal}: {minimal: boolean}) { const {currentAccount, accounts} = useSession() const {logoutEveryAccount} = useSessionApi() const {isLoading, data} = useProfilesQuery({ handles: accounts.map(acc => acc.did), }) const profiles = data?.profiles const signOutPromptControl = Prompt.usePromptControl() const {t: l} = useLingui() const t = useTheme()
const profile = profiles?.find(p => p.did === currentAccount!.did) const otherAccounts = accounts .filter(acc => acc.did !== currentAccount!.did) .map(account => ({ account, profile: profiles?.find(p => p.did === account.did), }))
const {isActive: live} = useActorStatus(profile)
return ( <View style={[a.pb_md, !minimal && [a.w_full, a.align_start]]}> {!isLoading && profile ? ( <Menu.Root> <Menu.Trigger label={l`Switch accounts`}> {({props, state, control}) => { const active = state.hovered || state.focused || control.isOpen return ( <Button label={props.accessibilityLabel} {...props} style={[ a.w_full, a.transition_color, active ? t.atoms.bg_contrast_25 : a.transition_delay_50ms, a.rounded_full, a.justify_between, a.align_center, a.flex_row, {gap: 6}, !minimal && [a.pl_lg, a.pr_md], ]}> <View style={[ !PlatformInfo.getIsReducedMotionEnabled() && [ a.transition_transform, {transitionDuration: '250ms'}, !active && a.transition_delay_50ms, ], a.relative, a.z_10, active && { transform: [ {scale: !minimal ? 2 / 3 : 0.8}, {translateX: !minimal ? -22 : 0}, ], }, ]}> <UserAvatar avatar={profile.avatar} size={LARGE_ELEMENT_SIZE} type={profile?.associated?.labeler ? 'labeler' : 'user'} live={live} /> </View> {!minimal && ( <> <View style={[ a.flex_1, a.transition_opacity, !active && a.transition_delay_50ms, { marginLeft: tokens.space.xl * -1, opacity: active ? 1 : 0, }, ]}> <Text emoji style={[a.font_bold, a.text_sm, a.leading_snug]} numberOfLines={1}> {sanitizeDisplayName( profile.displayName || profile.handle, )} </Text> <Text style={[ a.text_xs, a.leading_snug, t.atoms.text_contrast_medium, ]} numberOfLines={1}> {sanitizeHandle(profile.handle, '@')} </Text> </View> <EllipsisIcon aria-hidden={true} style={[ t.atoms.text_contrast_medium, a.transition_opacity, {opacity: active ? 1 : 0}, ]} size="sm" /> </> )} </Button> ) }} </Menu.Trigger> <SwitchMenuItems accounts={otherAccounts} signOutPromptControl={signOutPromptControl} /> </Menu.Root> ) : ( <LoadingPlaceholder width={LARGE_ELEMENT_SIZE} height={LARGE_ELEMENT_SIZE} style={[a.rounded_full, !minimal && a.ml_lg]} /> )} <Prompt.Basic control={signOutPromptControl} title={l`Sign out?`} description={l`You will be signed out of all your accounts.`} onConfirm={() => logoutEveryAccount('Settings')} confirmButtonCta={l`Sign out`} cancelButtonCta={l`Cancel`} confirmButtonColor="negative" /> </View> )}
function SwitchMenuItems({ accounts, signOutPromptControl,}: { accounts: | { account: SessionAccount profile?: app.bsky.actor.defs.ProfileViewDetailed }[] | undefined signOutPromptControl: DialogControlProps}) { const {t: l} = useLingui() const {currentAccount} = useSession() const {onPressSwitchAccount, pendingDid} = useAccountSwitcher() const navigation = useNavigation<NavigationProp>() const {control} = Menu.useMenuContext() const currentRouteInfo = useNavigationState(state => { if (!state) { return {name: 'Home'} } return getCurrentRoute(state) }) const profileLink = currentAccount ? makeProfileLink(currentAccount) : '/' const isCurrent = isCurrentProfileRoute({ routeName: currentRouteInfo.name, profileName: currentRouteInfo.name === 'Profile' ? (currentRouteInfo.params as CommonNavigatorParams['Profile']).name : undefined, currentHandle: currentAccount?.handle, }) const {setShowLoggedOut} = useLoggedOutViewControls() const closeEverything = useCloseAllActiveElements()
const onAddAnotherAccount = () => { setShowLoggedOut(true) closeEverything() }
const onProfilePress = (e: GestureResponderEvent) => { if (IS_WEB) { const mouseEvent = e as unknown as React.MouseEvent< HTMLAnchorElement, MouseEvent > if (mouseEvent.ctrlKey || mouseEvent.metaKey || mouseEvent.altKey) { return } mouseEvent.preventDefault() }
const onNavigate = () => { if (isCurrent) { emitSoftReset() } else { const [screen, params] = router.matchPath(profileLink) // @ts-expect-error TODO: type matchPath well enough that it can be plugged into navigation.navigate directly navigation.navigate(screen, params, {pop: true}) } }
if (IS_IOS) { onNavigate() } else if (IS_NATIVE) { control.close() onNavigate() } else { control.close(onNavigate) } }
return ( <Menu.Outer> {accounts && accounts.length > 0 && ( <> <Menu.LabelText> <Trans>Switch account</Trans> </Menu.LabelText> <Menu.Group> {/* Native groups require Menu.Item as a direct child. */} {accounts.map(({account, profile}) => ( <Menu.Item key={account.did} disabled={!!pendingDid} style={[a.gap_sm, {minWidth: 150}]} label={l`Switch to ${sanitizeHandle( profile?.handle ?? account.handle, '@', )}`} onPress={() => void onPressSwitchAccount(account, 'SwitchAccount') }> <SwitchMenuItemAvatar profile={profile} /> <Menu.ItemText> {sanitizeHandle(profile?.handle ?? account.handle, '@')} </Menu.ItemText> </Menu.Item> ))} </Menu.Group> <Menu.Divider /> </> )} <Menu.Group> <Menu.Item label={l`Go to profile`} onPress={onProfilePress} // @ts-expect-error href is web-only -prf href={profileLink}> <Menu.ItemIcon icon={UserCircleIcon} /> <Menu.ItemText> <Trans>Go to profile</Trans> </Menu.ItemText> </Menu.Item> <Menu.Item label={l`Add another account`} onPress={onAddAnotherAccount}> <Menu.ItemIcon icon={PlusIcon} /> <Menu.ItemText> <Trans>Add another account</Trans> </Menu.ItemText> </Menu.Item> <Menu.Item label={l`Sign out`} onPress={signOutPromptControl.open}> <Menu.ItemIcon icon={LeaveIcon} /> <Menu.ItemText> <Trans>Sign out</Trans> </Menu.ItemText> </Menu.Item> </Menu.Group> </Menu.Outer> )}
function SwitchMenuItemAvatar({ profile,}: { profile: app.bsky.actor.defs.ProfileViewDetailed | undefined}) { const {isActive: live} = useActorStatus(profile)
return ( <View> <UserAvatar avatar={profile?.avatar} size={20} type={profile?.associated?.labeler ? 'labeler' : 'user'} live={live} hideLiveBadge /> </View> )}
interface NavItemProps { beta?: boolean count?: string hasNew?: boolean href: string icons: { inactive: React.ComponentType<SVGIconProps> active: React.ComponentType<SVGIconProps> } label: string minimal: boolean navItem: Events['nav:click']['item'] onNavigateTab?: (tab: SidebarTab) => void}function NavItem({ beta, count, hasNew, href, icons, label, minimal, navItem, onNavigateTab,}: NavItemProps) { const t = useTheme() const {t: l} = useLingui() const accessibilityLabel = beta ? l`${label}, Beta` : label const ax = useAnalytics() const {currentAccount} = useSession()
const [pathName] = useMemo(() => router.matchPath(href), [href]) const navigationState = useNavigationState(state => state) const currentRouteInfo = getCurrentRoute(navigationState) const tab = NAV_ITEM_TO_TAB[navItem] const isCurrent = navItem === 'profile' ? isCurrentProfileRoute({ routeName: currentRouteInfo.name, profileName: currentRouteInfo.name === 'Profile' ? (currentRouteInfo.params as CommonNavigatorParams['Profile']) .name : undefined, currentHandle: currentAccount?.handle, }) : isTab(currentRouteInfo.name, pathName) const isSelected = IS_NATIVE && tab ? getTabState(navigationState, tab) !== TabState.Outside : isCurrent const isRelated = currentRouteInfo.name.startsWith(pathName) const navigation = useNavigation<NavigationProp>() const onPressWrapped = useCallback( (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { ax.metric('nav:click', {item: navItem, surface: 'leftNav'}) if (e.ctrlKey || e.metaKey || e.altKey) { return } e.preventDefault?.() if (tab && onNavigateTab) { onNavigateTab(tab) return } if (isCurrent) { emitSoftReset() } else { const [screen, params] = router.matchPath(href) // @ts-expect-error TODO: type matchPath well enough that it can be plugged into navigation.navigate directly navigation.navigate(screen, params, {pop: true}) } }, [navigation, href, isCurrent, ax, navItem, onNavigateTab, tab], )
const Icon = isSelected || (!IS_NATIVE && isRelated) ? icons.active : icons.inactive
return ( <PressableWithHover style={[ a.flex_row, a.align_center, a.p_md, a.rounded_full, a.gap_sm, a.outline_inset_1, a.transition_color, ]} hoverStyle={t.atoms.bg_contrast_25} // @ts-expect-error the function signature differs on web -prf onPress={onPressWrapped} href={href} dataSet={{noUnderline: 1}} role="link" accessibilityLabel={accessibilityLabel} accessibilityState={IS_NATIVE ? {selected: isSelected} : undefined} accessibilityHint=""> <View style={[ a.align_center, a.justify_center, { width: 24, height: 24, }, a.z_10, ]}> <Icon aria-hidden={true} width={NAV_ICON_WIDTH} style={t.atoms.text} /> {typeof count === 'string' && count ? ( <View style={[ a.absolute, a.inset_0, {right: -20}, // more breathing room ]}> <Text accessibilityLabel={l`${plural(count, { one: '# unread item', other: '# unread items', })}`} accessibilityHint="" accessible={true} numberOfLines={1} style={[ a.absolute, a.text_xs, a.font_semi_bold, a.rounded_full, a.text_center, a.leading_tight, a.z_20, { top: '-10%', left: count.length === 1 ? 12 : 8, backgroundColor: t.palette.primary_500, color: t.palette.white, lineHeight: a.text_sm.fontSize, paddingHorizontal: 4, paddingVertical: 1, minWidth: 16, }, ]}> {count} </Text> </View> ) : hasNew ? ( <View style={[ a.absolute, a.rounded_full, a.z_20, { backgroundColor: t.palette.primary_500, width: 8, height: 8, right: -2, top: -4, }, ]} /> ) : null} </View> {!minimal && ( <View style={[a.flex_row, a.align_center, a.gap_sm]}> <Text style={[a.text_xl, isSelected ? a.font_bold : a.font_normal]}> {label} </Text> {beta && <BetaTag />} </View> )} </PressableWithHover> )}
function ComposeBtn({minimal}: {minimal: boolean}) { const {currentAccount} = useSession() const {getState} = useNavigation() const currentRoute = useNavigationState(state => state ? getCurrentRoute(state) : {name: 'Home'}, ) const selectedFeed = useSelectedFeed() const {data: pinnedFeedInfos} = usePinnedFeedsInfos() const contextualFeed = currentRoute.name === 'Home' ? (selectedFeed ?? pinnedFeedInfos?.[0]?.feedDescriptor) : currentRoute.name === 'CustomFeed' ? (( currentRoute.params as CommonNavigatorParams['CustomFeed'] | undefined )?.resolvedFeed as FeedDescriptor | undefined) : undefined const {openComposer} = useOpenComposer(contextualFeed) const {t: l} = useLingui() const brand = useBrand() const {leftNavMinimal} = useLayoutBreakpoints() const [isFetchingHandle, setIsFetchingHandle] = useState(false) const fetchHandle = useFetchHandle()
const getProfileHandle = async () => { const routes = getState()?.routes const currentRoute = routes?.[routes?.length - 1]
if (currentRoute?.name === 'Profile') { let handle: string | undefined = ( currentRoute.params as CommonNavigatorParams['Profile'] ).name
if (handle.startsWith('did:')) { try { setIsFetchingHandle(true) handle = await fetchHandle(handle) } catch (e) { handle = undefined } setIsFetchingHandle(false) }
if ( !handle || handle === currentAccount?.handle || isInvalidHandle(handle) ) return undefined
return handle }
return undefined }
const onPressCompose = async () => openComposer({mention: await getProfileHandle(), logContext: 'Fab'})
const layout = getComposeButtonLayout({minimal, isNative: IS_NATIVE})
return ( <View style={layout.container}> <Button disabled={isFetchingHandle} label={l`Compose new post`} onPress={() => void onPressCompose()} size="large" color="primary" style={layout.button}> <ButtonIcon icon={EditBigIcon} size={minimal ? 'lg' : 'sm'} /> {!minimal && ( <ButtonText> {leftNavMinimal ? ( <Trans context="action">New post</Trans> ) : ( `New ${brand.messages.postButtonLabel}` )} </ButtonText> )} </Button> </View> )}
export function DesktopLeftNav({ routeName, onNavigateTab,}: { routeName: string onNavigateTab?: (tab: SidebarTab) => void}) { const {hasSession, currentAccount} = useSession() const {i18n, t: l} = useLingui() const ax = useAnalytics() const {gtMobile} = useBreakpoints()
// splitview uses the minimal variant of the leftnav. unfortunately there's no easy // way to thread this data through because of the view hierarchy, so just check the route name const isMessagesRelatedScreen = !IS_NATIVE && routeName.startsWith('Messages') const {leftNavMinimal: leftNavMinimalBreakpoint, centerColumnOffset} = useLayoutBreakpoints() const numUnreadNotifications = useUnreadNotifications() const numUnreadMessages = useUnreadMessageCount() const isModerationInboxEnabled = ax.features.enabled( ax.features.ModerationInboxEnable, ) const moderationInboxUnreadCountQuery = useModerationInboxUnreadCountQuery( isModerationInboxEnabled, ) const moderationInboxUnreadCount = isModerationInboxEnabled ? (moderationInboxUnreadCountQuery.data?.unreadCounts.total ?? 0) : 0 const numUnreadModerationInbox = moderationInboxUnreadCount > 0 ? moderationInboxUnreadCount >= UNREAD_NOTIFICATION_CAP ? l({ message: `${i18n.number(UNREAD_NOTIFICATION_CAP - 1)}+`, comment: 'Displayed when the number of notifications exceeds the cap – for example, 99+', }) : i18n.number(moderationInboxUnreadCount) : undefined const hasHomeBadge = useHomeBadge() const isAtmosphereExploreEnabled = ax.features.enabled( ax.features.AtmosphereScreenEnable, ) const insets = useSafeAreaInsets()
const leftNavMinimal = isMessagesRelatedScreen || leftNavMinimalBreakpoint
if (!hasSession && !gtMobile) { return null }
const content = ( <> {hasSession ? ( <ProfileCard minimal={leftNavMinimal} /> ) : !leftNavMinimal ? ( <View style={[a.pt_xl]}> <NavSignupCard /> </View> ) : null} {hasSession && ( <> <NavItem label={l`Home`} href="/" navItem="home" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} hasNew={hasHomeBadge && isFollowingV2HomeDotEnabled(ax)} icons={{ inactive: HomeIcon, active: HomeFilledIcon, }} /> <NavItem label={l`Explore`} href="/search" navItem="search" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} icons={{ inactive: MagnifyingGlassIcon, active: MagnifyingGlassFilledIcon, }} /> <NavItem label={l`Notifications`} href="/notifications" navItem="notifications" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} count={numUnreadNotifications} icons={{inactive: BellIcon, active: BellFilledIcon}} /> {isAtmosphereExploreEnabled && ( <NavItem label={l`Atmosphere`} href="/atmosphere" navItem="atmosphere" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} beta icons={{ inactive: EarthIcon, active: EarthIcon, }} /> )} <NavItem label={l`Chat`} href="/messages" navItem="chat" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} count={numUnreadMessages.numUnread} hasNew={numUnreadMessages.hasNew} icons={{inactive: MessageIcon, active: MessageFilledIcon}} /> <NavItem label={l`Feeds`} href="/feeds" navItem="feeds" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} icons={{inactive: HashtagIcon, active: HashtagFilledIcon}} /> <NavItem label={l`Lists`} href="/lists" navItem="lists" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} icons={{inactive: ListIcon, active: ListFilledIcon}} /> <NavItem label={l({message: 'Saved', context: 'link to bookmarks screen'})} href="/saved" navItem="saved" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} icons={{inactive: BookmarkIcon, active: BookmarkFilledIcon}} /> <NavItem label={l`Profile`} href={makeProfileLink(currentAccount!)} navItem="profile" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} icons={{inactive: UserCircleIcon, active: UserCircleFilledIcon}} /> <NavItem label={l`Settings`} href="/settings" navItem="settings" onNavigateTab={onNavigateTab} minimal={leftNavMinimal} count={numUnreadModerationInbox} icons={{inactive: SettingsIcon, active: SettingsFilledIcon}} /> <NavItem label={l`Support`} href="/support" navItem="support" minimal={leftNavMinimal} icons={{ inactive: HeartIcon, active: HeartFilledIcon, }} />
<ComposeBtn minimal={leftNavMinimal} /> </> )} </> )
return ( <View role="navigation" pointerEvents={IS_NATIVE ? 'box-none' : undefined} style={[ a.fixed, a.top_0, web(a.p_lg), styles.leftNav, native(a.bottom_0), !hasSession && !leftNavMinimal && {width: LEFT_NAV_PWI_WIDTH}, leftNavMinimal && [ {width: LEFT_NAV_MINIMAL_WIDTH}, !IS_NATIVE && a.h_full, a.align_center, web(a.overflow_x_hidden), ], web({maxHeight: '100vh', overflowY: 'auto', scrollbarWidth: 'thin'}), { transform: [ { translateX: -(CENTER_COLUMN_WIDTH / 2) + (centerColumnOffset ? CENTER_COLUMN_OFFSET : 0) + (!IS_NATIVE && isMessagesRelatedScreen && !leftNavMinimalBreakpoint ? LEFT_NAV_MINIMAL_WIDTH - LEFT_NAV_STANDARD_WIDTH : 0), }, {translateX: '-100%'}, ...a.scrollbar_offset.transform, ], }, ]}> {IS_NATIVE ? ( <ScrollView style={[a.flex_1, a.w_full]} contentContainerStyle={[ a.p_lg, { paddingTop: insets.top + tokens.space.lg, paddingBottom: insets.bottom + tokens.space.lg, }, ]} showsVerticalScrollIndicator={false}> {content} </ScrollView> ) : ( content )} </View> )}
const styles = StyleSheet.create({ leftNav: { left: '50%', width: LEFT_NAV_STANDARD_WIDTH, },})