From 82655f2ee3c208c2a0ab148dba1bccf884213375 Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 1 Mar 2024 15:47:59 -0800 Subject: [PATCH] Few list tweaks on web (#3062) * share button only on native * update gttablet to be 1300px * improve web layout * change re-layout to mobile breakpoint * adjustable not found reason * don't show the borders on mobile web * slight padding for the spinner --- src/alf/index.tsx | 2 +- src/components/Lists.tsx | 28 +++++++++++++++++++++++----- src/screens/Hashtag.tsx | 35 +++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/alf/index.tsx b/src/alf/index.tsx index 06d6ebf0..27738e91 100644 --- a/src/alf/index.tsx +++ b/src/alf/index.tsx @@ -17,7 +17,7 @@ const breakpoints: { [key: string]: number } = { gtMobile: 800, - gtTablet: 1200, + gtTablet: 1300, } function getActiveBreakpoints({width}: {width: number}) { const active: (keyof typeof breakpoints)[] = Object.keys(breakpoints).filter( diff --git a/src/components/Lists.tsx b/src/components/Lists.tsx index cf00734f..12a93580 100644 --- a/src/components/Lists.tsx +++ b/src/components/Lists.tsx @@ -9,6 +9,7 @@ import {Text} from '#/components/Typography' import {StackActions} from '@react-navigation/native' import {useNavigation} from '@react-navigation/core' import {NavigationProp} from 'lib/routes/types' +import {router} from '#/routes' export function ListFooter({ isFetching, @@ -30,6 +31,7 @@ export function ListFooter({ a.align_center, a.justify_center, a.border_t, + a.pb_lg, t.atoms.border_contrast_low, {height: 100}, ]}> @@ -128,6 +130,7 @@ export function ListMaybePlaceholder({ isError, empty, error, + notFoundType = 'page', onRetry, }: { isLoading: boolean @@ -135,10 +138,12 @@ export function ListMaybePlaceholder({ isError: boolean empty?: string error?: string + notFoundType?: 'page' | 'results' onRetry?: () => Promise }) { const navigation = useNavigation() const t = useTheme() + const {gtMobile} = useBreakpoints() const canGoBack = navigation.canGoBack() const onGoBack = React.useCallback(() => { @@ -146,7 +151,14 @@ export function ListMaybePlaceholder({ navigation.goBack() } else { navigation.navigate('HomeTab') - navigation.dispatch(StackActions.popToTop()) + + // Checking the state for routes ensures that web doesn't encounter errors while going back + if (navigation.getState()?.routes) { + navigation.dispatch(StackActions.push(...router.matchPath('/'))) + } else { + navigation.navigate('HomeTab') + navigation.dispatch(StackActions.popToTop()) + } } }, [navigation, canGoBack]) @@ -157,8 +169,7 @@ export function ListMaybePlaceholder({ style={[ a.flex_1, a.align_center, - a.border_t, - a.justify_between, + !gtMobile ? [a.justify_between, a.border_t] : a.gap_5xl, t.atoms.border_contrast_low, {paddingTop: 175, paddingBottom: 110}, ]}> @@ -173,7 +184,13 @@ export function ListMaybePlaceholder({ {isError ? ( Oops! ) : isEmpty ? ( - Page not found + <> + {notFoundType === 'results' ? ( + No results found + ) : ( + Page not found + )} + ) : undefined} @@ -195,7 +212,8 @@ export function ListMaybePlaceholder({ ) : undefined} - + {isError && onRetry && (