import React from 'react' import {View} from 'react-native' import {AppBskyGraphStarterpack, AtUri} from '@atproto/api' import {StarterPackViewBasic} from '@atproto/api/dist/client/types/app/bsky/graph/defs' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {sanitizeHandle} from 'lib/strings/handles' import {useSession} from 'state/session' import {atoms as a, useTheme} from '#/alf' import {StarterPack} from '#/components/icons/StarterPack' import {Link as InternalLink, LinkProps} from '#/components/Link' import {Text} from '#/components/Typography' export function Default({starterPack}: {starterPack?: StarterPackViewBasic}) { if (!starterPack) return null return ( ) } export function Notification({ starterPack, }: { starterPack?: StarterPackViewBasic }) { if (!starterPack) return null return ( ) } export function Card({ starterPack, noIcon, noDescription, }: { starterPack: StarterPackViewBasic noIcon?: boolean noDescription?: boolean }) { const {record, creator, joinedAllTimeCount} = starterPack const {_} = useLingui() const t = useTheme() const {currentAccount} = useSession() if (!AppBskyGraphStarterpack.isRecord(record)) { return null } return ( {!noIcon ? : null} {record.name} Starter pack by{' '} {creator?.did === currentAccount?.did ? _(msg`you`) : `@${sanitizeHandle(creator.handle)}`} {!noDescription && record.description ? ( {record.description} ) : null} {!!joinedAllTimeCount && joinedAllTimeCount >= 50 && ( {joinedAllTimeCount} users have joined! )} ) } export function Link({ starterPack, children, ...rest }: { starterPack: StarterPackViewBasic } & Omit) { const {record} = starterPack const {rkey, handleOrDid} = React.useMemo(() => { const rkey = new AtUri(starterPack.uri).rkey const {creator} = starterPack return {rkey, handleOrDid: creator.handle || creator.did} }, [starterPack]) if (!AppBskyGraphStarterpack.isRecord(record)) { return null } return ( {children} ) }