From 47d2d3cbf289ebb2e893e07b5265aad8fcd64cb1 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 21 Nov 2023 16:58:13 -0600 Subject: [PWI] Shell (#1967) * Sidebars * Bottom bar * Drawer * Translate * Spacing fix * Fix responsive regression * Fix nit --- src/view/com/util/UserAvatar.tsx | 8 +- src/view/shell/Drawer.tsx | 175 ++++++++++++++------------ src/view/shell/NavSignupCard.tsx | 61 +++++++++ src/view/shell/bottom-bar/BottomBar.tsx | 133 ++++++++++---------- src/view/shell/bottom-bar/BottomBarWeb.tsx | 73 ++++++----- src/view/shell/desktop/LeftNav.tsx | 193 ++++++++++++++++------------- src/view/shell/desktop/RightNav.tsx | 49 +++++--- src/view/shell/desktop/Search.tsx | 1 - src/view/shell/index.web.tsx | 12 +- 9 files changed, 416 insertions(+), 289 deletions(-) create mode 100644 src/view/shell/NavSignupCard.tsx (limited to 'src') diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index 2012f5828..395e9eb3a 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -43,7 +43,13 @@ interface PreviewableUserAvatarProps extends BaseUserAvatarProps { const BLUR_AMOUNT = isWeb ? 5 : 100 -function DefaultAvatar({type, size}: {type: UserAvatarType; size: number}) { +export function DefaultAvatar({ + type, + size, +}: { + type: UserAvatarType + size: number +}) { if (type === 'algo') { // Font Awesome Pro 6.4.0 by @fontawesome -https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. return ( diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index 3d84c61bb..9df9b70b3 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -52,6 +52,7 @@ import {useUnreadNotifications} from '#/state/queries/notifications/unread' import {emitSoftReset} from '#/state/events' import {useInviteCodesQuery} from '#/state/queries/invites' import {RQKEY as NOTIFS_RQKEY} from '#/state/queries/notifications/feed' +import {NavSignupCard} from '#/view/shell/NavSignupCard' export function DrawerProfileCard({ account, @@ -112,7 +113,7 @@ export function DrawerContent() { const {track} = useAnalytics() const {isAtHome, isAtSearch, isAtFeeds, isAtNotifications, isAtMyProfile} = useNavigationTabState() - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const numUnreadNotifications = useUnreadNotifications() // events @@ -218,18 +219,20 @@ export function DrawerContent() { ]}> - - {currentAccount && ( + {hasSession && currentAccount ? ( + - )} - + + ) : ( + + )} - + {hasSession && } - + {hasSession && } - } - size="24" - strokeWidth={1.7} - /> - ) : ( - } - size="24" - strokeWidth={1.7} - /> - ) - } - label={_(msg`Notifications`)} - accessibilityLabel={_(msg`Notifications`)} - accessibilityHint={ - numUnreadNotifications === '' - ? '' - : `${numUnreadNotifications} unread` - } - count={numUnreadNotifications} - bold={isAtNotifications} - onPress={onPressNotifications} - /> + + {hasSession && ( + } + size="24" + strokeWidth={1.7} + /> + ) : ( + } + size="24" + strokeWidth={1.7} + /> + ) + } + label={_(msg`Notifications`)} + accessibilityLabel={_(msg`Notifications`)} + accessibilityHint={ + numUnreadNotifications === '' + ? '' + : `${numUnreadNotifications} unread` + } + count={numUnreadNotifications} + bold={isAtNotifications} + onPress={onPressNotifications} + /> + )} + - } - label={_(msg`Lists`)} - accessibilityLabel={_(msg`Lists`)} - accessibilityHint="" - onPress={onPressLists} - /> - } - label={_(msg`Moderation`)} - accessibilityLabel={_(msg`Moderation`)} - accessibilityHint="" - onPress={onPressModeration} - /> - } - size="26" - strokeWidth={1.5} - /> - ) : ( - } - size="26" - strokeWidth={1.5} - /> - ) - } - label={_(msg`Profile`)} - accessibilityLabel={_(msg`Profile`)} - accessibilityHint="" - onPress={onPressProfile} - /> - } - size="26" - strokeWidth={1.75} + + {hasSession && ( + <> + } + label={_(msg`Lists`)} + accessibilityLabel={_(msg`Lists`)} + accessibilityHint="" + onPress={onPressLists} /> - } - label={_(msg`Settings`)} - accessibilityLabel={_(msg`Settings`)} - accessibilityHint="" - onPress={onPressSettings} - /> + } + label={_(msg`Moderation`)} + accessibilityLabel={_(msg`Moderation`)} + accessibilityHint="" + onPress={onPressModeration} + /> + } + size="26" + strokeWidth={1.5} + /> + ) : ( + } + size="26" + strokeWidth={1.5} + /> + ) + } + label={_(msg`Profile`)} + accessibilityLabel={_(msg`Profile`)} + accessibilityHint="" + onPress={onPressProfile} + /> + } + size="26" + strokeWidth={1.75} + /> + } + label={_(msg`Settings`)} + accessibilityLabel={_(msg`Settings`)} + accessibilityHint="" + onPress={onPressSettings} + /> + + )} + { + closeAllActiveElements() + setShowLoggedOut(true) + }, [setShowLoggedOut, closeAllActiveElements]) + + return ( + + + + + + Sign up or sign in to join the conversation + + + + + + + + + ) +} diff --git a/src/view/shell/bottom-bar/BottomBar.tsx b/src/view/shell/bottom-bar/BottomBar.tsx index 6935953b5..dfb18cc4a 100644 --- a/src/view/shell/bottom-bar/BottomBar.tsx +++ b/src/view/shell/bottom-bar/BottomBar.tsx @@ -37,7 +37,7 @@ type TabOptions = 'Home' | 'Search' | 'Notifications' | 'MyProfile' | 'Feeds' export function BottomBar({navigation}: BottomTabBarProps) { const {openModal} = useModalControls() - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const pal = usePalette('default') const {_} = useLingui() const queryClient = useQueryClient() @@ -169,72 +169,77 @@ export function BottomBar({navigation}: BottomTabBarProps) { accessibilityLabel={_(msg`Feeds`)} accessibilityHint="" /> - - ) : ( - - ) - } - onPress={onPressNotifications} - notificationCount={numUnreadNotifications} - accessible={true} - accessibilityRole="tab" - accessibilityLabel={_(msg`Notifications`)} - accessibilityHint={ - numUnreadNotifications === '' - ? '' - : `${numUnreadNotifications} unread` - } - /> - - {isAtMyProfile ? ( - - + - - ) : ( - - + ) + } + onPress={onPressNotifications} + notificationCount={numUnreadNotifications} + accessible={true} + accessibilityRole="tab" + accessibilityLabel={_(msg`Notifications`)} + accessibilityHint={ + numUnreadNotifications === '' + ? '' + : `${numUnreadNotifications} unread` + } + /> + + {isAtMyProfile ? ( + + + + ) : ( + + + + )} - )} - - } - onPress={onPressProfile} - onLongPress={onLongPressProfile} - accessibilityRole="tab" - accessibilityLabel={_(msg`Profile`)} - accessibilityHint="" - /> + } + onPress={onPressProfile} + onLongPress={onLongPressProfile} + accessibilityRole="tab" + accessibilityLabel={_(msg`Profile`)} + accessibilityHint="" + /> + + )} ) } diff --git a/src/view/shell/bottom-bar/BottomBarWeb.tsx b/src/view/shell/bottom-bar/BottomBarWeb.tsx index 32fa1943a..8efd7b6b0 100644 --- a/src/view/shell/bottom-bar/BottomBarWeb.tsx +++ b/src/view/shell/bottom-bar/BottomBarWeb.tsx @@ -24,7 +24,7 @@ import {CommonNavigatorParams} from 'lib/routes/types' import {useSession} from '#/state/session' export function BottomBarWeb() { - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const pal = usePalette('default') const safeAreaInsets = useSafeAreaInsets() const {footerMinimalShellTransform} = useMinimalShellMode() @@ -75,39 +75,44 @@ export function BottomBarWeb() { ) }} - - {({isActive}) => { - const Icon = isActive ? BellIconSolid : BellIcon - return ( - - ) - }} - - - {({isActive}) => { - const Icon = isActive ? UserIconSolid : UserIcon - return ( - - ) - }} - + + {hasSession && ( + <> + + {({isActive}) => { + const Icon = isActive ? BellIconSolid : BellIcon + return ( + + ) + }} + + + {({isActive}) => { + const Icon = isActive ? UserIconSolid : UserIcon + return ( + + ) + }} + + + )} ) } diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index bb76ff183..a0052e0ca 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -47,6 +47,7 @@ import {useFetchHandle} from '#/state/queries/handle' import {emitSoftReset} from '#/state/events' import {useQueryClient} from '@tanstack/react-query' import {RQKEY as NOTIFS_RQKEY} from '#/state/queries/notifications/feed' +import {NavSignupCard} from '#/view/shell/NavSignupCard' function ProfileCard() { const {currentAccount} = useSession() @@ -268,7 +269,7 @@ function ComposeBtn() { } export function DesktopLeftNav() { - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const pal = usePalette('default') const {_} = useLingui() const {isDesktop, isTablet} = useWebMediaQueries() @@ -282,8 +283,16 @@ export function DesktopLeftNav() { pal.view, pal.border, ]}> - + {hasSession ? ( + + ) : isDesktop ? ( + + + + ) : null} + + } @@ -332,98 +341,104 @@ export function DesktopLeftNav() { } label={_(msg`Feeds`)} /> - - } - iconFilled={ - - } - label={_(msg`Notifications`)} - /> - - } - iconFilled={ - - } - label={_(msg`Lists`)} - /> - + + } + iconFilled={ + + } + label={_(msg`Notifications`)} /> - } - iconFilled={ - + } + iconFilled={ + + } + label={_(msg`Lists`)} /> - } - label={_(msg`Moderation`)} - /> - + } + iconFilled={ + + } + label={_(msg`Moderation`)} /> - } - iconFilled={ - + } + iconFilled={ + + } + label="Profile" /> - } - label="Profile" - /> - + } + iconFilled={ + + } + label={_(msg`Settings`)} /> - } - iconFilled={ - - } - label={_(msg`Settings`)} - /> - + + + + )} ) } diff --git a/src/view/shell/desktop/RightNav.tsx b/src/view/shell/desktop/RightNav.tsx index 51ee28418..7087a4397 100644 --- a/src/view/shell/desktop/RightNav.tsx +++ b/src/view/shell/desktop/RightNav.tsx @@ -30,9 +30,21 @@ export function DesktopRightNav() { return ( - {hasSession && } - {hasSession && } - + + + {hasSession && ( + + + + )} + + {isSandbox ? ( @@ -41,18 +53,22 @@ export function DesktopRightNav() { ) : undefined} - - -  ·  - + {hasSession && ( + <> + + +  ·  + + + )} - + + {hasSession && } ) } diff --git a/src/view/shell/desktop/Search.tsx b/src/view/shell/desktop/Search.tsx index 5033fc2d8..f899431b6 100644 --- a/src/view/shell/desktop/Search.tsx +++ b/src/view/shell/desktop/Search.tsx @@ -222,7 +222,6 @@ const styles = StyleSheet.create({ container: { position: 'relative', width: 300, - paddingBottom: 18, }, search: { paddingHorizontal: 16, diff --git a/src/view/shell/index.web.tsx b/src/view/shell/index.web.tsx index 09f8ba983..e833a08bf 100644 --- a/src/view/shell/index.web.tsx +++ b/src/view/shell/index.web.tsx @@ -21,8 +21,8 @@ import { useSetDrawerOpen, useOnboardingState, } from '#/state/shell' -import {useSession} from '#/state/session' import {useCloseAllActiveElements} from '#/state/util' +import {useLoggedOutView} from '#/state/shell/logged-out' function ShellInner() { const isDrawerOpen = useIsDrawerOpen() @@ -30,8 +30,8 @@ function ShellInner() { const onboardingState = useOnboardingState() const {isDesktop, isMobile} = useWebMediaQueries() const navigator = useNavigation() - const {hasSession} = useSession() const closeAllActiveElements = useCloseAllActiveElements() + const {showLoggedOut} = useLoggedOutView() useAuxClick() @@ -42,7 +42,7 @@ function ShellInner() { }, [navigator, closeAllActiveElements]) const showBottomBar = isMobile && !onboardingState.isActive - const showSideNavs = !isMobile && hasSession && !onboardingState.isActive + const showSideNavs = !isMobile && !onboardingState.isActive && !showLoggedOut return ( @@ -50,16 +50,22 @@ function ShellInner() { + {showSideNavs && ( <> )} + + {showBottomBar && } + + + {!isDesktop && isDrawerOpen && ( setDrawerOpen(false)} -- cgit 1.4.1