From d4714baf13561236a85d44fec144f7f27a149bfd Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 27 Nov 2023 19:17:09 -0600 Subject: [PATCH] [PWI] Home (#2007) * Fix up home page * Fix spacing * Remove unused default tab * Update logic --- src/view/com/feeds/FeedPage.tsx | 25 +++++++++-- src/view/com/pager/FeedsTabBar.web.tsx | 57 +++++++++++++++++++++++- src/view/com/pager/FeedsTabBarMobile.tsx | 54 +++++++++++----------- src/view/screens/Home.tsx | 46 +++++++------------ 4 files changed, 121 insertions(+), 61 deletions(-) diff --git a/src/view/com/feeds/FeedPage.tsx b/src/view/com/feeds/FeedPage.tsx index 535306af..885cd2a1 100644 --- a/src/view/com/feeds/FeedPage.tsx +++ b/src/view/com/feeds/FeedPage.tsx @@ -195,13 +195,30 @@ export function FeedPage({ function useHeaderOffset() { const {isDesktop, isTablet} = useWebMediaQueries() const {fontScale} = useWindowDimensions() + const {hasSession} = useSession() + if (isDesktop) { return 0 } if (isTablet) { - return 50 + if (hasSession) { + return 50 + } else { + return 0 + } + } + + if (hasSession) { + const navBarPad = 16 + const navBarText = 21 * fontScale + const tabBarPad = 20 + 3 // nav bar padding + border + const tabBarText = 16 * fontScale + const magic = 7 * fontScale + return navBarPad + navBarText + tabBarPad + tabBarText + magic + } else { + const navBarPad = 16 + const navBarText = 21 * fontScale + const magic = 4 * fontScale + return navBarPad + navBarText + magic } - // default text takes 44px, plus 34px of pad - // scale the 44px by the font scale - return 34 + 44 * fontScale } diff --git a/src/view/com/pager/FeedsTabBar.web.tsx b/src/view/com/pager/FeedsTabBar.web.tsx index 29837289..a39499b2 100644 --- a/src/view/com/pager/FeedsTabBar.web.tsx +++ b/src/view/com/pager/FeedsTabBar.web.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {StyleSheet} from 'react-native' +import {View, StyleSheet} from 'react-native' import Animated from 'react-native-reanimated' import {TabBar} from 'view/com/pager/TabBar' import {RenderTabBarFnProps} from 'view/com/pager/Pager' @@ -9,20 +9,73 @@ import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile' import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' import {useShellLayout} from '#/state/shell/shell-layout' import {usePinnedFeedsInfos} from '#/state/queries/feed' +import {useSession} from '#/state/session' +import {TextLink} from '#/view/com/util/Link' +import {CenteredView} from '../util/Views' export function FeedsTabBar( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { const {isMobile, isTablet} = useWebMediaQueries() + const {hasSession} = useSession() + if (isMobile) { return } else if (isTablet) { - return + if (hasSession) { + return + } else { + return + } } else { return null } } +function FeedsTabBarPublic() { + const pal = usePalette('default') + const {isSandbox} = useSession() + + return ( + + + + {isSandbox ? 'SANDBOX' : 'Bluesky'}{' '} + {/*hasNew && ( + + )*/} + + } + // onPress={emitSoftReset} + /> + + + ) +} + function FeedsTabBarTablet( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { diff --git a/src/view/com/pager/FeedsTabBarMobile.tsx b/src/view/com/pager/FeedsTabBarMobile.tsx index e0c0be1e..2983a457 100644 --- a/src/view/com/pager/FeedsTabBarMobile.tsx +++ b/src/view/com/pager/FeedsTabBarMobile.tsx @@ -23,7 +23,7 @@ export function FeedsTabBar( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { const pal = usePalette('default') - const {isSandbox} = useSession() + const {isSandbox, hasSession} = useSession() const {_} = useLingui() const setDrawerOpen = useSetDrawerOpen() const feeds = usePinnedFeedsInfos() @@ -61,30 +61,35 @@ export function FeedsTabBar( {isSandbox ? 'SANDBOX' : 'Bluesky'} - - - - + + {hasSession && ( + + + + )} - + + {items.length > 0 && ( + + )} ) } @@ -104,8 +109,7 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 18, - paddingTop: 8, - paddingBottom: 2, + paddingVertical: 8, width: '100%', }, title: { diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 015c436f..ad9b6f7f 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -17,13 +17,8 @@ import {useSession} from '#/state/session' type Props = NativeStackScreenProps export function HomeScreen(props: Props) { - const {hasSession} = useSession() const {data: preferences} = usePreferencesQuery() - if (!hasSession) { - return - } - if (preferences) { return } else { @@ -35,35 +30,12 @@ export function HomeScreen(props: Props) { } } -function HomeScreenPublic() { - const setMinimalShellMode = useSetMinimalShellMode() - const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() - - const renderCustomFeedEmptyState = React.useCallback(() => { - return - }, []) - - useFocusEffect( - React.useCallback(() => { - setMinimalShellMode(false) - setDrawerSwipeDisabled(false) - }, [setDrawerSwipeDisabled, setMinimalShellMode]), - ) - - return ( - - ) -} - function HomeScreenReady({ preferences, }: Props & { preferences: UsePreferencesQueryResponse }) { + const {hasSession} = useSession() const setMinimalShellMode = useSetMinimalShellMode() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() const [selectedPage, setSelectedPage] = React.useState(0) @@ -144,7 +116,7 @@ function HomeScreenReady({ return }, []) - return ( + return hasSession ? ( + ) : ( + + + ) }