use useravatars for starter pack icon
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {View} from 'react-native'
|
||||||
|
import {AppBskyGraphDefs} from '@atproto/api'
|
||||||
|
|
||||||
|
import {UserAvatar} from 'view/com/util/UserAvatar'
|
||||||
|
import {atoms as a} from '#/alf'
|
||||||
|
|
||||||
|
export function StarterPackAvatarsIcon({
|
||||||
|
starterPack,
|
||||||
|
size = 60,
|
||||||
|
}: {
|
||||||
|
starterPack?: AppBskyGraphDefs.StarterPackView
|
||||||
|
size?: number
|
||||||
|
}) {
|
||||||
|
if (!starterPack) return null
|
||||||
|
|
||||||
|
// TODO be sure we get this back from the server
|
||||||
|
const avatars = starterPack.listItemsSample?.map(item => item.subject.avatar)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.rounded_sm,
|
||||||
|
{height: size, width: size, backgroundColor: '#0070FF'},
|
||||||
|
]}>
|
||||||
|
<View style={[a.flex_1, a.flex_row]}>
|
||||||
|
<UserAvatar avatar={avatars![0]} size={size / 2} type="square" />
|
||||||
|
<UserAvatar avatar={avatars![1]} size={size / 2} type="square" />
|
||||||
|
</View>
|
||||||
|
<View style={[a.flex_1, a.flex_row]}>
|
||||||
|
<UserAvatar avatar={avatars![2]} size={size / 2} type="square" />
|
||||||
|
<UserAvatar avatar={avatars![3]} size={size / 2} type="square" />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -127,6 +127,7 @@ function Header({
|
|||||||
isOwner={isOwn}
|
isOwner={isOwn}
|
||||||
avatar={undefined}
|
avatar={undefined}
|
||||||
creator={creator}
|
creator={creator}
|
||||||
|
starterPack={starterPack}
|
||||||
avatarType="starter-pack">
|
avatarType="starter-pack">
|
||||||
<View style={[a.flex_row, a.gap_sm]}>
|
<View style={[a.flex_row, a.gap_sm]}>
|
||||||
{__DEV__ && (
|
{__DEV__ && (
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import {Text} from '../util/text/Text'
|
|||||||
import {UserAvatar, UserAvatarType} from '../util/UserAvatar'
|
import {UserAvatar, UserAvatarType} from '../util/UserAvatar'
|
||||||
import {CenteredView} from '../util/Views'
|
import {CenteredView} from '../util/Views'
|
||||||
import hairlineWidth = StyleSheet.hairlineWidth
|
import hairlineWidth = StyleSheet.hairlineWidth
|
||||||
import {StarterPackIcon} from '#/components/icons/StarterPackIcon'
|
import {AppBskyGraphDefs} from '@atproto/api'
|
||||||
|
|
||||||
|
import {StarterPackAvatarsIcon} from '#/components/StarterPack/StarterPackAvatarsIcon'
|
||||||
|
|
||||||
export function ProfileSubpageHeader({
|
export function ProfileSubpageHeader({
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -31,6 +33,7 @@ export function ProfileSubpageHeader({
|
|||||||
isOwner,
|
isOwner,
|
||||||
creator,
|
creator,
|
||||||
avatarType,
|
avatarType,
|
||||||
|
starterPack,
|
||||||
children,
|
children,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
@@ -44,6 +47,7 @@ export function ProfileSubpageHeader({
|
|||||||
handle: string
|
handle: string
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
|
starterPack?: AppBskyGraphDefs.StarterPackView
|
||||||
avatarType: UserAvatarType | 'starter-pack'
|
avatarType: UserAvatarType | 'starter-pack'
|
||||||
}>) {
|
}>) {
|
||||||
const setDrawerOpen = useSetDrawerOpen()
|
const setDrawerOpen = useSetDrawerOpen()
|
||||||
@@ -132,7 +136,7 @@ export function ProfileSubpageHeader({
|
|||||||
accessibilityHint=""
|
accessibilityHint=""
|
||||||
style={{width: 58}}>
|
style={{width: 58}}>
|
||||||
{avatarType === 'starter-pack' ? (
|
{avatarType === 'starter-pack' ? (
|
||||||
<StarterPackIcon width={58} height={58} />
|
<StarterPackAvatarsIcon starterPack={starterPack} />
|
||||||
) : (
|
) : (
|
||||||
<UserAvatar type={avatarType} size={58} avatar={avatar} />
|
<UserAvatar type={avatarType} size={58} avatar={avatar} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import * as Menu from '#/components/Menu'
|
|||||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||||
import {openCamera, openCropper, openPicker} from '../../../lib/media/picker'
|
import {openCamera, openCropper, openPicker} from '../../../lib/media/picker'
|
||||||
|
|
||||||
export type UserAvatarType = 'user' | 'algo' | 'list' | 'labeler'
|
export type UserAvatarType = 'user' | 'algo' | 'list' | 'labeler' | 'square'
|
||||||
|
|
||||||
interface BaseUserAvatarProps {
|
interface BaseUserAvatarProps {
|
||||||
type?: UserAvatarType
|
type?: UserAvatarType
|
||||||
@@ -168,6 +168,13 @@ let UserAvatar = ({
|
|||||||
const backgroundColor = pal.colors.backgroundLight
|
const backgroundColor = pal.colors.backgroundLight
|
||||||
|
|
||||||
const aviStyle = useMemo(() => {
|
const aviStyle = useMemo(() => {
|
||||||
|
if (type === 'square') {
|
||||||
|
return {
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
backgroundColor,
|
||||||
|
}
|
||||||
|
}
|
||||||
if (type === 'algo' || type === 'list' || type === 'labeler') {
|
if (type === 'algo' || type === 'list' || type === 'labeler') {
|
||||||
return {
|
return {
|
||||||
width: size,
|
width: size,
|
||||||
|
|||||||
Reference in New Issue
Block a user