Bluesky app fork with some witchin' additions 馃挮
at main 162 lines 4.9 kB view raw
1import {Text as RNText, View} from 'react-native' 2import {Image} from 'expo-image' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {urls} from '#/lib/constants' 7import {getUserDisplayName} from '#/lib/getUserDisplayName' 8import {logger} from '#/logger' 9import {useDeerVerificationEnabled} from '#/state/preferences/deer-verification' 10import {useSession} from '#/state/session' 11import {atoms as a, useBreakpoints, useTheme} from '#/alf' 12import {Button, ButtonText} from '#/components/Button' 13import * as Dialog from '#/components/Dialog' 14import {VerifierCheck} from '#/components/icons/VerifierCheck' 15import {Link} from '#/components/Link' 16import {Text} from '#/components/Typography' 17import {type FullVerificationState} from '#/components/verification' 18import type * as bsky from '#/types/bsky' 19 20export {useDialogControl} from '#/components/Dialog' 21 22export function VerifierDialog({ 23 control, 24 profile, 25 verificationState, 26}: { 27 control: Dialog.DialogControlProps 28 profile: bsky.profile.AnyProfileView 29 verificationState: FullVerificationState 30}) { 31 return ( 32 <Dialog.Outer control={control}> 33 <Dialog.Handle /> 34 <Inner 35 control={control} 36 profile={profile} 37 verificationState={verificationState} 38 /> 39 <Dialog.Close /> 40 </Dialog.Outer> 41 ) 42} 43 44function Inner({ 45 profile, 46 control, 47}: { 48 control: Dialog.DialogControlProps 49 profile: bsky.profile.AnyProfileView 50 verificationState: FullVerificationState 51}) { 52 const t = useTheme() 53 const {_} = useLingui() 54 const {gtMobile} = useBreakpoints() 55 const {currentAccount} = useSession() 56 57 const isSelf = profile.did === currentAccount?.did 58 const userName = getUserDisplayName(profile) 59 const label = isSelf 60 ? _(msg`You are a trusted verifier`) 61 : _(msg`${userName} is a trusted verifier`) 62 63 const deerVerificationEnabled = useDeerVerificationEnabled() 64 65 return ( 66 <Dialog.ScrollableInner 67 label={label} 68 style={[ 69 gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full, 70 ]}> 71 <View style={[a.gap_lg]}> 72 {!deerVerificationEnabled && ( 73 <View 74 style={[ 75 a.w_full, 76 a.rounded_md, 77 a.overflow_hidden, 78 t.atoms.bg_contrast_25, 79 {minHeight: 100}, 80 ]}> 81 <Image 82 accessibilityIgnoresInvertColors 83 source={require('../../../assets/images/initial_verification_announcement_1.png')} 84 style={[ 85 { 86 aspectRatio: 353 / 160, 87 }, 88 ]} 89 alt={_( 90 msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`, 91 )} 92 /> 93 </View> 94 )} 95 96 <View style={[a.gap_sm]}> 97 <Text 98 style={[a.text_2xl, a.font_semi_bold, a.pr_4xl, a.leading_tight]}> 99 {label} 100 </Text> 101 <Text style={[a.text_md, a.leading_snug]}> 102 <Trans> 103 Accounts with a scalloped blue check mark{' '} 104 <RNText> 105 <VerifierCheck width={14} /> 106 </RNText>{' '} 107 can verify others. These trusted verifiers are selected by{' '} 108 {deerVerificationEnabled ? 'you' : 'Bluesky'}. 109 </Trans> 110 </Text> 111 </View> 112 113 <View 114 style={[ 115 a.w_full, 116 a.gap_sm, 117 a.justify_end, 118 gtMobile ? [a.flex_row, a.justify_end] : [a.flex_col], 119 ]}> 120 <Link 121 overridePresentation 122 to={urls.website.blog.initialVerificationAnnouncement} 123 label={_( 124 msg({ 125 message: `Learn more about verification on Bluesky`, 126 context: `english-only-resource`, 127 }), 128 )} 129 size="small" 130 variant="solid" 131 color="primary" 132 style={[a.justify_center]} 133 onPress={() => { 134 logger.metric( 135 'verification:learn-more', 136 { 137 location: 'verifierDialog', 138 }, 139 {statsig: true}, 140 ) 141 }}> 142 <ButtonText> 143 <Trans context="english-only-resource">Learn more</Trans> 144 </ButtonText> 145 </Link> 146 <Button 147 label={_(msg`Close dialog`)} 148 size="small" 149 variant="solid" 150 color="secondary" 151 onPress={() => { 152 control.close() 153 }}> 154 <ButtonText> 155 <Trans>Close</Trans> 156 </ButtonText> 157 </Button> 158 </View> 159 </View> 160 </Dialog.ScrollableInner> 161 ) 162}