Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/mobile/src/components/details-tile/DetailsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,14 @@ export const DetailsTile = ({
) : null}
{!isPublished ? null : (
<DetailsTileStats
playCount={playCount}
hidePlayCount={hidePlayCount}
favoriteCount={saveCount}
hideFavoriteCount={hideFavoriteCount}
repostCount={repostCount}
hideRepostCount={hideRepostCount}
onPressFavorites={onPressFavorites}
onPressReposts={onPressReposts}
repostCount={repostCount}
/>
)}
{description ? (
Expand Down
31 changes: 13 additions & 18 deletions packages/mobile/src/components/details-tile/DetailsTileStats.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { pluralize } from '@audius/common/utils'

import { Flex, IconHeart, IconPlay, IconRepost } from '@audius/harmony-native'
import type { GestureResponderHandler } from 'app/types/gesture'

import { DetailsTileStat } from './DetailsStat'

const messages = {
plays: 'Plays',
favorites: 'Favorites',
reposts: 'Reposts'
favorites: (count: number) => `${pluralize('Favorite', count)}`,
reposts: (count: number) => `${pluralize('Repost', count)}`
}

type DetailsTileStatsProps = {
playCount?: number
repostCount?: number
favoriteCount?: number
hidePlayCount?: number
hidePlayCount?: boolean
hideRepostCount?: boolean
hideFavoriteCount?: boolean
onPressFavorites?: GestureResponderHandler
Expand All @@ -24,21 +25,15 @@ type DetailsTileStatsProps = {
* The stats displayed on track and playlist screens
*/
export const DetailsTileStats = ({
playCount,
repostCount,
favoriteCount,
playCount = 0,
repostCount = 0,
favoriteCount = 0,
hidePlayCount,
hideRepostCount,
hideFavoriteCount,
onPressFavorites,
onPressReposts
}: DetailsTileStatsProps) => {
if (
(hideFavoriteCount && hideRepostCount && hidePlayCount) ||
(!favoriteCount && !repostCount && !playCount)
) {
return null
}
return (
<Flex
w='100%'
Expand All @@ -48,22 +43,22 @@ export const DetailsTileStats = ({
justifyContent='flex-start'
>
{hidePlayCount ? null : (
<DetailsTileStat count={playCount ?? 0} icon={IconPlay} />
<DetailsTileStat count={playCount} icon={IconPlay} />
)}
{hideRepostCount ? null : (
<DetailsTileStat
count={repostCount ?? 0}
count={repostCount}
onPress={onPressReposts}
icon={IconRepost}
label={messages.reposts}
label={messages.reposts(repostCount)}
/>
)}
{hideFavoriteCount ? null : (
<DetailsTileStat
count={favoriteCount ?? 0}
count={favoriteCount}
onPress={onPressFavorites}
icon={IconHeart}
label={messages.favorites}
label={messages.favorites(favoriteCount)}
/>
)}
</Flex>
Expand Down
4 changes: 3 additions & 1 deletion packages/mobile/src/components/details-tile/MetadataItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ type MetadataItemProps = PropsWithChildren<{
export const MetadataItem = ({ label, children }: MetadataItemProps) => {
return (
<Flex direction='row' alignItems='center' key={label} gap='xs'>
<Text variant='label'>{label}</Text>
<Text variant='label' color='subdued'>
{label}
</Text>
<Text variant='body' size='s' strength='strong'>
{children}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,13 @@ export const TrackScreenDetailsTile = ({
hideRepost={hideRepost}
hideShare={isUnlisted && !isOwner}
hideOverflow={!isReachable || (isUnlisted && !isOwner)}
hideFavoriteCount={isUnlisted}
hidePlayCount={(!isOwner && isUnlisted) || isStreamGated}
hideRepostCount={isUnlisted}
hideFavoriteCount={isUnlisted || (!isOwner && (save_count ?? 0) <= 0)}
hidePlayCount={
(!isOwner && isUnlisted) ||
isStreamGated ||
(!isOwner && (play_count ?? 0) <= 0)
}
hideRepostCount={isUnlisted || (!isOwner && (repost_count ?? 0) <= 0)}
isPlaying={isPlaying && isPlayingId}
isPreviewing={isPreviewing}
isUnlisted={isUnlisted}
Expand Down