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
31 changes: 31 additions & 0 deletions packages/mobile/src/components/user/FollowsYouBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ID } from '@audius/common/models'
import { accountSelectors } from '@audius/common/store'
import { useSelector } from 'react-redux'

import { MusicBadge } from '@audius/harmony-native'
import { trpc } from 'app/services/trpc-client-mobile'

const messages = {
followsYou: 'Follows You'
}

type FollowsYouBadgeProps = {
userId: ID
}

export const FollowsYouBadge = (props: FollowsYouBadgeProps) => {
const { userId } = props
const currentUserId = useSelector(accountSelectors.getUserId)
const { data } = trpc.me.userRelationship.useQuery(
{
theirId: userId.toString()
},
{
enabled: !!currentUserId
}
)

if (!data?.followsMe) return null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you really wanna do this again? lol jk


return <MusicBadge size='s'>{messages.followsYou}</MusicBadge>
}
51 changes: 0 additions & 51 deletions packages/mobile/src/components/user/FollowsYouChip.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/mobile/src/components/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './FollowButton'
export * from './FollowsYouChip'
export * from './FollowsYouBadge'
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export type MusicBadgeProps = {
* The type of the MusicBadge
*/
variant?: MusicBadgeVariant
/**
* The size of the MusicBadge
*/
size?: 's' | 'm'
/**
* The icon to display in the left of the MusicBadge
*/
Expand All @@ -29,9 +33,18 @@ export type MusicBadgeProps = {
} & ComponentPropsWithoutRef<'div'>

export const MusicBadge = (props: MusicBadgeProps) => {
const { variant = 'default', icon: Icon, color: colorProp, children } = props
const {
variant = 'default',
size = 's',
icon: Icon,
color: colorProp,
children
} = props
const { color } = useTheme()

const gap = size === 'm' ? 's' : 'xs'
const height = size === 'm' ? '2xl' : 'xl'

const backgroundColor = colorProp
? color.special[colorProp]
: variant === 'default'
Expand Down Expand Up @@ -60,9 +73,9 @@ export const MusicBadge = (props: MusicBadgeProps) => {
justifyContent='center'
borderRadius='s'
border='strong'
gap='xs'
ph='s'
pv='xs'
gap={gap}
h={height}
ph={size}
style={css({
backgroundColor: Color(backgroundColor).fade(0.92).toString(),
borderColor
Expand All @@ -71,7 +84,7 @@ export const MusicBadge = (props: MusicBadgeProps) => {
{Icon ? <Icon size='s' fill={iconColor} /> : null}
<Text
variant='label'
size='s'
size={size}
// Hack - should not have to explicitly set lineHeight, but there's a bug
// that adds extra margins to demibold + bold text variants.
style={css({ color: textColor, lineHeight: 16 })}
Expand Down
100 changes: 15 additions & 85 deletions packages/mobile/src/screens/profile-screen/ProfileInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {
chatSelectors,
reachabilitySelectors
} from '@audius/common/store'
import { View, Text } from 'react-native'
import { useDispatch, useSelector } from 'react-redux'

import { Flex } from '@audius/harmony-native'
import { FollowButton, FollowsYouChip } from 'app/components/user'
import UserBadges from 'app/components/user-badges'
import { Flex, Text } from '@audius/harmony-native'
import { FollowButton, FollowsYouBadge } from 'app/components/user'
import { UserLink } from 'app/components/user-link'
import { useRoute } from 'app/hooks/useRoute'
import { flexRowCentered, makeStyles } from 'app/styles'

import { EditProfileButton } from './EditProfileButton'
import { MessageButton } from './MessageButton'
Expand All @@ -28,55 +26,6 @@ const { getCanCreateChat } = chatSelectors
const { fetchBlockees, fetchBlockers, fetchPermissions } = chatActions
const { getProfileUserId } = profilePageSelectors

const useStyles = makeStyles(({ typography, palette, spacing }) => ({
name: {
...flexRowCentered(),
marginRight: spacing(2),
marginBottom: spacing(1)
},
username: {
...typography.h1,
color: palette.neutral,
marginBottom: 0 // Override h1 bottom margin for this layout to work
},
badges: {
marginTop: 2,
marginLeft: 2,
flexGrow: 1
},
handleInfo: {
flexDirection: 'row',
alignItems: 'center',
flexShrink: 1
},
handle: {
marginRight: spacing(2),
textAlignVertical: 'bottom'
},
handleText: {
...typography.h4,
color: palette.neutralLight4
},
followsYou: {
marginTop: -6,
borderRadius: 4,
overflow: 'hidden',
borderColor: palette.neutralLight4,
borderWidth: 1,
paddingVertical: spacing(1),
paddingHorizontal: spacing(2)
},
info: {
flexDirection: 'column',
justifyContent: 'flex-start',
marginBottom: spacing(2)
},
text: {
marginTop: spacing(2),
flexShrink: 1
}
}))

type ProfileInfoProps = {
onFollow: () => void
}
Expand All @@ -87,7 +36,6 @@ export const ProfileInfo = (props: ProfileInfoProps) => {
const { getIsReachable } = reachabilitySelectors
const isReachable = useSelector(getIsReachable)
const accountHandle = useSelector(getUserHandle)
const styles = useStyles()
const dispatch = useDispatch()

const profileUserId = useSelector((state) =>
Expand All @@ -110,13 +58,11 @@ export const ProfileInfo = (props: ProfileInfoProps) => {

const profile = useSelectProfile([
'user_id',
'name',
'handle',
'does_current_user_follow',
'is_verified'
'does_current_user_follow'
])

const { user_id, name, handle, does_current_user_follow } = profile
const { user_id, handle, does_current_user_follow } = profile

const isOwner =
params.handle === 'accountUser' ||
Expand Down Expand Up @@ -147,7 +93,7 @@ export const ProfileInfo = (props: ProfileInfoProps) => {
)

return (
<View pointerEvents='box-none' style={styles.info}>
<Flex pointerEvents='box-none' pv='s'>
<Flex
direction='row'
justifyContent='flex-end'
Expand All @@ -156,31 +102,15 @@ export const ProfileInfo = (props: ProfileInfoProps) => {
>
{isReachable ? actionButtons : null}
</Flex>
<View pointerEvents='none' style={styles.text}>
<View style={styles.name}>
<Text
accessibilityRole='header'
numberOfLines={1}
style={styles.username}
>
{name}
<Flex pointerEvents='none' alignItems='flex-start' gap='2xs'>
<UserLink userId={user_id} textVariant='title' size='l' />
<Flex direction='row' gap='s'>
<Text size='l' color='subdued'>
@{handle}
</Text>
<UserBadges
user={profile}
badgeSize={12}
style={styles.badges}
hideName
/>
</View>
<View style={styles.handleInfo}>
<View style={styles.handle}>
<Text style={styles.handleText} numberOfLines={1}>
@{handle}
</Text>
</View>
<FollowsYouChip userId={profile.user_id} />
</View>
</View>
</View>
<FollowsYouBadge userId={user_id} />
</Flex>
</Flex>
</Flex>
)
}
4 changes: 2 additions & 2 deletions packages/mobile/src/screens/user-list-screen/UserListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSelector } from 'react-redux'

import { IconUser } from '@audius/harmony-native'
import { Text, ProfilePicture } from 'app/components/core'
import { FollowButton, FollowsYouChip } from 'app/components/user'
import { FollowButton, FollowsYouBadge } from 'app/components/user'
import UserBadges from 'app/components/user-badges'
import { useNavigation } from 'app/hooks/useNavigation'
import { useColorAnimation } from 'app/hooks/usePressColorAnimation'
Expand Down Expand Up @@ -108,7 +108,7 @@ export const UserListItem = (props: UserListItemProps) => {
{messages.followers(follower_count)}
</Text>
</View>
<FollowsYouChip userId={user.user_id} />
<FollowsYouBadge userId={user.user_id} />
</View>
{tag === 'SUPPORTING' ? <SupportingInfo user={user} /> : null}
{tag === 'TOP SUPPORTERS' ? <SupporterInfo user={user} /> : null}
Expand Down