about summary refs log tree commit diff
path: root/src/components/verification/VerifierDialog.tsx
blob: c62f0183258f86b9d9d7a3bb206574e45aaa8edc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import {Text as RNText, View} from 'react-native'
import {Image} from 'expo-image'
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 {useSession} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {VerifierCheck} from '#/components/icons/VerifierCheck'
import {Link} from '#/components/Link'
import {Text} from '#/components/Typography'
import {type FullVerificationState} from '#/components/verification'
import type * as bsky from '#/types/bsky'

export {useDialogControl} from '#/components/Dialog'

export function VerifierDialog({
  control,
  profile,
  verificationState,
}: {
  control: Dialog.DialogControlProps
  profile: bsky.profile.AnyProfileView
  verificationState: FullVerificationState
}) {
  return (
    <Dialog.Outer control={control}>
      <Dialog.Handle />
      <Inner
        control={control}
        profile={profile}
        verificationState={verificationState}
      />
      <Dialog.Close />
    </Dialog.Outer>
  )
}

function Inner({
  profile,
  control,
}: {
  control: Dialog.DialogControlProps
  profile: bsky.profile.AnyProfileView
  verificationState: FullVerificationState
}) {
  const t = useTheme()
  const {_} = useLingui()
  const {gtMobile} = useBreakpoints()
  const {currentAccount} = useSession()

  const isSelf = profile.did === currentAccount?.did
  const userName = getUserDisplayName(profile)
  const label = isSelf
    ? _(msg`You are a trusted verifier`)
    : _(msg`${userName} is a trusted verifier`)

  return (
    <Dialog.ScrollableInner
      label={label}
      style={[
        gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
      ]}>
      <View style={[a.gap_lg]}>
        <View
          style={[
            a.w_full,
            a.rounded_md,
            a.overflow_hidden,
            t.atoms.bg_contrast_25,
            {minHeight: 100},
          ]}>
          <Image
            accessibilityIgnoresInvertColors
            source={require('../../../assets/images/initial_verification_announcement_1.png')}
            style={[
              {
                aspectRatio: 353 / 160,
              },
            ]}
            alt={_(
              msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`,
            )}
          />
        </View>

        <View style={[a.gap_sm]}>
          <Text style={[a.text_2xl, a.font_bold, a.pr_4xl, a.leading_tight]}>
            {label}
          </Text>
          <Text style={[a.text_md, a.leading_snug]}>
            <Trans>
              Accounts with a scalloped blue check mark{' '}
              <RNText>
                <VerifierCheck width={14} />
              </RNText>{' '}
              can verify others. These trusted verifiers are selected by
              Bluesky.
            </Trans>
          </Text>
        </View>

        <View
          style={[
            a.w_full,
            a.gap_sm,
            a.justify_end,
            gtMobile ? [a.flex_row, a.justify_end] : [a.flex_col],
          ]}>
          <Link
            overridePresentation
            to={urls.website.blog.initialVerificationAnnouncement}
            label={_(msg`Learn more about verification on Bluesky`)}
            size="small"
            variant="solid"
            color="primary"
            style={[a.justify_center]}
            onPress={() => {
              logger.metric(
                'verification:learn-more',
                {
                  location: 'verifierDialog',
                },
                {statsig: true},
              )
            }}>
            <ButtonText>
              <Trans>Learn more</Trans>
            </ButtonText>
          </Link>
          <Button
            label={_(msg`Close dialog`)}
            size="small"
            variant="solid"
            color="secondary"
            onPress={() => {
              control.close()
            }}>
            <ButtonText>
              <Trans>Close</Trans>
            </ButtonText>
          </Button>
        </View>
      </View>
    </Dialog.ScrollableInner>
  )
}