Unify profile tabs and lists screens placeholders (#4315)

zio/stable
Bartosz Kaszubowski 2024-06-04 01:05:26 +02:00 committed by GitHub
parent 8d8323421c
commit 44670c7ee2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 38 additions and 46 deletions

View File

@ -7,7 +7,7 @@ import {
View, View,
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
import {msg, Trans} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@ -18,12 +18,11 @@ import {isNative} from '#/platform/detection'
import {hydrateFeedGenerator} from '#/state/queries/feed' import {hydrateFeedGenerator} from '#/state/queries/feed'
import {usePreferencesQuery} from '#/state/queries/preferences' import {usePreferencesQuery} from '#/state/queries/preferences'
import {RQKEY, useProfileFeedgensQuery} from '#/state/queries/profile-feedgens' import {RQKEY, useProfileFeedgensQuery} from '#/state/queries/profile-feedgens'
import {usePalette} from 'lib/hooks/usePalette'
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
import {EmptyState} from 'view/com/util/EmptyState'
import {ErrorMessage} from '../util/error/ErrorMessage' import {ErrorMessage} from '../util/error/ErrorMessage'
import {List, ListRef} from '../util/List' import {List, ListRef} from '../util/List'
import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn'
import {Text} from '../util/text/Text'
import {FeedSourceCardLoaded} from './FeedSourceCard' import {FeedSourceCardLoaded} from './FeedSourceCard'
const LOADING = {_reactKey: '__loading__'} const LOADING = {_reactKey: '__loading__'}
@ -52,7 +51,6 @@ export const ProfileFeedgens = React.forwardRef<
{did, scrollElRef, headerOffset, enabled, style, testID, setScrollViewTag}, {did, scrollElRef, headerOffset, enabled, style, testID, setScrollViewTag},
ref, ref,
) { ) {
const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const theme = useTheme() const theme = useTheme()
const [isPTRing, setIsPTRing] = React.useState(false) const [isPTRing, setIsPTRing] = React.useState(false)
@ -138,13 +136,11 @@ export const ProfileFeedgens = React.forwardRef<
({item, index}: ListRenderItemInfo<any>) => { ({item, index}: ListRenderItemInfo<any>) => {
if (item === EMPTY) { if (item === EMPTY) {
return ( return (
<View <EmptyState
icon="hashtag"
message={_(msg`You have no feeds.`)}
testID="listsEmpty" testID="listsEmpty"
style={[{padding: 18, borderTopWidth: 1}, pal.border]}> />
<Text style={pal.textLight}>
<Trans>You have no feeds.</Trans>
</Text>
</View>
) )
} else if (item === ERROR_ITEM) { } else if (item === ERROR_ITEM) {
return ( return (
@ -176,7 +172,7 @@ export const ProfileFeedgens = React.forwardRef<
} }
return null return null
}, },
[error, refetch, onPressRetryLoadMore, pal, preferences, _], [error, refetch, onPressRetryLoadMore, preferences, _],
) )
React.useEffect(() => { React.useEffect(() => {

View File

@ -9,7 +9,8 @@ import {
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
import {AppBskyGraphDefs as GraphDefs} from '@atproto/api' import {AppBskyGraphDefs as GraphDefs} from '@atproto/api'
import {Trans} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
@ -17,11 +18,10 @@ import {MyListsFilter, useMyListsQuery} from '#/state/queries/my-lists'
import {useAnalytics} from 'lib/analytics/analytics' import {useAnalytics} from 'lib/analytics/analytics'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {s} from 'lib/styles' import {s} from 'lib/styles'
import {EmptyState} from 'view/com/util/EmptyState'
import {ErrorMessage} from '../util/error/ErrorMessage' import {ErrorMessage} from '../util/error/ErrorMessage'
import {List} from '../util/List' import {List} from '../util/List'
import {Text} from '../util/text/Text'
import {ListCard} from './ListCard' import {ListCard} from './ListCard'
import hairlineWidth = StyleSheet.hairlineWidth
const LOADING = {_reactKey: '__loading__'} const LOADING = {_reactKey: '__loading__'}
const EMPTY = {_reactKey: '__empty__'} const EMPTY = {_reactKey: '__empty__'}
@ -42,6 +42,7 @@ export function MyLists({
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const {track} = useAnalytics() const {track} = useAnalytics()
const {_} = useLingui()
const [isPTRing, setIsPTRing] = React.useState(false) const [isPTRing, setIsPTRing] = React.useState(false)
const {data, isFetching, isFetched, isError, error, refetch} = const {data, isFetching, isFetched, isError, error, refetch} =
useMyListsQuery(filter) useMyListsQuery(filter)
@ -83,14 +84,12 @@ export function MyLists({
({item, index}: {item: any; index: number}) => { ({item, index}: {item: any; index: number}) => {
if (item === EMPTY) { if (item === EMPTY) {
return ( return (
<View <EmptyState
key={item._reactKey} key={item._reactKey}
icon="list-ul"
message={_(msg`You have no lists.`)}
testID="listsEmpty" testID="listsEmpty"
style={[{padding: 18, borderTopWidth: hairlineWidth}, pal.border]}> />
<Text style={pal.textLight}>
<Trans>You have no lists.</Trans>
</Text>
</View>
) )
} else if (item === ERROR_ITEM) { } else if (item === ERROR_ITEM) {
return ( return (
@ -118,7 +117,7 @@ export function MyLists({
/> />
) )
}, },
[error, onRefresh, renderItem, pal], [error, onRefresh, renderItem, _],
) )
if (inline) { if (inline) {

View File

@ -7,7 +7,7 @@ import {
View, View,
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
import {msg, Trans} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@ -17,12 +17,11 @@ import {logger} from '#/logger'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {RQKEY, useProfileListsQuery} from '#/state/queries/profile-lists' import {RQKEY, useProfileListsQuery} from '#/state/queries/profile-lists'
import {useAnalytics} from 'lib/analytics/analytics' import {useAnalytics} from 'lib/analytics/analytics'
import {usePalette} from 'lib/hooks/usePalette'
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
import {EmptyState} from 'view/com/util/EmptyState'
import {ErrorMessage} from '../util/error/ErrorMessage' import {ErrorMessage} from '../util/error/ErrorMessage'
import {List, ListRef} from '../util/List' import {List, ListRef} from '../util/List'
import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn'
import {Text} from '../util/text/Text'
import {ListCard} from './ListCard' import {ListCard} from './ListCard'
const LOADING = {_reactKey: '__loading__'} const LOADING = {_reactKey: '__loading__'}
@ -49,7 +48,6 @@ export const ProfileLists = React.forwardRef<SectionRef, ProfileListsProps>(
{did, scrollElRef, headerOffset, enabled, style, testID, setScrollViewTag}, {did, scrollElRef, headerOffset, enabled, style, testID, setScrollViewTag},
ref, ref,
) { ) {
const pal = usePalette('default')
const theme = useTheme() const theme = useTheme()
const {track} = useAnalytics() const {track} = useAnalytics()
const {_} = useLingui() const {_} = useLingui()
@ -142,11 +140,11 @@ export const ProfileLists = React.forwardRef<SectionRef, ProfileListsProps>(
({item, index}: ListRenderItemInfo<any>) => { ({item, index}: ListRenderItemInfo<any>) => {
if (item === EMPTY) { if (item === EMPTY) {
return ( return (
<View testID="listsEmpty" style={[{padding: 18}, pal.border]}> <EmptyState
<Text style={pal.textLight}> icon="list-ul"
<Trans>You have no lists.</Trans> message={_(msg`You have no lists.`)}
</Text> testID="listsEmpty"
</View> />
) )
} else if (item === ERROR_ITEM) { } else if (item === ERROR_ITEM) {
return ( return (
@ -176,7 +174,7 @@ export const ProfileLists = React.forwardRef<SectionRef, ProfileListsProps>(
/> />
) )
}, },
[error, refetch, onPressRetryLoadMore, pal, _], [error, refetch, onPressRetryLoadMore, _],
) )
React.useEffect(() => { React.useEffect(() => {

View File

@ -61,7 +61,7 @@ export function Component({
return [pal.border, {height: screenHeight / 1.5}] return [pal.border, {height: screenHeight / 1.5}]
} }
return [pal.border, {flex: 1}] return [pal.border, {flex: 1, borderTopWidth: 1}]
}, [pal.border, screenHeight]) }, [pal.border, screenHeight])
return ( return (
@ -233,11 +233,7 @@ const styles = StyleSheet.create({
textAlign: 'center', textAlign: 'center',
fontWeight: 'bold', fontWeight: 'bold',
fontSize: 24, fontSize: 24,
marginBottom: 10, marginBottom: 12,
},
list: {
flex: 1,
borderTopWidth: 1,
}, },
btns: { btns: {
position: 'relative', position: 'relative',

View File

@ -8,6 +8,7 @@ import {
import {Text} from './text/Text' import {Text} from './text/Text'
import {UserGroupIcon} from 'lib/icons' import {UserGroupIcon} from 'lib/icons'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {isWeb} from 'platform/detection'
export function EmptyState({ export function EmptyState({
testID, testID,
@ -22,7 +23,9 @@ export function EmptyState({
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
return ( return (
<View testID={testID} style={[styles.container, pal.border, style]}> <View
testID={testID}
style={[styles.container, isWeb && pal.border, style]}>
<View style={styles.iconContainer}> <View style={styles.iconContainer}>
{icon === 'user-group' ? ( {icon === 'user-group' ? (
<UserGroupIcon size="64" style={styles.icon} /> <UserGroupIcon size="64" style={styles.icon} />
@ -48,9 +51,9 @@ export function EmptyState({
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
paddingVertical: 20, paddingVertical: 24,
paddingHorizontal: 36, paddingHorizontal: 36,
borderTopWidth: 1, borderTopWidth: isWeb ? 1 : undefined,
}, },
iconContainer: { iconContainer: {
flexDirection: 'row', flexDirection: 'row',

View File

@ -52,12 +52,12 @@ export function ListsScreen({}: Props) {
<View style={s.hContentRegion} testID="listsScreen"> <View style={s.hContentRegion} testID="listsScreen">
<SimpleViewHeader <SimpleViewHeader
showBackButton={isMobile} showBackButton={isMobile}
style={ style={[
!isMobile && [ pal.border,
pal.border, isMobile
{borderLeftWidth: hairlineWidth, borderRightWidth: hairlineWidth}, ? {borderBottomWidth: hairlineWidth}
] : {borderLeftWidth: hairlineWidth, borderRightWidth: hairlineWidth},
}> ]}>
<View style={{flex: 1}}> <View style={{flex: 1}}>
<Text type="title-lg" style={[pal.text, {fontWeight: 'bold'}]}> <Text type="title-lg" style={[pal.text, {fontWeight: 'bold'}]}>
<Trans>User Lists</Trans> <Trans>User Lists</Trans>