about summary refs log tree commit diff
path: root/src/screens/Profile/ProfileFollows.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-12-11 21:12:58 +0000
committerGitHub <noreply@github.com>2024-12-11 21:12:58 +0000
commit89c6ca94fe5f13a06d592be0771ebc27774b01ea (patch)
tree132c6144c814e75135bd51238334069945fb9efc /src/screens/Profile/ProfileFollows.tsx
parent7db5882ea287a7a97084680fc4d310f7077c44d1 (diff)
downloadvoidsky-89c6ca94fe5f13a06d592be0771ebc27774b01ea.tar.zst
Followers/following exact count (#7057)
* followers exact count in heading

* exact count for following

* move files to new dir

* use <Plural>
Diffstat (limited to 'src/screens/Profile/ProfileFollows.tsx')
-rw-r--r--src/screens/Profile/ProfileFollows.tsx56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/screens/Profile/ProfileFollows.tsx b/src/screens/Profile/ProfileFollows.tsx
new file mode 100644
index 000000000..a0b612795
--- /dev/null
+++ b/src/screens/Profile/ProfileFollows.tsx
@@ -0,0 +1,56 @@
+import React from 'react'
+import {Plural} from '@lingui/macro'
+import {useFocusEffect} from '@react-navigation/native'
+
+import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
+import {sanitizeDisplayName} from '#/lib/strings/display-names'
+import {useProfileQuery} from '#/state/queries/profile'
+import {useResolveDidQuery} from '#/state/queries/resolve-uri'
+import {useSetMinimalShellMode} from '#/state/shell'
+import {ProfileFollows as ProfileFollowsComponent} from '#/view/com/profile/ProfileFollows'
+import * as Layout from '#/components/Layout'
+
+type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollows'>
+export const ProfileFollowsScreen = ({route}: Props) => {
+  const {name} = route.params
+  const setMinimalShellMode = useSetMinimalShellMode()
+
+  const {data: resolvedDid} = useResolveDidQuery(name)
+  const {data: profile} = useProfileQuery({
+    did: resolvedDid,
+  })
+
+  useFocusEffect(
+    React.useCallback(() => {
+      setMinimalShellMode(false)
+    }, [setMinimalShellMode]),
+  )
+
+  return (
+    <Layout.Screen testID="profileFollowsScreen">
+      <Layout.Header.Outer>
+        <Layout.Header.BackButton />
+        <Layout.Header.Content>
+          {profile && (
+            <>
+              <Layout.Header.TitleText>
+                {sanitizeDisplayName(profile.displayName || profile.handle)}
+              </Layout.Header.TitleText>
+              <Layout.Header.SubtitleText>
+                <Plural
+                  value={profile.followersCount ?? 0}
+                  one="# following"
+                  other="# following"
+                />
+              </Layout.Header.SubtitleText>
+            </>
+          )}
+        </Layout.Header.Content>
+        <Layout.Header.Slot />
+      </Layout.Header.Outer>
+      <Layout.Center>
+        <ProfileFollowsComponent name={name} />
+      </Layout.Center>
+    </Layout.Screen>
+  )
+}