import {View} from 'react-native'
import {type AppBskyActorDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {urls} from '#/lib/constants'
import {getUserDisplayName} from '#/lib/getUserDisplayName'
import {logger} from '#/logger'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useProfileQuery} from '#/state/queries/profile'
import {useSession} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {useDialogControl} from '#/components/Dialog'
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
import {Link} from '#/components/Link'
import * as ProfileCard from '#/components/ProfileCard'
import {Text} from '#/components/Typography'
import {type FullVerificationState} from '#/components/verification'
import {VerificationRemovePrompt} from '#/components/verification/VerificationRemovePrompt'
import type * as bsky from '#/types/bsky'
export {useDialogControl} from '#/components/Dialog'
export function VerificationsDialog({
control,
profile,
verificationState,
}: {
control: Dialog.DialogControlProps
profile: bsky.profile.AnyProfileView
verificationState: FullVerificationState
}) {
return (
)
}
function Inner({
profile,
control,
verificationState: state,
}: {
control: Dialog.DialogControlProps
profile: bsky.profile.AnyProfileView
verificationState: FullVerificationState
}) {
const t = useTheme()
const {_} = useLingui()
const {gtMobile} = useBreakpoints()
const userName = getUserDisplayName(profile)
const label = state.profile.isViewer
? state.profile.isVerified
? _(msg`You are verified`)
: _(msg`Your verifications`)
: state.profile.isVerified
? _(msg`${userName} is verified`)
: _(
msg({
message: `${userName}'s verifications`,
comment: `Possessive, meaning "the verifications of {userName}"`,
}),
)
return (
{label}
{state.profile.isVerified ? (
This account has a checkmark because it's been verified by trusted
sources.
) : (
This account has one or more verifications, but it is not
currently verified.
)}
{profile.verification ? (
Verified by:
{profile.verification.verifications.map(v => (
))}
{profile.verification.verifications.some(v => !v.isValid) &&
state.profile.isViewer && (
Some of your verifications are invalid.
)}
) : null}
{
logger.metric('verification:learn-more', {
location: 'verificationsDialog',
})
}}>
Learn more
)
}
function VerifierCard({
verification,
subject,
outerDialogControl,
}: {
verification: AppBskyActorDefs.VerificationView
subject: bsky.profile.AnyProfileView
outerDialogControl: Dialog.DialogControlProps
}) {
const t = useTheme()
const {_} = useLingui()
const {currentAccount} = useSession()
const moderationOpts = useModerationOpts()
const {data: profile, error} = useProfileQuery({did: verification.issuer})
const verificationRemovePromptControl = useDialogControl()
const canAdminister = verification.issuer === currentAccount?.did
return (
{error ? (
<>
Unknown verifier
{verification.issuer}
>
) : profile && moderationOpts ? (
<>
{canAdminister && (
)}
>
) : (
<>
>
)}
outerDialogControl.close()}
/>
)
}