Skip to content

Commit

Permalink
More exact counts (#7059)
Browse files Browse the repository at this point in the history
* post liked by

* rm unnecessary layout.center

* do post quotes/reposts

* set height of header to prevent layout shifts
  • Loading branch information
mozzius authored Dec 11, 2024
1 parent 89c6ca9 commit 48346ed
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/components/Layout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function Outer({
a.gap_sm,
gutters,
platform({
native: [a.pb_sm, a.pt_xs],
web: [a.py_sm],
native: [a.pb_xs, {minHeight: 48}],
web: [a.py_xs, {minHeight: 52}],
}),
t.atoms.border_contrast_low,
gtMobile && [a.mx_auto, {maxWidth: 600}],
Expand Down
29 changes: 24 additions & 5 deletions src/screens/Post/PostLikedBy.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {Plural, Trans} from '@lingui/macro'
import {useFocusEffect} from '@react-navigation/native'

import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers'
import {usePostThreadQuery} from '#/state/queries/post-thread'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy'
import {ViewHeader} from '#/view/com/util/ViewHeader'
import * as Layout from '#/components/Layout'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostLikedBy'>
export const PostLikedByScreen = ({route}: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const {_} = useLingui()
const {data: post} = usePostThreadQuery(uri)

let likeCount
if (post?.thread.type === 'post') {
likeCount = post.thread.post.likeCount
}

useFocusEffect(
React.useCallback(() => {
Expand All @@ -25,7 +29,22 @@ export const PostLikedByScreen = ({route}: Props) => {

return (
<Layout.Screen>
<ViewHeader title={_(msg`Liked By`)} />
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
{post && (
<>
<Layout.Header.TitleText>
<Trans>Liked By</Trans>
</Layout.Header.TitleText>
<Layout.Header.SubtitleText>
<Plural value={likeCount ?? 0} one="# like" other="# likes" />
</Layout.Header.SubtitleText>
</>
)}
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<PostLikedByComponent uri={uri} />
</Layout.Screen>
)
Expand Down
39 changes: 29 additions & 10 deletions src/screens/Post/PostQuotes.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import React from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {Plural, Trans} from '@lingui/macro'
import {useFocusEffect} from '@react-navigation/native'

import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers'
import {isWeb} from '#/platform/detection'
import {usePostThreadQuery} from '#/state/queries/post-thread'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostQuotes as PostQuotesComponent} from '#/view/com/post-thread/PostQuotes'
import {ViewHeader} from '#/view/com/util/ViewHeader'
import {CenteredView} from '#/view/com/util/Views'
import * as Layout from '#/components/Layout'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostQuotes'>
export const PostQuotesScreen = ({route}: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const {_} = useLingui()
const {data: post} = usePostThreadQuery(uri)

let quoteCount
if (post?.thread.type === 'post') {
quoteCount = post.thread.post.quoteCount
}

useFocusEffect(
React.useCallback(() => {
Expand All @@ -27,10 +29,27 @@ export const PostQuotesScreen = ({route}: Props) => {

return (
<Layout.Screen>
<CenteredView sideBorders={true}>
<ViewHeader title={_(msg`Quotes`)} showBorder={!isWeb} />
<PostQuotesComponent uri={uri} />
</CenteredView>
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
{post && (
<>
<Layout.Header.TitleText>
<Trans>Quotes</Trans>
</Layout.Header.TitleText>
<Layout.Header.SubtitleText>
<Plural
value={quoteCount ?? 0}
one="# quote"
other="# quotes"
/>
</Layout.Header.SubtitleText>
</>
)}
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<PostQuotesComponent uri={uri} />
</Layout.Screen>
)
}
39 changes: 29 additions & 10 deletions src/screens/Post/PostRepostedBy.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import React from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {Plural, Trans} from '@lingui/macro'
import {useFocusEffect} from '@react-navigation/native'

import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers'
import {isWeb} from '#/platform/detection'
import {usePostThreadQuery} from '#/state/queries/post-thread'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostRepostedBy as PostRepostedByComponent} from '#/view/com/post-thread/PostRepostedBy'
import {ViewHeader} from '#/view/com/util/ViewHeader'
import {CenteredView} from '#/view/com/util/Views'
import * as Layout from '#/components/Layout'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostRepostedBy'>
export const PostRepostedByScreen = ({route}: Props) => {
const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const setMinimalShellMode = useSetMinimalShellMode()
const {_} = useLingui()
const {data: post} = usePostThreadQuery(uri)

let quoteCount
if (post?.thread.type === 'post') {
quoteCount = post.thread.post.repostCount
}

useFocusEffect(
React.useCallback(() => {
Expand All @@ -27,10 +29,27 @@ export const PostRepostedByScreen = ({route}: Props) => {

return (
<Layout.Screen>
<CenteredView sideBorders={true}>
<ViewHeader title={_(msg`Reposted By`)} showBorder={!isWeb} />
<PostRepostedByComponent uri={uri} />
</CenteredView>
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
{post && (
<>
<Layout.Header.TitleText>
<Trans>Reposted By</Trans>
</Layout.Header.TitleText>
<Layout.Header.SubtitleText>
<Plural
value={quoteCount ?? 0}
one="# reposts"
other="# reposts"
/>
</Layout.Header.SubtitleText>
</>
)}
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<PostRepostedByComponent uri={uri} />
</Layout.Screen>
)
}
4 changes: 1 addition & 3 deletions src/screens/Profile/ProfileFollowers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export const ProfileFollowersScreen = ({route}: Props) => {
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<Layout.Center>
<ProfileFollowersComponent name={name} />
</Layout.Center>
<ProfileFollowersComponent name={name} />
</Layout.Screen>
)
}
4 changes: 1 addition & 3 deletions src/screens/Profile/ProfileFollows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export const ProfileFollowsScreen = ({route}: Props) => {
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<Layout.Center>
<ProfileFollowsComponent name={name} />
</Layout.Center>
<ProfileFollowsComponent name={name} />
</Layout.Screen>
)
}

0 comments on commit 48346ed

Please sign in to comment.