add a dialog for newskies to profiles
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {Pressable, View} from 'react-native'
|
||||||
|
import {AppBskyActorDefs, AppBskyGraphStarterpack} from '@atproto/api'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {HITSLOP_10} from 'lib/constants'
|
||||||
|
import {isNative} from 'platform/detection'
|
||||||
|
import {atoms as a} from '#/alf'
|
||||||
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
|
import {Newskie} from '#/components/icons/Newskie'
|
||||||
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
|
export function NewskieDialog({
|
||||||
|
profile,
|
||||||
|
}: {
|
||||||
|
profile: AppBskyActorDefs.ProfileViewDetailed
|
||||||
|
}) {
|
||||||
|
const {_} = useLingui()
|
||||||
|
const control = useDialogControl()
|
||||||
|
|
||||||
|
const profileName = profile.displayName || `@${profile.handle}`
|
||||||
|
const joinedVia = profile.joinedViaStarterPack
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Pressable
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel={_(msg`Open new user info dialog`)}
|
||||||
|
accessibilityHint={_(
|
||||||
|
msg`Opens a dialog with information about the new user`,
|
||||||
|
)}
|
||||||
|
hitSlop={HITSLOP_10}
|
||||||
|
onPress={control.open}>
|
||||||
|
<Newskie size={32} />
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Dialog.Outer control={control}>
|
||||||
|
<Dialog.Handle />
|
||||||
|
<Dialog.ScrollableInner label={_(msg`New user info dialog`)}>
|
||||||
|
<View style={[a.gap_md, isNative && {marginBottom: 40}]}>
|
||||||
|
<Text style={[a.font_bold, a.text_xl]}>
|
||||||
|
<Trans>{profileName} is new here!</Trans>
|
||||||
|
</Text>
|
||||||
|
<Text style={[]}>
|
||||||
|
{AppBskyGraphStarterpack.isRecord(joinedVia?.record) ? (
|
||||||
|
<Trans>
|
||||||
|
{profileName} recently joined Bluesky with{' '}
|
||||||
|
{joinedVia?.creator.displayName ||
|
||||||
|
`@${joinedVia?.creator.handle}`}
|
||||||
|
's starter pack!
|
||||||
|
</Trans>
|
||||||
|
) : (
|
||||||
|
<Trans>
|
||||||
|
{profileName} recently joined Bluesky on {profile.createdAt}.
|
||||||
|
</Trans>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</Dialog.ScrollableInner>
|
||||||
|
</Dialog.Outer>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import {View} from 'react-native'
|
|||||||
import Svg, {Path} from 'react-native-svg'
|
import Svg, {Path} from 'react-native-svg'
|
||||||
export function Newskie({size}: {size: number}) {
|
export function Newskie({size}: {size: number}) {
|
||||||
return (
|
return (
|
||||||
<View style={{height: size, width: size}}>
|
<View style={{height: size / 0.6, width: size}}>
|
||||||
<Svg fill="none" viewBox="0 0 21 11">
|
<Svg fill="none" viewBox="0 0 21 11">
|
||||||
<Path
|
<Path
|
||||||
fill="#FFC404"
|
fill="#FFC404"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {AppBskyActorDefs, ModerationDecision} from '@atproto/api'
|
import {AppBskyActorDefs, ModerationDecision} from '@atproto/api'
|
||||||
import {sanitizeHandle} from 'lib/strings/handles'
|
|
||||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
|
||||||
import {Shadow} from '#/state/cache/types'
|
|
||||||
|
|
||||||
|
import {Shadow} from '#/state/cache/types'
|
||||||
|
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
||||||
|
import {sanitizeHandle} from 'lib/strings/handles'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
import {NewskieDialog} from '#/components/StarterPack/NewskieDialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export function ProfileHeaderDisplayName({
|
export function ProfileHeaderDisplayName({
|
||||||
@@ -17,7 +18,7 @@ export function ProfileHeaderDisplayName({
|
|||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
return (
|
return (
|
||||||
<View pointerEvents="none">
|
<View style={[a.flex_row, a.align_center, a.gap_md]}>
|
||||||
<Text
|
<Text
|
||||||
testID="profileHeaderDisplayName"
|
testID="profileHeaderDisplayName"
|
||||||
style={[t.atoms.text, a.text_4xl, {fontWeight: '500'}]}>
|
style={[t.atoms.text, a.text_4xl, {fontWeight: '500'}]}>
|
||||||
@@ -26,6 +27,9 @@ export function ProfileHeaderDisplayName({
|
|||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
)}
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
|
<View style={[a.h_full]}>
|
||||||
|
<NewskieDialog profile={profile} />
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user