Skip to content

Commit f5a9c14

Browse files
committed
fix lint errors and update profile followers and profile follows
1 parent 6665bf2 commit f5a9c14

File tree

7 files changed

+123
-25
lines changed

7 files changed

+123
-25
lines changed

src/components/Lists.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import {msg, Trans} from '@lingui/macro'
44
import {useLingui} from '@lingui/react'
55

66
import {cleanError} from '#/lib/strings/errors'
7+
import {
8+
EmptyState,
9+
type EmptyStateButtonProps,
10+
} from '#/view/com/util/EmptyState'
711
import {CenteredView} from '#/view/com/util/Views'
812
import {atoms as a, flatten, useBreakpoints, useTheme} from '#/alf'
913
import {Button, ButtonText} from '#/components/Button'
@@ -129,6 +133,9 @@ let ListMaybePlaceholder = ({
129133
hideBackButton,
130134
sideBorders,
131135
topBorder = false,
136+
emptyStateIcon,
137+
emptyStateButton,
138+
useEmptyState = false,
132139
}: {
133140
isLoading: boolean
134141
noEmpty?: boolean
@@ -143,6 +150,9 @@ let ListMaybePlaceholder = ({
143150
hideBackButton?: boolean
144151
sideBorders?: boolean
145152
topBorder?: boolean
153+
emptyStateIcon?: React.ReactElement
154+
emptyStateButton?: EmptyStateButtonProps
155+
useEmptyState?: boolean
146156
}): React.ReactNode => {
147157
const t = useTheme()
148158
const {_} = useLingui()
@@ -180,6 +190,30 @@ let ListMaybePlaceholder = ({
180190
)
181191
}
182192

193+
if (useEmptyState) {
194+
return (
195+
<View
196+
style={[
197+
a.h_full_vh,
198+
a.align_center,
199+
a.justify_center,
200+
t.atoms.border_contrast_low,
201+
{paddingTop: 175, paddingBottom: 110},
202+
]}>
203+
<EmptyState
204+
icon={emptyStateIcon ?? 'growth'}
205+
message={
206+
emptyMessage ??
207+
(emptyType === 'results'
208+
? _(msg`No results found`)
209+
: _(msg`Page not found`))
210+
}
211+
button={emptyStateButton}
212+
/>
213+
</View>
214+
)
215+
}
216+
183217
if (!noEmpty) {
184218
return (
185219
<Error
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import {createSinglePathSVG} from './TEMPLATE'
22

3+
export const PeopleRemove2_Stroke1_Corner0_Rounded = createSinglePathSVG({
4+
viewBox: '0 0 65 64',
5+
strokeWidth: 2,
6+
strokeLinecap: 'round',
7+
strokeLinejoin: 'round',
8+
path: 'M32.4999 53.3333H15.429C13.8577 53.3333 12.6129 51.975 12.9574 50.4419C14.9904 41.396 22.3783 34.6667 32.4999 34.6667C33.4116 34.6667 34.3012 34.7213 35.1666 34.8272M53.8333 42.6667L48.4999 48M48.4999 48L43.1666 53.3333M48.4999 48L43.1666 42.6667M48.4999 48L53.8333 53.3333M41.8333 17.3333C41.8333 22.488 37.6546 26.6667 32.4999 26.6667C27.3453 26.6667 23.1666 22.488 23.1666 17.3333C23.1666 12.1787 27.3453 8 32.4999 8C37.6546 8 41.8333 12.1787 41.8333 17.3333Z',
9+
})
10+
311
export const PeopleRemove2_Stroke2_Corner0_Rounded = createSinglePathSVG({
412
path: 'M10 4a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5ZM5.5 6.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM16 11a1 1 0 0 1 1-1h5a1 1 0 1 1 0 2h-5a1 1 0 0 1-1-1ZM3.678 19h12.644c-.71-2.909-3.092-5-6.322-5s-5.613 2.091-6.322 5Zm-2.174.906C1.917 15.521 5.242 12 10 12c4.758 0 8.083 3.521 8.496 7.906A1 1 0 0 1 17.5 21h-15a1 1 0 0 1-.996-1.094Z',
513
})

src/screens/Profile/Sections/Feed.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '#/view/com/util/EmptyState'
1919
import {type ListRef} from '#/view/com/util/List'
2020
import {LoadLatestBtn} from '#/view/com/util/load-latest/LoadLatestBtn'
21-
import {atoms as a, ios, useTheme} from '#/alf'
21+
import {atoms as a, ios, useBreakpoints, useTheme} from '#/alf'
2222
import {EditBig_Stroke1_Corner0_Rounded as EditIcon} from '#/components/icons/EditBig'
2323
import {Text} from '#/components/Typography'
2424
import {type SectionRef} from './types'
@@ -58,7 +58,7 @@ export function ProfileFeedSection({
5858
screenHeightOffset: headerHeight,
5959
})
6060
const t = useTheme()
61-
61+
const {gtPhone} = useBreakpoints()
6262
const onScrollToTop = useCallback(() => {
6363
scrollElRef.current?.scrollToOffset({
6464
animated: isNative,
@@ -74,17 +74,27 @@ export function ProfileFeedSection({
7474

7575
const renderPostsEmpty = useCallback(() => {
7676
return (
77-
<EmptyState
78-
icon={
79-
emptyStateIcon || (
80-
<EditIcon size="3xl" fill={t.atoms.text_contrast_low.color} />
81-
)
82-
}
83-
message={emptyStateMessage || _(msg`No posts yet.`)}
84-
button={emptyStateButton}
85-
/>
77+
<View style={[a.flex_1, a.justify_center, a.align_center]}>
78+
<EmptyState
79+
style={{width: '100%', marginTop: gtPhone ? 0 : 200}}
80+
icon={
81+
emptyStateIcon || (
82+
<EditIcon size="3xl" fill={t.atoms.text_contrast_low.color} />
83+
)
84+
}
85+
message={emptyStateMessage || _(msg`No posts yet.`)}
86+
button={emptyStateButton}
87+
/>
88+
</View>
8689
)
87-
}, [_, t, emptyStateMessage, emptyStateButton, emptyStateIcon])
90+
}, [
91+
_,
92+
emptyStateButton,
93+
emptyStateIcon,
94+
emptyStateMessage,
95+
gtPhone,
96+
t.atoms.text_contrast_low.color,
97+
])
8898

8999
useEffect(() => {
90100
if (isIOS && isFocused && scrollElRef.current) {

src/view/com/lists/ProfileLists.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {useLingui} from '@lingui/react'
1818
import {useNavigation} from '@react-navigation/native'
1919
import {useQueryClient} from '@tanstack/react-query'
2020

21-
import {HashtagWideIcon} from '#/lib/icons'
2221
import {cleanError} from '#/lib/strings/errors'
2322
import {logger} from '#/logger'
2423
import {isIOS, isNative, isWeb} from '#/platform/detection'
@@ -31,6 +30,7 @@ import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
3130
import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
3231
import {atoms as a, ios, useTheme} from '#/alf'
3332
import * as FeedCard from '#/components/FeedCard'
33+
import {BulletList_Stroke1_Corner0_Rounded as ListIcon} from '#/components/icons/BulletList'
3434
import {ListFooter} from '#/components/Lists'
3535

3636
const LOADING = {_reactKey: '__loading__'}
@@ -151,19 +151,22 @@ export function ProfileFeedgens({
151151
return (
152152
<EmptyState
153153
icon={
154-
<HashtagWideIcon
155-
size={64}
156-
style={{color: t.atoms.text_contrast_low.color}}
154+
<ListIcon
155+
size="3xl"
156+
fill={t.atoms.text_contrast_low.color}
157+
viewBox="0 0 47 38"
157158
/>
158159
}
159-
message={_(msg`You haven't made any custom feeds yet.`)}
160+
message={_(
161+
msg`Lists allow you to see content from your favorite people.`,
162+
)}
160163
textStyle={[t.atoms.text_contrast_medium, a.font_medium]}
161164
button={{
162-
label: _(msg`Browse custom feeds`),
163-
text: _(msg`Browse custom feeds`),
164-
onPress: () => navigation.navigate('Feeds' as never),
165+
label: _(msg`Create a list`),
166+
text: _(msg`Create a list`),
167+
onPress: () => navigation.navigate('Lists' as never),
165168
size: 'small',
166-
color: 'secondary',
169+
color: 'primary',
167170
}}
168171
/>
169172
)

src/view/com/profile/ProfileFollowers.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import React from 'react'
22
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
33
import {msg} from '@lingui/macro'
44
import {useLingui} from '@lingui/react'
5+
import {useNavigation} from '@react-navigation/native'
56

67
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
78
import {cleanError} from '#/lib/strings/errors'
89
import {logger} from '#/logger'
910
import {useProfileFollowersQuery} from '#/state/queries/profile-followers'
1011
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
1112
import {useSession} from '#/state/session'
13+
import {useTheme} from '#/alf'
14+
import {PeopleRemove2_Stroke1_Corner0_Rounded as PeopleRemoveIcon} from '#/components/icons/PeopleRemove2'
1215
import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
1316
import {List} from '../util/List'
1417
import {ProfileCardWithFollowBtn} from './ProfileCard'
@@ -35,8 +38,10 @@ function keyExtractor(item: ActorDefs.ProfileViewBasic) {
3538

3639
export function ProfileFollowers({name}: {name: string}) {
3740
const {_} = useLingui()
41+
const navigation = useNavigation()
3842
const initialNumToRender = useInitialNumToRender()
3943
const {currentAccount} = useSession()
44+
const t = useTheme()
4045

4146
const [isPTRing, setIsPTRing] = React.useState(false)
4247
const {
@@ -91,12 +96,23 @@ export function ProfileFollowers({name}: {name: string}) {
9196
emptyType="results"
9297
emptyMessage={
9398
isMe
94-
? _(msg`You do not have any followers.`)
99+
? _(msg`No followers yet.`)
95100
: _(msg`This user doesn't have any followers.`)
96101
}
97102
errorMessage={cleanError(resolveError || error)}
98103
onRetry={isError ? refetch : undefined}
99104
sideBorders={false}
105+
useEmptyState={true}
106+
emptyStateIcon={
107+
<PeopleRemoveIcon size="3xl" fill={t.atoms.text_contrast_low.color} />
108+
}
109+
emptyStateButton={{
110+
label: _(msg`Go back`),
111+
text: _(msg`Go back`),
112+
color: 'secondary',
113+
size: 'small',
114+
onPress: () => navigation.goBack(),
115+
}}
100116
/>
101117
)
102118
}

src/view/com/profile/ProfileFollows.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import React from 'react'
22
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
33
import {msg} from '@lingui/macro'
44
import {useLingui} from '@lingui/react'
5+
import {useNavigation} from '@react-navigation/native'
56

67
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
8+
import {type NavigationProp} from '#/lib/routes/types'
79
import {cleanError} from '#/lib/strings/errors'
810
import {logger} from '#/logger'
11+
import {isWeb} from '#/platform/detection'
912
import {useProfileFollowsQuery} from '#/state/queries/profile-follows'
1013
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
1114
import {useSession} from '#/state/session'
15+
import {useTheme} from '#/alf'
16+
import {PeopleRemove2_Stroke1_Corner0_Rounded as PeopleRemoveIcon} from '#/components/icons/PeopleRemove2'
1217
import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
1318
import {List} from '../util/List'
1419
import {ProfileCardWithFollowBtn} from './ProfileCard'
@@ -37,6 +42,17 @@ export function ProfileFollows({name}: {name: string}) {
3742
const {_} = useLingui()
3843
const initialNumToRender = useInitialNumToRender()
3944
const {currentAccount} = useSession()
45+
const t = useTheme()
46+
const navigation = useNavigation<NavigationProp>()
47+
48+
const onPressFindAccounts = React.useCallback(() => {
49+
if (isWeb) {
50+
navigation.navigate('Search', {})
51+
} else {
52+
navigation.navigate('SearchTab')
53+
navigation.popToTop()
54+
}
55+
}, [navigation])
4056

4157
const [isPTRing, setIsPTRing] = React.useState(false)
4258
const {
@@ -97,6 +113,16 @@ export function ProfileFollows({name}: {name: string}) {
97113
errorMessage={cleanError(resolveError || error)}
98114
onRetry={isError ? refetch : undefined}
99115
sideBorders={false}
116+
useEmptyState={true}
117+
emptyStateIcon={
118+
<PeopleRemoveIcon size="3xl" fill={t.atoms.text_contrast_low.color} />
119+
}
120+
emptyStateButton={{
121+
label: _(msg`See suggested accounts`),
122+
text: _(msg`See suggested accounts`),
123+
variant: 'solid',
124+
onPress: onPressFindAccounts,
125+
}}
100126
/>
101127
)
102128
}

src/view/com/util/EmptyState.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {View} from 'react-native'
44

55
import {usePalette} from '#/lib/hooks/usePalette'
66
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
7-
import {atoms as a, useTheme} from '#/alf'
7+
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
88
import {Button, type ButtonProps, ButtonText} from '#/components/Button'
99
import {EditBig_Stroke1_Corner0_Rounded as EditIcon} from '#/components/icons/EditBig'
1010
import {Growth_Stroke2_Corner0_Rounded as Growth} from '#/components/icons/Growth'
@@ -34,9 +34,10 @@ export function EmptyState({
3434
const {isTabletOrDesktop} = useWebMediaQueries()
3535
const iconSize = isTabletOrDesktop ? 64 : 48
3636
const t = useTheme()
37+
const {gtMobile} = useBreakpoints()
3738

3839
const placeholderIcon = (
39-
<EditIcon size="2xl" fill={t.atoms.text_contrast_low.color} />
40+
<EditIcon size="3xl" fill={t.atoms.text_contrast_low.color} />
4041
)
4142

4243
const renderIcon = () => {
@@ -73,7 +74,7 @@ export function EmptyState({
7374
</View>
7475
<Text
7576
style={[
76-
{color: pal.colors.textLight, maxWidth: '40%'},
77+
{color: pal.colors.textLight, maxWidth: gtMobile ? '40%' : '60%'},
7778
a.font_medium,
7879
a.text_md,
7980
a.leading_snug,

0 commit comments

Comments
 (0)